解决问题
1.数据安全问题
2.高并发读问题
1.主节点和
redis-单节点安装一致
2.从节点
daemonize yes
port 6379
bind 0.0.0.0
requirepass 123456
save 3600 1 300 100 60 10000dir /usr/local/redis
dbfilename dump.rdb
logfile redis.log
pidfile redis.pidreplicaof 172.22.46.31 6379
masterauth 123456
多了replicaof和masterauth(主节点的ip和密码)
3.测试
[root@sq2355-20220517--1 bin]# ./redis-cli
127.0.0.1:6379> Auth 123456
OK
127.0.0.1:6379> INFO replication
# Replication
role:master
connected_slaves:1
slave0:ip=172.22.46.32,port=6379,state=online,offset=42,lag=1
master_replid:c7784001d154e776ea9da966b5954a6a9918a67d
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:42
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:42
127.0.0.1:6379> INFO replication
# Replication
role:master
connected_slaves:2
slave0:ip=172.22.46.32,port=6379,state=online,offset=98,lag=0
slave1:ip=172.22.46.34,port=6379,state=online,offset=98,lag=0
master_replid:c7784001d154e776ea9da966b5954a6a9918a67d
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:98
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:98
使用role命令也可以查看当前服务器信息
127.0.0.1:6379> role
1) "master"
2) (integer) 182
3) 1) 1) "172.22.46.32"2) "6379"3) "182"2) 1) "172.22.46.34"2) "6379"3) "182"
子节点不允许写入数据
CONFIG GET replica-read-only
主节点写入,查看是否同步
子节点同步成功