In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will bring you an article on how to copy redis from master and slave. The editor thinks it's pretty good, so I'll share it for you as a reference. Let's follow the editor and have a look.
The process of synchronous implementation of redis master-slave replication
1. Send a sync synchronization command to the master service to request full synchronization from the slave service
two。 When the master service receives the sync synchronization command from the slave service, it will fork a child process to execute the bgsave command in the background (non-blocking) snapshot save, generate the RDB file, and set the
Send the RDB file to the slave service
3. Load the received RDB file into its own redis memory from the service
4. After the slave service loads the RDB, the master service sends all write commands in the buffer to the slave service.
5. The slave service loads all the write commands of the master service into memory to achieve complete data synchronization.
6. The slave service only needs to send its own offset location (equivalent to the location of mysql binlog) when it needs to synchronize data next time, and only the newly added data is synchronized, without the need for full synchronization.
Master-slave synchronization through configuration files
1. Just configure the slave service profile
[root@localhost] # vim / app/redis/etc/redis.conf... .. slaveof 192.168.1.9 6379 # add a slave service belonging to a host. .. masterauth 123456 # password for connecting to the master server from the slave service. Slave-read-only yes # is read-only from the service and cannot write data on the command line.
two。 Restart the slave service to realize the master-slave connection
[root@localhost ~] # redis-server / app/redis/etc/redis.conf [root@localhost ~] # redis-cli127.0.0.1:6379 > auth 123456OK127.0.0.1:6379 > info replication#Replicationrole:slavemaster_host:192.168.1.9master_port:6379master_link_status:up.
This is how redis does master-slave replication. The code should be clear enough, and I believe there are quite a few examples that we may meet in our daily work. Through this article, I hope you can gain more.
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.