1. Install
cd / usr / src # to enter the download directory (the directory set their own) yum install -y the make TCL # wget gcc installation depends wget HTTP: //download.redis.io/releases/redis- 3.2 . 1 .tar.gz # Download Source package the tar -zxvf redis- 3.2 . . 1 .tar.gz # decompression CD redis - 3.2 . . 1 # enter the directory redis the make the make && test # compiling and testing the make the install the PREFIX = / usr / local / redis #prefix installation directory specified
2. Start
1. Stand-alone start
./bin/redis-server # start redis service
2. Sentinel mode
1. In the / usr / local / Create a directory redis-sentinel, and then create three folders
mkdir /usr/local/redis-sentinel mkdir /usr/local/redis-sentinel/{8333,8334,8335,8336}
2. The installation directory redis reids.conf copy the configuration file folder 8333,8334, custom configuration in which some of the following (other configuration unchanged):
#Redis default is not a way to run daemon, you can modify the configuration item, use yes Enable daemon daemonize yes # When Redis when running in daemon mode, the default Redis will pid write /var/run/redis.pid file, you can specify pidfile pidfile /var/run/redis_8333.pid listening # Redis specified, the default port is 6379, the author explains why the choice of 6379 as the default port in his blog post, since 6379 MERZ on the phone keypad the corresponding number, and MERZ from Italian showgirl Alessia Merz name Port 8333 # bindings host address (such as setting up two network cards on two ip virtual machine: . 134,133 if bind the ip 134, and the 133 can not be accessed by redis to the service) the bind 192.168.37.134 # logging mode, the default is standard output, log output to specify the log file logfile "./redis-8333.log" # specify the local database storage directory dir "/ usr / local / redis- sentinel / 8333 " # When the master service is password-protected, slave master password for the service connection masterauth ADMIN .123 # Set Redis connection password, if configured connection password, a password is required by the client AUTH <password> command when connected Redis, off by default ADMIN requirepass .123 # specify whether after each update operation logging, Redis default asynchronous data is written to disk, if you do not turn, may result in data over a period of time when power is lost. # Redis itself as synchronous data file is based on the above criteria to save synchronized, so some data will exist only in the memory for some time. The default is NO appendOnly Yes # is set when the slave machine according to the present service, set the master service IP address and port, at Redis starts, it will automatically synchronize the data from the master (in the present embodiment mainly port 8333 , from 8334 to , so in the following only to) the 8334 configuration slaveof 192.168.37.134 8333
3. Copy the sentinel.conf 8335,8336 redis installation directory files in the folder, which is custom configured as follows:
# ============================================ custom configuration start = ======================================= #Redis default is not run as daemon, you can use this configuration item changes, the use of yes to enable daemon daemonize yes # designated Redis listening port, the default port is 6379, the author explains why the choice of 6379 as the default port in his blog post, since 6379 MERZ correspondence on the phone keypad numbers, and MERZ from Italian showgirl Alessia Merz name Port 8336 # specify the local database storage directory dir "/ usr / local / Redis-Sentinel / 8336" # logging mode, the default is standard output, log output to a specified log file logfile "./sentinel.log" # alias specified number of master address port sentry (down to a few sentinel to monitor the execution transition master node) Sentinel monitor mymaster 193.168.37.134. 1 8333 # 3s if not received within the master node sentinel heartbeat, Sentinel is considered the primary node goes down, the default is 30 seconds Down-After-milliseconds Sentinel mymaster 3000 # after the election of a new master node, the number of nodes can be connected from Sentinel Parallel-mymaster The syncs . 1 # if after 10 seconds , Master still did not alive, failover is started, the default 180s Sentinel timeout-mymaster failover 10000 # configure password connected to the master node redis Sentinel Pass mymaster the auth-ADMIN .1231 # ============================= =============== custom configuration end =============================== =========
4. Start redis service (bin folder in make installation directory)
4.1. First start from the master
[root@localhost bin]# redis-server /usr/local/redis-sentinel/8333/redis-8333.conf [root@localhost bin]# redis-server /usr/local/redis-sentinel/8334/redis-8334.conf 查看服务信息 [root@localhost bin]# redis-cli -h 192.168.37.134 -p 8333 -a admin.1231 192.168.37.134:8333> info replication # Replication role:master connected_slaves:1 slave0:ip=192.168.37.134,port=8334,state=online,offset=57,lag=0 master_repl_offset:57 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:2 repl_backlog_histlen:56
4.2. Start Sentinel
[root@localhost bin]# redis-sentinel /usr/local/redis-sentinel/8335/redis-8335.conf [root@localhost bin]# redis-sentinel /usr/local/redis-sentinel/8336/redis-8336.conf
4.3. Check process
[root@localhost bin]# ps -ef | grep redis root 26149 1 0 14:58 ? 00:00:01 redis-server 192.168.37.134:8333 root 26153 1 0 14:58 ? 00:00:01 redis-server 192.168.37.134:8334 root 26188 1 0 15:04 ? 00:00:02 redis-sentinel *:8335 [sentinel] root 26230 1 0 15:06 ? 00:00:02 redis-sentinel *:8336 [sentinel] root 26281 1382 0 15:26 pts/0 00:00:00 grep --color=auto redis
After starting if the external network can not access
1. Check whether the firewall open port
how to open a port that does
add a
firewall-cmd --zone = public --add- port = 8333 / tcp --permanent ( after --permanent permanent, you do not have this parameter to restart failed)
again Loading
firewall-cmd --reload
view
firewall-cmd --zone = public --query- port = 8333 / tcp
delete
Firewall-cmd = --zone public --remove-Port = 8333 / tcp --permanent
2. configuration in a bind if the error
3. password is wrong