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 > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "what are the ways of Redis node configuration replication". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Establish replication
By default, Redis is the master node, but in the case of replication, Redis instances are usually divided into master node (master) and slave node (slave), and each slave node has only one master node, while the master node can have multiple slave nodes at the same time. In addition, when Redis is copied, it can only be copied from the master node to the slave node, not from the slave node to the master node. Let's take a look at how to configure replication in Redis.
There are three main ways to configure replication:
Add slaveof {masterHost} {masterPort} to the configuration file.
Add-- slaveof {masterHost} {masterPort} after the redis-server startup command
Use the command directly: slaveof {masterHost} {masterPort}
Let's enable two ports to demonstrate the functionality of Redis replication.
The slaveof configuration is initiated from the slave node, so after the command execution in the above figure is completed, 6379 will be used as the master node and 6380 as the slave node. As shown in the above figure, when I perform the set operation in the 6379 master node, I have successfully obtained the value in the 6380 slave node, indicating that the replication function of Redis has been successful.
The slaveof command is an asynchronous command, when the slaveof command is executed, the node only saves the information of the master node and returns after dinner, and the subsequent replication operations are executed asynchronously within the node. When the master-slave node replication function is established successfully, you can use the info repliication command to view the replication-related status. The specific operation is shown in the figure:
Disconnect replication
The slaveof command can not only establish replication, but also slaveof no one the slave node to break the replication relationship with the master node. There are two main processes for disconnecting replication:
Break the replication relationship with the primary node
From the node to the primary node.
Note: disconnecting replication from the node does not erase the original data, but cannot continue to obtain data from the primary node. You can also cut the main operation through the slaveof command. Then, as the name implies, the master operation is to replace the master node from the slave node. Execute the command slaveof {newMasterIp} {newMasterPort} in Redis to complete the main operation. The main process of cutting the main operation is as follows:
Break the replication relationship with the old master node
Establish a replication relationship with the new node
Delete all current data from the slave node
Copy the new primary node
Note: it is precisely because the cut master operation will erase all the data from the slave node, so you should pay special attention when performing the cut master operation in the production environment.
The following figure shows the detailed flow of disconnecting replication and cutting master operations:
The following figure illustrates the specific operation of disconnecting replication:
The following figure shows the specific operation of the main operation:
This is the end of the content of "how to configure replication for Redis nodes". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.