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 > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article shows you how the Redis 4.0 master-slave replication configuration is, concise and easy to understand, absolutely can make your eyes shine, through the detailed introduction of this article I hope you can gain something.
Master: 192.168.174.201
Slave: 192.168.174.202
Install Redis on both servers,
http://blog.itpub.net/26506993/viewspace-2146826/
On the master node, edit the configuration file
[root@MySQL01 redis-4.0.2]# vim redis.conf
#Specify port
port 6379
#Configure Password
requirepass abc
#Listen to all connections from the network
# bind 127.0.0.1
On the slave node, edit the configuration file
[root@localhost redis-4.0.2]# vim redis.conf
#Configure IP and port of master node
slaveof 192.168.174.201 6379
#Configure the password used to connect to the main library
masterauth abc
#Configure Password
requirepass abc
#Listen to all connections from the network
# bind 127.0.0.1
#Specify port
port 6380
On the master node, start redis
[root@MySQL01 redis-4.0.2]# src/redis-server redis.conf
51173:C 04 Nov 07:12:09.019 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
51173:C 04 Nov 07:12:09.019 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=51173, just started
51173:C 04 Nov 07:12:09.019 # Configuration loaded
On the slave node, start redis
[root@localhost redis-4.0.2]# src/redis-server /opt/redis-4.0.2/redis.conf
61391:C 04 Nov 07:14:10.695 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
61391:C 04 Nov 07:14:10.695 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=61391, just started
61391:C 04 Nov 07:14:10.695 # Configuration loaded
verify that replication
Insert linked list data above the master node
[root@MySQL01 redis-4.0.2]# src/redis-cli -a abc
127.0.0.1:6379> rpush list-key item1
(integer) 1
127.0.0.1:6379> rpush list-key item2
(integer) 2
127.0.0.1:6379> rpush list-key item3
(integer) 3
127.0.0.1:6379> lrange list-key 0 -1
1) "item1"
2) "item2"
3) "item3"
view the replication status
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:1
slave0:ip=192.168.174.202,port=6380,state=online,offset=1785,lag=0
master_replid:17cc14861639f71ed1f82ce9999f22ff337014e4
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:1785
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:1785
View linked list data from above node
[root@localhost redis-4.0.2]# src/redis-cli -h 192.168.174.202 -p 6380 -a abc
192.168.174.202:6380> lrange list-key 0 -1
1) "item1"
2) "item2"
3) "item3"
view the replication status
192.168.174.202:6380> info replication
# Replication
role:slave
master_host:192.168.174.201
master_port:6379
master_link_status:up
master_last_io_seconds_ago:6
master_sync_in_progress:0
slave_repl_offset:1771
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:17cc14861639f71ed1f82ce9999f22ff337014e4
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:1771
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:1771
So that's what Redis 4.0 looks like with master-slave replication. Have you learned anything? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.
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.