In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Introduction to redis
Redis is a key-value storage system. Similar to Memcached, it supports relatively more value types, including string (string), list (linked list), set (collection), zset (sorted set-ordered collection), and hash (hash type). These data types support push/pop, add/remove, and take intersection union and difference sets, and richer operations, and these operations are atomic. On this basis, redis supports a variety of different sorting methods. Like memcached, data is cached in memory for efficiency. The difference is that redis will periodically write updated data to disk or modify operations to additional record files, and on this basis to achieve master-slave (master-slave) synchronization.
Case environment host IP address role Centos7192.168.71.134redis-masterCentos7192.168.71.129redis-slave building process
1. Master-slave installation of redis
[root@localhost ~] # yum install epel-release-y
[root@localhost ~] # yum install redis-y
2. The master server modifies the configuration file
[root@localhost ~] # vim / etc/redis.confbind 0.0.0.0 # listens on any port
3. Modify the configuration file from the server
[root@localhost ~] # vim / etc/redis.confbind 0.0.0.0 # listen on any port # slaveof slaveof 192.168.71.128 6379 # points to the ip and port of the master server
4. Enable the service from the master / slave server
[root@localhost ~] # systemctl start redis
5. Verify synchronization function (remember to turn off the firewall)
Log in and write content on the main server
[root@localhost] # redis-cli-h 192.168.71.134-p 6379
192.168.71.134 6379 > set abc 111
OK
192.168.71.134purl 6379 > get abc
"111"
Log in from the server to view the content
[root@localhost] # redis-cli-h 192.168.71.129-p 6379
192.168.71.129purl 6379 > get abc
"111"
At this point, the synchronization function is complete, and then the master-slave function is built.
6. Master-slave settings of master server
[root@localhost ~] # vim / etc/redis-sentinel.conf
17-line protected-mode no
69 line sentinel monitor mymaster 192.168.71.134 6379 1 # master address, port, slave server 1
98 line sentinel down-after-milliseconds mymaster 300 # set the switching time
7. Start the service (you don't need to make any configuration from the server, just start the service)
[root@localhost ~] # systemctl start redis-sentinel.service
8. Check the master-slave status on the master server
[root@localhost] # redis-cli-h 192.168.71.134-p 26379 info sentinel
9. Disable a redis and check the master-slave status again.
[root@localhost ~] # systemctl stop redis
10. When the service is enabled again, master will not return to the master service, and the slave server can be disabled again.
Root@localhost ~] # systemctl stop redis # Slave server downtime redis [root@localhost ~] # systemctl start redis # Master server opens redis [root@localhost ~] # redis-cli-h 192.168.71.134-p 26379 info sentinel# Sentinelsentinel_masters:1sentinel_tilt:0sentinel_running_scripts:0sentinel_scripts_queue_length:0sentinel_simulate_failure_flags:0master0:name=mymaster,status=ok,address=192.168.71.134:6379,slaves=1,sentinels=3
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.