The Sentinel redis

 

 


#: Emerge redis4. 0 [the root Master @ ~] # the tar XF redis- 4.0 . 14 . The tar .gz [the root Master @ ~] CD redis- # 4.0 . 14 / [the root @ Master Redis - 4.0 . 14 ] # the make the PREFIX = / Apps / redis the install #: Create user redis [root @ Master redis - 4.0 . 14 ] the groupadd -g # 55 redis redis && the useradd -u -R & lt -g 55 redis #: Create the required directory redis [root Redis the @Master - 4.0 .14]# mkdir /apps/redis/{data,etc,logs,run} [root@master redis-4.0.14]# chown -R redis.redis /apps/redis/* #:创建环境变量软连接 [root@master redis-4.0.14]# ln -sv /apps/redis/bin/redis-* /usr/bin #:创建启动脚本 [root@master redis-4.0.14]# vim /usr/lib/systemd/system/redis.service [Unit] Description=Redis persistent key-value database After=network.target After=network-online.target Wants=network-online.target [Service] ExecStart=/apps/redis/bin/redis-server /apps/redis/etc/redis.conf --supervised systemd ExecStop = # / usr / libexec / Redis the shutdown- ExecReload=/bin/kill -s HUP $MAINPID ExecStop = / bin / -s the kill the QUIT $ MAINPID the Type = Notify the User Redis = Group = Redis RuntimeDirectory = Redis RuntimeDirectoryMode = 0755 [the Install] WantedBy = multi-user.target #: Preparation redis profile [@ Master redis the root-4.0.14] # CP redis.conf / Apps / redis / etc / #: modify profile [the root @ Master etc] # Vim /apps/redis/etc/redis.conf the bind 0.0 .0.0 PidFile /apps/redis/run/redis_6379.pid logfile "/apps/redis/logs/redis_6379.log" STOP ON-Writes-error-NO-bgsave the dir "/ Apps / Redis / Data /" masterauth 123456 requirepass 123456 yes appendOnly #: package will redis directory, copy to each node [root @ Master Apps] # tar zcvf redis.tar.gz ./* [root @ Master Apps] # scp redis.tar.gz 192.168.7.105:/apps/ [root @ Master Apps] # scp redis.tar.gz 192.168.7.106:/apps/ #; startup script also copy the past [root @ Master Apps] # scp /usr/lib/systemd/system/redis.service 192.168.7.105:/usr/lib/systemd/system/ [root @master apps] # scp /usr/lib/systemd/system/redis.service 192.168.7.106:/usr/lib/systemd/system/

 

The remaining two nodes from the node is configured to

  

#: Extract the files 

[the root @ Slave ~] # CD / Apps / 
[the root @ Slave Apps] # the tar XF Redis. The tar .gz 
[the root @ Slave Apps] Redis CD # / 

#: modify the configuration file, the node is configured to 

[root @ Slave redis] # vim etc / redis.conf 
slaveof 192.168 . 7.101  6379 
masterauth " 123456 " 


#: Creating redis user 


[root @ Slave redis] # groupadd -g 55 redis redis && useradd -g -u 55 redis 

#: start service 

[root @ Slave Redis] # systemctl start Redis 

#: detection 

[root @ Slave Redis] # Redis - cli 
 127.0. 0.1 : 6379 > AUTH 123456  

# Replication 
Role: Slave 
MASTER_HOST: 192.168 . 7.101 
MASTER_PORT: 6379 
master_link_status: up 

#: 106 is also configured such that it

 

Sentinel node disposed in each

#: Preparation Sentinel profile 

[the root @ Master Apps] CD # ~ / redis- 4.0 . 14 / 
[the root @ Master Redis - 4.0 . 14 ] # CP sentinel.conf / Apps / Redis / etc / 

#: Modify owner genus group 

[the root @ Master Redis - 4.0 . 14 ] # chown -R & lt redis.redis / Apps / Redis / * 

#; modify profile 

[root @ master redis-4.0.14] # vim / apps / redis / etc / sentinel. conf 
the bind 0.0.0.0 
dir "/ Apps / Redis /" 
Sentinel Monitor mymaster 192.168.7.101 6379 # 2: write at least half the number of all cluster 

Sentinel auth-Pass mymaster 123456  
Sentinel deny-scripts-reconfig yes
daemonize yes 
PidFile "/apps/redis/run/redis-sentinel.pid" 
logfile "/apps/redis/logs/sentinel_26379.log" 


#: Copy profile to each node 


[root @ master redis] # scp etc / sentinel 192.168.7.105:/apps/redis/etc/ .conf 
[root @ master Redis] # scp etc / sentinel.conf 192.168.7.106:/apps/redis/etc/ 

#: Sentinel started (start primary election, followed by start) from the 

[the root @ master etc] # / Apps / Redis / bin / Redis-Sentinel /apps/redis/etc/sentinel.conf 



#: test stopped master 


#: If the master node back online, remember to change the configuration files from the server is configured to limit

 

Guess you like

Origin www.cnblogs.com/maxuebin/p/11484897.html