Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ To compile and install Redis Linux and master-slave replication configuration     - LVM management parameters commonly used commands explained in detail (Linux)

- Java filter (Programming)

- PostgreSQL 9.3.2 Json type of use (Database)

- Oracle 11g contraction table space error ORA-03297: file contains used data beyondrequested RESIZE value (Database)

- Windows7 system using Vagrant to build Linux virtualized development environment (Linux)

- Linux file content inspection - cat, tac, no, more, less, head, tail, od (Linux)

- Puppet Detailed centralized configuration management system (Server)

- PCM audio under Linux (Linux)

- Prevent security threats caused Rootkit (Linux)

- Java environment to build a number of issues (Linux)

- Hadoop 2.0 Detailed Configuration Tutorial (Server)

- Ubuntu uses conky add desktop control (Linux)

- SpringMVC the use of interceptors (Programming)

- Installing Linux and Windows 10 dual system (Linux)

- Linux / Unix: chroot command examples to explain (Linux)

- HBase cluster installation and deployment (Server)

- How to Install Suricata IDS on a Linux system (Server)

- Linux Basics Tutorial: Linux Kickstart automated installation (Linux)

- Security Knowledge: redirection command application security (Linux)

- Modifying the system registry protection server security (Linux)

 
         
  To compile and install Redis Linux and master-slave replication configuration
     
  Add Date : 2017-08-31      
         
         
         
  Redis installation configuration is very simple, and long before the installed Redis, these days can be installed again forgotten some details, it seems better to write a bad memory, or in the blog record is better, at least not always Hold your mother thigh.

Today, the compiler installed several times and found that the list did not actually specified in the document generated prefix? ?? Read a half-day results found PREFIX I used lowercase letters. . .

It seems to have recorded a correct operation steps, so again such distress.

First, select the version

Go to the official website: http: //www.redis.io/download

Choose a suitable stable version, such as the latest stable version of redis-3.0 (stable), access to download address:

Http://download.redis.io/releases/redis-3.0.0.tar.gz

Second, compile and install

Cd / usr / local / src
Wget http://download.redis.io/releases/redis-3.0.0.tar.gz
Tar zxvf redis-3.0.0.tar.gz
Cd redis-3.0.0
Make
# Run the make test command

# Remember here PREFIX is capitalized, lowercase does not take effect!
Make PREFIX = / usr / local / redis-3.0.0 install

# Create a soft link
Ln -s /usr/local/redis-3.0.0 / usr / local / redis

# Create a directory and copy the default configuration file in the past
Mkdir -p / usr / local / redis / {etc, var}
Cp redis.conf / usr / local / etc /

# If it is to provide services to other machines, it is recommended to set the monitor IP in redis.conf 0.0.0.0, start can open a process, the default is 2, there is a 127.0.0.1
Bind 0.0.0.0

Cd / usr / local / src

Wget http://download.redis.io/releases/redis-3.0.0.tar.gz

Tar zxvf redis-3.0.0.tar.gz

Cd redis-3.0.0

Make

# Run the make test command

 

# Remember here PREFIX is capitalized, lowercase does not take effect!

Make PREFIX = / usr / local / redis-3.0.0 install

 

# Create a soft link

Ln -s /usr/local/redis-3.0.0 / usr / local / redis

# Create a directory and copy the default configuration file in the past

Mkdir -p / usr / local / redis / {etc, var}

Cp redis.conf / usr / local / etc /
 

# If it is to provide services to other machines, it is recommended to set the monitor IP in redis.conf 0.0.0.0, start can open a process, the default is 2, there is a 127.0.0.1

Bind 0.0.0.0


After the installation is complete, redis directory structure is as follows:

[Root @ cache-ns-4 ~] # tree / usr / local / redis
/ Usr / local / redis
 Bin # bin stored below the implementation of various documents
 Redis-benchmark
 Redis-check-aof
 Redis-check-dump
 Redis-cli #redis The client executes the file
 Redis-sentinel -> /usr/local/redis-3.0.0/bin/redis-server
 Redis-server #redis The server executable file
 Dump.rdb # After the default data file generated, you can set the redis.conf path parameters specified in the dir to another directory
 Etc
 Redis.conf
 Var

[Root @ cache-ns-4 ~] # tree / usr / local / redis

/ Usr / local / redis

  Bin # bin stored below the implementation of various documents

  Redis-benchmark

  Redis-check-aof

  Redis-check-dump

  Redis-cli #redis The client executes the file

  Redis-sentinel -> /usr/local/redis-3.0.0/bin/redis-server

  Redis-server #redis The server executable file

Dump.rdb # After the default data file generated, you can set the redis.conf path parameters specified in the dir to another directory

Etc

Redis.conf

  Var

 

Third, registration services

1, the preparation of service control script

Vi /etc/init.d/redis

#! / Bin / bash
#
# Redis - this script starts and stops the redis-server daemon
#
# Chkconfig: - 80 12
# Description: Redis is a persistent key-value database
# Processname: redis-server
# Config: /usr/local/redis/etc/redis.conf
# Pidfile: /usr/local/redis/var/redis.pid
 
