In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
I. deployment environment
System: centos7
Complete the deployment of the master-slave cluster by starting two different redis instances on the Linux system
Yum source deployed
II. Download and installation of redis
1. Download: download from the official website
2. Installation
Create / app/ directory, and redis is installed in / app/ directory
[root@liyg~] # mkdir / app [root@liyg~] # cd / usr/local/src/ [root@liyg src] # lsredis-4.0.11.tar.gz [root@liyg src] # tar zxf redis-4.0.11.tar.gz-C / app/ [root@liyg~] # yum install-y gcc* [root@liyg~] # cd / app/redis-4.0.11/ [root@liyg redis-4.0.11] # make [root@liyg redis-4.0.11] # make install3, By configuring different ports To launch different instances [root@liyg ~] # mkdir / app/redis_ replication [root @ liyg ~] # mkdir / app/redis_replication/7001_ master [root @ liyg ~] # mkdir / app/redis_replication/7002_ slave [root @ liyg ~] # cp / app/redis-4.0.11/redis.conf / app/redis_replication/7001_master/ [root @ liyg ~] # cp / app/redis-4.0.11/redis.conf / app/redis_replication/7002_slave/
Edit master profile
[root@liyg ~] # cd / app/redis_replication/ [root @ liyg redis_replication] # vim 7001_master/redis.conf # modify port 6379 to 7001 dir / app/redis_replication/7001_master pidfile / var/run/redis_7001.pid logfile "/ app/redis_replication/7001_master/7001.log" protected-mode no # # yes to no to turn off security mode daemonize yes # # to start in daemon mode Use requirepass qwer1234 # # to enable password authentication masterauth qwer1234 # # need to add when Sentinel mode is enabled In case slave is upgraded to master, it cannot be synchronized
Edit slave profile
[root@liyg redis_replication] # vim 7001_master/redis.conf # port changed to 7002 dir / app/redis_replication/7002_slave pidfile / var/run/redis_7002.pid logfile "/ app/redis_replication/7002_slave/7002.log" protected-mode no masterauth qwer1234 # # password required for synchronizing master requirepass qwer1234 # # enable password authentication slaveof 127.0.0.1 7001 # added
Start redis
[root@liyg redis_replication] # redis-server 7001_master/redis.conf 2521:C 03 Dec 15:50:54.660 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo2521:C 03 Dec 15:50:54.661 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=2521 Just started2521:C 03 Dec 15:50:54.661 # Configuration loaded [root@liyg redis_replication] # redis-server 7002_slave/redis.conf 2530:C 03 Dec 15:51:07.037 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo2530:C 03 Dec 15:51:07.037 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=2530, just started2530:C 03 Dec 15:51:07.037 # Configuration loaded
4. Verification
[root@liyg redis_replication] # redis-cli-p 7001-a qwer1234 info replicationrole:masterconnected_slaves:1slave0:ip=127.0.0.1,port=7002,state=online,offset=70,lag=1 [root@liyg redis_replication] # redis-cli-p 7002-a qwer1234 info replicationmaster_host:127.0.0.1master_port:7001...
Create a KEY in master to check whether the slave is synchronized
[root@liyg ~] # redis-cli-p 7001-a qwer1234 set K1 t1OK [root@liyg ~] # redis-cli-p 7002-a qwer1234 get K1 "T1"
At this point, the master-slave configuration of redis is complete.
Configure redis master-slave sentinel mode
[root@liyg app] # cp redis-4.0.11/sentinel.conf redis_replication/ [root @ liyg app] # vim redis_replication/sentinel.conf protected-mode no # # turn off the security mode sentinel monitor mymaster 127.0.0.1 7002 1 sentinel auth-pass mymaster qwer1234 # # when the redis master-slave cluster has password authentication
Start
[root@liyg app] # redis-sentinel redis_replication/sentinel.conf
Verification
Close the master7001 port and see if port 7002 has been upgraded to master through the Sentinel
[root@liyg redis_replication] # redis-cli-p 7001-a qwer1234 shutdown
When master is off, you can see the Sentinel's output.
... = 'class1' > 2138Dec X 04 Dec 09 Dec 0515 525 * + slave slave 127.0.1 @ mymaster 127.0.0.1 70022138 Dec 09 Dec 0515 525 * + 645 # + sdown slave 127.0. 0.1 redis-cli 7001 127.0.0.1 7001 @ mymaster 127.0.0.1 7002 [root@liyg redis_replication] # redis-cli-p 7002-a qwer1234 info replicationrole:masterconnected_slaves:0
You can see that the original slave7002 has been upgraded to master, and start the 7001 instance again
[root@liyg redis_replication] # redis-server 7001_master/redis.conf
[root@liyg redis_replication] # redis-cli-p 7001-a qwer1234 info replication
Role:slavemaster_host:127.0.0.1master_port:7002
7001 has become a 7002 slave library, and the verification is successful.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.