文章目录 1、修改配置文件中的 bind ,注释该配置,取消绑定仅主机登录 2、修改protected-mode 为no,取消保护模式 3、查看redis的进程状态 4、配置6380是6379的从机 5、配置6381是6379的从机 6、查看主机 6379 的主从信息
1、修改配置文件中的 bind ,注释该配置,取消绑定仅主机登录
[ root@localhost ~]
[ root@localhost redis]
总用量 232
drwxr-xr-x. 2 root root 150 12 月 6 2023 bin
-rw-r--r--. 1 root root 89 12 月 20 2023 dump.rdb
-rw-r--r--. 1 root root 207 6 月 24 12 :33 redis_6379.conf
-rw-r--r--. 1 root root 207 6 月 24 12 :47 redis_6380.conf
-rw-r--r--. 1 root root 207 6 月 24 12 :52 redis_6381.conf
-rw-r--r--. 1 root root 106546 6 月 24 13 :03 redis_common.conf
-rw-r--r--. 1 root root 106546 12 月 6 2023 redis.conf
[ root@localhost redis]
[ root@localhost redis]
2、修改protected-mode 为no,取消保护模式
3、查看redis的进程状态
[ root@localhost redis]
root 6926 1 0 14 :16 ? 00:00:00 /usr/local/redis/bin/redis-server *:6379
root 6965 1 0 14 :19 ? 00:00:00 /usr/local/redis/bin/redis-server *:6380
root 6980 1 0 14 :20 ? 00:00:00 /usr/local/redis/bin/redis-server *:6381
root 6997 6479 0 14 :21 pts/3 00:00:00 grep --color = auto redis
[ root@localhost redis]
变成 * 代表配置修改成功
4、配置6380是6379的从机
[ root@localhost ~]
127.0 .0.1:6380 > ping
PONG
127.0 .0.1:6380 > slaveof 192.168 .74.148 6379
OK
127.0 .0.1:6380 > info replication
role:slave
master_host:192.168.74.148
master_port:6379
master_link_status:up
master_last_io_seconds_ago:6
master_sync_in_progress:0
slave_read_repl_offset:168
slave_repl_offset:168
slave_priority:100
slave_read_only:1
replica_announced:1
connected_slaves:0
master_failover_state:no-failover
master_replid:bad8e16c55e217d4cab9aff4598fd83f84b74336
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:168
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:169
repl_backlog_histlen:0
127.0 .0.1:6380 >
5、配置6381是6379的从机
[ root@localhost ~]
127.0 .0.1:6381 > ping
PONG
127.0 .0.1:6381 > slaveof 192.168 .74.148 6379
OK
127.0 .0.1:6381 > info replication
role:slave
master_host:192.168.74.148
master_port:6379
master_link_status:up
master_last_io_seconds_ago:4
master_sync_in_progress:0
slave_read_repl_offset:294
slave_repl_offset:294
slave_priority:100
slave_read_only:1
replica_announced:1
connected_slaves:0
master_failover_state:no-failover
master_replid:bad8e16c55e217d4cab9aff4598fd83f84b74336
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:294
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:295
repl_backlog_histlen:0
127.0 .0.1:6381 >
6、查看主机 6379 的主从信息
[ root@localhost ~]
127.0 .0.1:6379 > ping
PONG
127.0 .0.1:6379 > info replication
role:master
connected_slaves:2
slave0:ip= 192.168 .74.148,port= 6380 ,state= online,offset= 406 ,lag= 1
slave1:ip= 192.168 .74.148,port= 6381 ,state= online,offset= 406 ,lag= 1
master_failover_state:no-failover
master_replid:bad8e16c55e217d4cab9aff4598fd83f84b74336
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:406
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:406
127.0 .0.1:6379 >