Redis主从集群通过关闭防火墙使得从机得以访问主机实现主从集群关系确立—–Redis

[root@localhost myredis]# redis-server /myredis/redis6379.conf 
[root@localhost myredis]# redis-cli -a abc123
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> keys *
 1) "count"
 2) "list"
 3) "k100"
 4) "key"
 5) "k10000"
 6) "k300"
 7) "k200"
 8) "user:001"
 9) "k2"
10) "balance"
11) "k1"
12) "email"
13) "k3"
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:2
slave0:ip=192.168.92.130,port=6380,state=online,offset=308,lag=1
slave1:ip=192.168.92.131,port=6381,state=online,offset=322,lag=0
master_failover_state:no-failover
master_replid:a5075df9f030230dd8e30b2fb6c917650647850f
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:322
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:322

[root@localhost myredis]# redis-server /myredis/redis6379.conf 
[root@localhost myredis]# redis-cli -a abc123
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> keys *
 1) "count"
 2) "list"
 3) "k100"
 4) "key"
 5) "k10000"
 6) "k300"
 7) "k200"
 8) "user:001"
 9) "k2"
10) "balance"
11) "k1"
12) "email"
13) "k3"
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:2
slave0:ip=192.168.92.130,port=6380,state=online,offset=308,lag=1
slave1:ip=192.168.92.131,port=6381,state=online,offset=322,lag=0
master_failover_state:no-failover
master_replid:a5075df9f030230dd8e30b2fb6c917650647850f
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:322
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:322
 

[root@localhost ~]# cd /myredis
[root@localhost myredis]# ll
总用量 228
-rw-r--r--. 1 root root   1144 1月  20 16:03 6379.log
drwxr-xr-x. 2 root root    132 1月  18 16:33 appendonlydir
-rw-r--r--. 1 root root    111 1月  18 16:48 cmd.txt
-rw-r--r--. 1 root root    313 1月  20 14:43 dump6379.rdb
-rw-r--r--. 1 root root 107540 1月  20 15:38 redis6379.conf
-rw-r--r--. 1 root root 107529 1月  18 16:06 redis.conf
[root@localhost myredis]# vim 6379.log 
[root@localhost myredis]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since 六 2024-01-20 15:02:36 CST; 1h 13min ago
     Docs: man:firewalld(1)
 Main PID: 829 (firewalld)
    Tasks: 2
   CGroup: /system.slice/firewalld.service
           └─829 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