Source /etc/init.d/functions
 
BIN = "/ usr / local / redis / bin"
CONFIG = "/ usr / local / redis / etc / redis.conf"
PIDFILE = "/ var / run / redis.pid"
 
 
### Read configuration
[-r "$ SYSCONFIG"] && source "$ SYSCONFIG"
 
RETVAL = 0
Prog = "redis-server"
Desc = "Redis Server"
 
Start () {
 
     If [-e $ PIDFILE]; then
       Echo "$ desc already running ...."
       Exit 1
     Fi
 
     Echo -n $ "Starting $ desc:"

     # Occasionally found in the use of server startup actually do not turn into the background, so in the final addition of a "&"
     Daemon $ BIN / $ prog $ CONFIG &
 
     RETVAL = $?
     Echo
     [$ RETVAL -eq 0] && touch / var / lock / subsys / $ prog
     Return $ RETVAL
}}

Stop () {
     Echo -n $ "Stop $ desc:"
     Killproc $ prog
     RETVAL = $?
     Echo
     [$ RETVAL -eq 0] && rm -f / var / lock / subsys / $ prog $ PIDFILE
     Return $ RETVAL
}}
 
Restart () {
   Stop
   Start
}}
 
Case "$ 1" in
  Start)
     Start
     ;
  Stop)
     Stop
     ;
  Restart)
     Restart
     ;
  Condrestart)
     [-e / var / lock / subsys / $ prog] && restart
     RETVAL = $?
     ;
  Status)
     Status $ prog
     RETVAL = $?
     ;
   *)
     Echo $ "Usage: $ 0 {start | stop | restart | condrestart | status}"
     RETVAL = 1
Esac
 
Exit $ RETVAL


#! / Bin / bash

#

# Redis - this script starts and stops the redis-server daemon

#

# Chkconfig: - 80 12

# Description: Redis is a persistent key-value database

# Processname: redis-server

# Config: /usr/local/redis/etc/redis.conf

# Pidfile: /usr/local/redis/var/redis.pid

Source /etc/init.d/functions

 
BIN = "/ usr / local / redis / bin"

CONFIG = "/ usr / local / redis / etc / redis.conf"

PIDFILE = "/ var / run / redis.pid"

### Read configuration

[-r "$ SYSCONFIG"] && source "$ SYSCONFIG"



RETVAL = 0

Prog = "redis-server"

Desc = "Redis Server"

 
Start () {

    If [-e $ PIDFILE]; then

      Echo "$ desc already running ...."

      Exit 1

    Fi


    Echo -n $ "Starting $ desc:"

    # Occasionally found in the use of server startup actually do not turn into the background, so in the final addition of a "&"

    Daemon $ BIN / $ prog $ CONFIG &

    RETVAL = $?

    Echo

    [$ RETVAL -eq 0] && touch / var / lock / subsys / $ prog

    Return $ RETVAL

}}

 
Stop () {

    Echo -n $ "Stop $ desc:"

    Killproc $ prog

    RETVAL = $?

    Echo

    [$ RETVAL -eq 0] && rm -f / var / lock / subsys / $ prog $ PIDFILE

    Return $ RETVAL

}}

 
Restart () {

  Stop

  Start

}}

 

Case "$ 1" in

Start)

    Start

    ;

Stop)

    Stop

    ;

Restart)

    Restart

    ;

Condrestart)

    [-e / var / lock / subsys / $ prog] && restart

    RETVAL = $?

    ;

Status)

    Status $ prog

    RETVAL = $?

    ;

  *)

    Echo $ "Usage: $ 0 {start | stop | restart | condrestart | status}"

    RETVAL = 1

Esac

Exit $ RETVAL

2, registration services and start

# Give Execute permission
Chmod + x /etc/init.d/redis

#boot
Chkconfig redis on

# Start the service
Service redis start

# The following is the startup record
[Root @ localhost ~] # service redis start
Starting Redis Server:
[Root @ localhost ~] # _._
          _.- `` __ '' -._
      _.- ``. `_. '' -._ Redis 3.0.0 (00000000/0) 64 bit
  . -``. `` `.` `` \ / _., _ '' -._
 ( ',.-`|`,) Running in stand alone mode
 | `-._` -...- `__...-.` `-._ | '_.-' | Port: 6379
 | `-._` ._ / _.- '| PID: 28584
  `-._` -._ `-. / _.- '_.-'
 | `-._` -._ `-.__.- '_.-'_.-' |
 | `-._` -._ _.-'_.- '| http://redis.io
  `-._` -._ `-.__.-'_.- '_.-'
 | `-._` -._ `-.__.- '_.-'_.-' |
 | `-._` -._ _.-'_.- '|
  `-._` -._ `-.__.-'_.- '_.-'
      `-._` -.__.- '_.-'
          `-._ _.- '
              `-.__.- '

[28584] 16 Apr 23: 48: 55.614 # Server started, Redis version 3.0.0
[28584] 16 Apr 23: 48: 55.614 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or Run the command 'sysctl vm.overcommit_memory = 1' for this to take effect.
[28584] 16 Apr 23:48:55.614 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never> / sys / Kernel / mm / transparent_hugepage / enabled 'as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
[28584] 16 Apr 23: 48: 55.614 # WARNING: The TCP backlog setting of 511 can not be enforced because / proc / sys / net / core / somaxconn is set to the lower value of 128.
[28584] 16 Apr 23: 48: 55.615 * DB loaded from disk: 0.000 seconds
[28584] 16 Apr 23: 48: 55.615 * The server is now ready to accept connections on port 6379


# Give Execute permission

Chmod + x /etc/init.d/redis

#boot

Chkconfig redis on

# Start the service

Service redis start


# The following is the startup record

[Root @ localhost ~] # service redis start

Starting Redis Server:

[Root @ localhost ~] # _._

          _.- `` __ '' -._

      _.- ``. `_. '' -._ Redis 3.0.0 (00000000/0) 64 bit

  . -``. `` `.` `` \ / _., _ '' -._

