Sentinel master mode from redis +

redis main structures from Sentinel +

 

Prior to installation, you need to install the environment, otherwise the compiler will complain
need to install gcc: yum install gcc-c ++

A master node structures
1. redis installation package uploaded to the directory / usr / local / redis

2. extracting package
tar -zxvf redis-5.0.5.tar.gz

3. Extract the package copy, changed its name to Master-Redis
cp -r Redis-5.0.5 / usr / local / Redis / Redis-Master

4. directory compiled into
CD-Master Redis /
the make

5. Modify the configuration file
vim redis.conf
modifications are as follows:
Enable daemon: daemonize yes
setting pidfile path: pidfile /usr/local/redis/redis-master/redis.pid
set the port: port 8379
unbind host address: # bind 127.0.0.1
change log path: logfile "/usr/local/redis/redis-master/logs/master.log"
password: requirepass redis
more # Note the log path needs to be created logs directory and file master.log

6. Then create two files to start and stop
vi start.sh
/ usr / local / Redis / Redis-Master / src / Redis-Server /usr/local/redis/redis-master/redis.conf

vi stop.sh
kill `cat /usr/local/redis/redis-master/redis_6379.pid`

7. authorization script
chmod 777 * .sh

8. You can execute scripts to start or stop Redis
./start.sh
./stop.sh

9. Check the process
ps aux | grep redis

The master node completed structures

Second, the structures from the node

1 set up from node
1. Copy redis extracting a good package
CD / usr / local / redis
CP -R & lt redis-5.0.5 / usr / local / redis / redis-Slave1

2. Compile
make

3. Modify the configuration file
vim redis.conf
modifications are as follows:
Enable daemon: daemonize yes
setting pidfile path: pidfile /usr/local/redis/redis-slave1/redis.pid
set the port: port 8380
unbind host address: # bind 127.0.0.1 # master node IP and port
change log path: logfile "/usr/local/redis/redis-slave1/logs/slave1.log"
binding primary node ID: slaveof 127.0.0.1 8379
master node password: masterauth redis # master node password
password: requirepass redis # password and the master node consistent

6. Then create two files to start and stop
vi start.sh
/ usr / local / Redis / Redis-slave1 / src / Redis-Server /usr/local/redis/redis-slave1/redis.conf

vi stop.sh
kill `cat /usr/local/redis/redis-slave1/redis_6379.pid`

7. authorization script
chmod 777 * .sh

8. You can execute scripts to start or stop Redis
./start.sh
./stop.sh

9. Check the process
ps aux | grep redis

Completed structures from node 1

Structures from node 2
1. a copy of the decompressed file
/ usr / local / Redis
CP--R & lt Redis 5.0.5 / usr / local / Redis / Redis-slave2

2. Compile
make

3. Modify the configuration file
vim redis.conf
modifications are as follows:
Enable daemon: daemonize yes
setting pidfile path: pidfile /usr/local/redis/redis-slave2/redis.pid
set the port: port 8381
unbind host address: # bind 127.0.0.1 # master node IP and port
change log path: logfile "/usr/local/redis/redis-slave2/logs/slave2.log"
binding primary node ID: slaveof 127.0.0.1 8379
master node password: masterauth redis # master node password
password: requirepass redis # password and the master node consistent

6. Then create two files to start and stop
vi start.sh
/ usr / local / Redis / Redis-slave2 / src / Redis-Server /usr/local/redis/redis-slave2/redis.conf

vi stop.sh
kill `cat /usr/local/redis/redis-slave2/redis_6379.pid`

7. authorization script
chmod 777 * .sh

8. You can execute scripts to start or stop Redis
./start.sh
./stop.sh

9. Check the process
ps aux | grep redis


Third, the sentinel node build
Sentinel node 1 to build a
1 1 directly from the nodes copied without carrying compiled
cp -r redis-slave1 / usr / local / redis / redis-sentinel1

2. modify the configuration file
vim sentinel.conf
modifications are as follows:
Enable daemon: daemonize yes
setting pidfile path: pidfile /usr/local/redis/redis-sentinel1/redis.pid
set the port: port 20001
change log path: logfile " /usr/local/redis/redis-sentinel1/logs/sentinel1.log "
# alias specified number of master address port sentry (down to a few sentinel to monitor the execution transition master node)
disposed in the master node listens: sentinel monitor mymaster 127.0.0.1 8379 2
set the master node password: auth-Sentinel Pass mymaster Redis
# If the heartbeat is not received within the master node sentry 3s, sentry considered the primary node goes down, the default is 30 seconds
set the expiration time (in seconds) : Down-Sentinel after milliseconds mymaster-30000
# If after 10 seconds, Master still did not alive, is initiated failover, 180s default
settings failover time (in milliseconds): sentinel failover-timeout mymaster 6000

6. Then create two files to start and stop
vi start.sh
/ usr / local / Redis / Redis-sentinel1 / src / Redis-Server /usr/local/redis/redis-sentinel1/redis.conf

vi stop.sh
kill `cat /usr/local/redis/redis-sentinel1/redis_6379.pid`

7. authorization script
chmod 777 * .sh

8. You can execute scripts to start or stop Redis
./start.sh
./stop.sh

9. Check the process
ps aux | grep redis


Sentinel node 2 built, will build two sentinel node, it is time to write down here, do not re-write the third sentinel node structures
1. Direct the sentinel node 1 copied without performing compile, and some configuration files change without re-
# cp -r Redis-sentinel1 / usr / local / Redis / Redis-sentinel2
# cp -r Redis-sentinel1 / usr / local / Redis / Redis-sentinel3

2. modify the configuration file
vim sentinel.conf
modifications are as follows:
Enable daemon: daemonize yes
setting pidfile path: pidfile /home/redis/redis-sentinel2/redis.pid
set the port: port 20002
change log path: logfile "/ home /redis/redis-sentinel2/logs/sentinel2.log "
master node listens provided: sentinel monitor mymaster 127.0.0.1 8379 2
provided the master node password: sentinel auth-pass mymaster redis
set dead time (in seconds): sentinel down- after-milliseconds mymaster 30000
disposed failover time (in milliseconds): sentinel failover-timeout mymaster 6000

The remaining steps above. . .

Fourth, view the status
1. See sentinel node status
/ usr / local / redis / redis -sentinel1 / src / redis-cli -p 20001 -a redis
connect before input commands:
info Sentinel
Under normal circumstances, will have the following output:

If prompted NOAUTH Authentication required.
The password is required
auth Redis
info Sentinel

Exit connected
quit

2. Check the status of master node
# / usr / local / Redis / Redis-Master / the src / CLI -p-8379 -a Redis Redis
127.0.0.1:8379> info Replication


3.查看从节点状态
[root@iZwz9clei4hhnvm8rucly7Z redis-sentinel3]# /usr/local/redis/redis-slave1/src/redis-cli -p 8380 -a redis
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:8380> info replication

 

Guess you like

Origin www.cnblogs.com/zboy-bin/p/11415294.html