In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to configure master-slave clusters in Redis. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
Environmental preparation
Two services, both of which are equipped with redis
Open firewall port 6379 from the server
Implementation steps:
* * step 1: configure slave library * *
Configure the firewall, develop port 6379, open the iptables configuration, and add the following red box
Vim / etc/sysconfig/iptables
Save exit! then restart the firewall
Systemctl restart iptables.service
Open redis.conf from the redis configuration file on the server, and modify the configuration as follows:
Replicaof
The old version of redis has the following parameters:
Slaveof
Where:
Masterip: the IP address of the primary server
Masterport: the port number of the master server redis
Because my primary server ip address is 49.234.24.93 redis port number is 6379, so my configuration is as follows:
If the master server sets the access password, the slave server needs to configure the following parameters:
Masterauth
The password of master-password master server is set here as follows:
The slave database can only be read, not written, (because after the master-slave cluster is configured, the slave database will pull the data from the master database. If the slave database is writable, the written data will be temporary. If there is a key with the same name as the master database when synchronizing the master database data, the slave database will be overwritten.)
The parameters to configure read-only from the library are as follows:
Replica-read-only yes
The default is read-only, and no is writable
Configure 111.231.120.51 from the library to access 111.231.120.51 this ip address is the external ip address of the server where the library redis is located. The purpose of the configuration here is to allow the main library to access him, or to comment out the configuration of bind directly.
Bind 127.0.0.1 111.231.120.51
Step 2: configure the main library:
Turn on the firewall
To set up the redis.conf file, the configuration of the main library is very simple. Just comment out the bind parameter, that is, make it accessible to the outside world.
Step 3: test whether the configuration is successful
Log in to the main library with the user's redis-cli tool and enter the role command to view the role of the current service
Indicates that the configuration is successful. Master indicates that it is currently the master library, and the red box contains the link information of the slave library.
The user redis-cli tool logs in to the slave library and enters the role command to view the current server role
After reading the above, do you have any further understanding of how to configure master-slave clusters in Redis? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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
HandlerInterceptorpublic class HandlerInterceptorDemo implements HandlerInterceptor {@ Override
© 2024 shulou.com SLNews company. All rights reserved.