文章目录
1、新建三个redis配置文件,用于定义每个服务的专属配置

[root@localhost ~]
[root@localhost redis-7.0.10]
-rw-rw-r--. 1 root root 106545 3月 21 2023 redis.conf
[root@localhost redis-7.0.10]
1.1、复制文件redis.conf到redis安装目录下

[root@localhost redis-7.0.10]
[root@localhost redis-7.0.10]
[root@localhost redis]
总用量 220
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 106545 6月 24 11:20 redis_common.conf
-rw-r--r--. 1 root root 106546 12月 6 2023 redis.conf
[root@localhost redis]
1.2、关闭redis_common.conf中的 aof 功能
[root@localhost redis]
/appendonly


1.1.1、新建 redis_6379.conf
[root@localhost redis]

include /usr/local/redis/redis_common.conf
pidfile /var/run/redis_6379.pid
port 6379
dbfilename dump6379.rdb
1.1.2、新建 redis_6380.conf
[root@localhost redis]
[root@localhost redis]

[root@localhost redis]

include /usr/local/redis/redis_common.conf
pidfile /var/run/redis_6380.pid
port 6380
dbfilename dump6380.rdb
1.1.3、新建 redis_6381.conf
[root@localhost redis]
[root@localhost redis]

[root@localhost redis]

include /usr/local/redis/redis_common.conf
pidfile /var/run/redis_6381.pid
port 6381
dbfilename dump6381.rdb
2、启动三个服务器
2.1、后台启动redis
[root@localhost redis]
2.2、启动 redis_6379.conf 服务
[root@localhost redis]
[root@localhost redis]
root 5936 1 0 13:07 ? 00:00:00 /usr/local/redis/bin/redis-server 127.0.0.1:6379
root 5950 2374 0 13:07 pts/0 00:00:00 grep --color=auto redis
2.3、启动 redis_6380.conf 服务
[root@localhost redis]
[root@localhost redis]
root 5936 1 0 13:07 ? 00:00:00 /usr/local/redis/bin/redis-server 127.0.0.1:6379
root 5963 1 0 13:09 ? 00:00:00 /usr/local/redis/bin/redis-server 127.0.0.1:6380
root 5969 2374 0 13:09 pts/0 00:00:00 grep --color=auto redis
[root@localhost redis]
2.4、启动 redis_6381.conf 服务
[root@localhost redis]
[root@localhost redis]
root 5936 1 0 13:07 ? 00:00:00 /usr/local/redis/bin/redis-server 127.0.0.1:6379
root 5963 1 0 13:09 ? 00:00:00 /usr/local/redis/bin/redis-server 127.0.0.1:6380
root 5979 1 0 13:09 ? 00:00:00 /usr/local/redis/bin/redis-server 127.0.0.1:6381
root 5985 2374 0 13:09 pts/0 00:00:00 grep --color=auto redis
[root@localhost redis]
2.5、查看 redis 进程服务
[root@localhost redis]
root 5936 1 0 13:07 ? 00:00:00 /usr/local/redis/bin/redis-server 127.0.0.1:6379
root 5963 1 0 13:09 ? 00:00:00 /usr/local/redis/bin/redis-server 127.0.0.1:6380
root 5979 1 0 13:09 ? 00:00:00 /usr/local/redis/bin/redis-server 127.0.0.1:6381
3、使用info replication查看主从相关信息
3.1、查看redis6379的主从信息
[root@localhost redis]
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> info replication
role:master
connected_slaves:0
master_failover_state:no-failover
master_replid:1109fe6a469bbd0ab301ab41951d49d2d4c47b6f
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
127.0.0.1:6379>
3.2、查看redis6380的主从信息
[root@localhost ~]
127.0.0.1:6380> ping
PONG
127.0.0.1:6380> info replication
role:master
connected_slaves:0
master_failover_state:no-failover
master_replid:4404d2727adac2159e33fa9ae736e6ae1882bcdc
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
127.0.0.1:6380>
3.3、查看redis6381的主从信息
[root@localhost ~]
127.0.0.1:6381> ping
PONG
127.0.0.1:6381> info replication
role:master
connected_slaves:0
master_failover_state:no-failover
master_replid:3dd81759608607cb84208e53b21b30f349f7c63a
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
127.0.0.1:6381>