1月 20 15:02:35 localhost.localdomain systemd[1]: Starting firewalld - dynamic f....
1月 20 15:02:36 localhost.localdomain systemd[1]: Started firewalld - dynamic fi....
1月 20 15:02:36 localhost.localdomain firewalld[829]: WARNING: AllowZoneDrifting ...
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost myredis]# systemctl stop firewalld
^[[A[root@localhost myredis]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since 六 2024-01-20 16:16:20 CST; 1s ago
     Docs: man:firewalld(1)
  Process: 829 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 829 (code=exited, status=0/SUCCESS)

1月 20 15:02:35 localhost.localdomain systemd[1]: Starting firewalld - dynamic f....
1月 20 15:02:36 localhost.localdomain systemd[1]: Started firewalld - dynamic fi....
1月 20 15:02:36 localhost.localdomain firewalld[829]: WARNING: AllowZoneDrifting ...
1月 20 16:16:18 localhost.localdomain systemd[1]: Stopping firewalld - dynamic f....
1月 20 16:16:20 localhost.localdomain systemd[1]: Stopped firewalld - dynamic fi....
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost myredis]# vim 6379.log 

[root@localhost ~]# cd /myredis
[root@localhost myredis]# ll
总用量 228
-rw-r--r--. 1 root root   1144 1月  20 16:03 6379.log
drwxr-xr-x. 2 root root    132 1月  18 16:33 appendonlydir
-rw-r--r--. 1 root root    111 1月  18 16:48 cmd.txt
-rw-r--r--. 1 root root    313 1月  20 14:43 dump6379.rdb
-rw-r--r--. 1 root root 107540 1月  20 15:38 redis6379.conf
-rw-r--r--. 1 root root 107529 1月  18 16:06 redis.conf
[root@localhost myredis]# vim 6379.log 
[root@localhost myredis]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since 六 2024-01-20 15:02:36 CST; 1h 13min ago
     Docs: man:firewalld(1)
 Main PID: 829 (firewalld)
    Tasks: 2
   CGroup: /system.slice/firewalld.service
           └─829 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

1月 20 15:02:35 localhost.localdomain systemd[1]: Starting firewalld - dynamic f....
1月 20 15:02:36 localhost.localdomain systemd[1]: Started firewalld - dynamic fi....
1月 20 15:02:36 localhost.localdomain firewalld[829]: WARNING: AllowZoneDrifting ...
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost myredis]# systemctl stop firewalld
^[[A[root@localhost myredis]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since 六 2024-01-20 16:16:20 CST; 1s ago
     Docs: man:firewalld(1)
  Process: 829 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 829 (code=exited, status=0/SUCCESS)

1月 20 15:02:35 localhost.localdomain systemd[1]: Starting firewalld - dynamic f....
1月 20 15:02:36 localhost.localdomain systemd[1]: Started firewalld - dynamic fi....
1月 20 15:02:36 localhost.localdomain firewalld[829]: WARNING: AllowZoneDrifting ...
1月 20 16:16:18 localhost.localdomain systemd[1]: Stopping firewalld - dynamic f....
1月 20 16:16:20 localhost.localdomain systemd[1]: Stopped firewalld - dynamic fi....
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost myredis]# vim 6379.log 
 

[root@localhost myredis]# redis-server /myredis/redis6380.conf 
[root@localhost myredis]# redis-cli -a abc123 -p 6380
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
AUTH failed: ERR AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct?
127.0.0.1:6380> ping
PONG
127.0.0.1:6380> keys *
(empty array)
127.0.0.1:6380> keys *
(empty array)
127.0.0.1:6380> info replication
# Replication
role:slave
master_host:192.168.92.129
master_port:6379
master_link_status:up
master_last_io_seconds_ago:3
master_sync_in_progress:0
slave_read_repl_offset:378
slave_repl_offset:378
slave_priority:100
slave_read_only:1
replica_announced:1
connected_slaves:0
master_failover_state:no-failover
master_replid:a5075df9f030230dd8e30b2fb6c917650647850f
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:378
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:15
repl_backlog_histlen:364

 [root@localhost myredis]# redis-server /myredis/redis6380.conf 
[root@localhost myredis]# redis-cli -a abc123 -p 6380
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
AUTH failed: ERR AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct?
127.0.0.1:6380> ping
PONG
127.0.0.1:6380> keys *
(empty array)
127.0.0.1:6380> keys *
(empty array)
127.0.0.1:6380> info replication
# Replication
role:slave
master_host:192.168.92.129
master_port:6379
master_link_status:up
master_last_io_seconds_ago:3
master_sync_in_progress:0
slave_read_repl_offset:378
slave_repl_offset:378
slave_priority:100
slave_read_only:1
replica_announced:1
connected_slaves:0
master_failover_state:no-failover
master_replid:a5075df9f030230dd8e30b2fb6c917650647850f
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:378
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:15
repl_backlog_histlen:364

[root@localhost myredis]# redis-server /myredis/redis6381.conf 
[root@localhost myredis]# redis-cli -a abc123 -p 6381
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
AUTH failed: ERR AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct?
127.0.0.1:6381> keys *
(empty array)
127.0.0.1:6381> ping
PONG
127.0.0.1:6381> info replication
# Replication
role:slave
master_host:192.168.92.129
master_port:6379
master_link_status:up
master_last_io_seconds_ago:4
master_sync_in_progress:0
slave_read_repl_offset:392
slave_repl_offset:392
slave_priority:100
slave_read_only:1
replica_announced:1
connected_slaves:0
master_failover_state:no-failover
master_replid:a5075df9f030230dd8e30b2fb6c917650647850f
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:392
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:15
repl_backlog_histlen:378

 [root@localhost myredis]# redis-server /myredis/redis6381.conf 
[root@localhost myredis]# redis-cli -a abc123 -p 6381
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
AUTH failed: ERR AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct?
127.0.0.1:6381> keys *
(empty array)
127.0.0.1:6381> ping
PONG
127.0.0.1:6381> info replication
# Replication
role:slave
master_host:192.168.92.129
master_port:6379
master_link_status:up
master_last_io_seconds_ago:4
master_sync_in_progress:0
slave_read_repl_offset:392
slave_repl_offset:392
slave_priority:100
slave_read_only:1
replica_announced:1
connected_slaves:0
master_failover_state:no-failover
master_replid:a5075df9f030230dd8e30b2fb6c917650647850f
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:392
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:15
repl_backlog_histlen:378