( ',.-`|`,) Running in stand alone mode

| `-._` -...- `__...-.` `-._ | '_.-' | Port: 6379

| `-._` ._ / _.- '| PID: 28584

  `-._` -._ `-. / _.- '_.-'

| `-._` -._ `-.__.- '_.-'_.-' |

| `-._` -._ _.-'_.- '| http://redis.io

  `-._` -._ `-.__. -'_.- '_.-'

| `-._` -._ `-.__.- '_.-'_.-' |

| `-._` -._ _.-'_.- '|

  `-._` -._ `-.__.-'_.- '_.-'

      `-._` -.__.- '_.-'

          `-._ _.- '

              `-.__.- '

 

[28584] 16 Apr 23: 48: 55.614 # Server started, Redis version 3.0.0

[28584] 16 Apr 23: 48: 55.614 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or Run the command 'sysctl vm.overcommit_memory = 1' for this to take effect.

[28584] 16 Apr 23:48:55.614 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never> / sys / Kernel / mm / transparent_hugepage / enabled 'as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.

[28584] 16 Apr 23: 48: 55.614 # WARNING: The TCP backlog setting of 511 can not be enforced because / proc / sys / net / core / somaxconn is set to the lower value of 128.

[28584] 16 Apr 23: 48: 55.615 * DB loaded from disk: 0.000 seconds

[28584] 16 Apr 23: 48: 55.615 * The server is now ready to accept connections on port 6379

Fourth, the master-slave configuration

1, configuration

In accordance with the above steps from the machine to install redis, and then from the machine redis.conf which add the following configuration items:


# Specify the IP address and port number of the redis host (password authentication is disabled by default)
Slaveof 192.168.10.124 6379


# Specify the IP address and port number of the redis host (password authentication is disabled by default)

Slaveof 192.168.10.124 6379


Save the redis to complete a simple master-slave configuration.

2, the test

Test is very simple, first in the host through the client redis-cli implementation of the new key-value command:


[Root @ localhost ~] # / usr / local / redis / bin / redis-cli
127.0.0.1:6379> set newkey slavetest
OK

 

[Root @ localhost ~] # / usr / local / redis / bin / redis-cli

127.0.0.1:6379> set newkey slavetest

OK


Then, the same machine from the implementation of redis-cli implementation of the inquiry:


[Root @ localhost ~] # / usr / local / redis / bin / redis-cli
127.0.0.1:6379> get newkey
"Slavetest"

[Root @ localhost ~] # / usr / local / redis / bin / redis-cli

127.0.0.1:6379> get newkey

"Slavetest"


Obviously the new host keys have been automatically synchronized to the slave, master-slave synchronization success!

This article only records the basic compilation and installation and master-slave configuration, of course, redis also can continue to customize the settings or optimization of the project, the follow-up have the opportunity to continue to organize to add.
     
         
         
         
  More:      
 
- Ubuntu 14.04 kernel after the restart boot black screen to solve (Linux)
- Installation salt-minion on RHEL5 (Linux)
- Linux User Management (Linux)
- Java JDK has been able to compile without warning (Programming)
- [JavaScript] catch (ex) statements of ex (Programming)
- Polymorphism of the C ++ compiler and run-time polymorphism (Programming)
- Spring AOP custom annotation way to achieve log management (Programming)
- Recover accidentally deleted Nginx logs (Server)
- Multipath configuration under Linux (Linux)
- Mutt - an email client that sends messages through the terminal (Linux)
- To compiler and install MariaDB-10.0.20 under CentOS 6.6 (Database)
- MySQL error: ERROR 1175: You are using safe update mode solution (Database)
- Introduction and MongoDB CRUD (Database)
- MySQL to recover the data through binlog (Database)
- Oracle View index and use indexes Precautions (Database)
- How to enable curl command HTTP2 support (Linux)
- CentOS5 installation Nodejs (Linux)
- Configuring a Linux operating system against syn attack (Linux)
- Through the source code to install MySQL 5.6.26 under CentOS6 (Database)
- Security of data to create a safe .mdb database (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.