8.5 Redis集群之检查命令和日志分析

1.检查命令

cd /usr/local/redis/src
redis-cli  -a admin123 --cluster check 121.4.211.73:6371

在这里插入图片描述
如图所示,主节点6375有1个key,5461个solts(范围为10923-16383)和1个从节点。

2.查看主从日志

cd /usr/local/redis/cluster/log
cat redis-6371.log
#主节点6371
21453:C 01 Feb 2023 12:36:48.770 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
21453:C 01 Feb 2023 12:36:48.770 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=21453, just started
21453:C 01 Feb 2023 12:36:48.770 # Configuration loaded
21453:M 01 Feb 2023 12:36:48.771 * monotonic clock: POSIX clock_gettime
#当前节点id
21453:M 01 Feb 2023 12:36:48.771 * No cluster configuration found, I'm bac73b1e1a8315a3591991eebfcb728d09ab2ebe
#集群模式运行,端口号为6371
21453:M 01 Feb 2023 12:36:48.775 * Running mode=cluster, port=6371.
21453:M 01 Feb 2023 12:36:48.775 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
#服务初始化
21453:M 01 Feb 2023 12:36:48.775 # Server initialized
21453:M 01 Feb 2023 12:36:48.775 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
21453:M 01 Feb 2023 12:36:48.776 * Ready to accept connections
21453:M 01 Feb 2023 13:01:43.093 # configEpoch set to 1 via CLUSTER SET-CONFIG-EPOCH
#从节点6374请求复制
21453:M 01 Feb 2023 13:01:45.101 * Replica 121.4.191.124:6374 asks for synchronization
21453:M 01 Feb 2023 13:01:45.101 * Partial resynchronization not accepted: Replication ID mismatch (Replica asked for '81acc08f6d738ec135b98c5f33e5fc13bba4bf55', my replication IDs are '2ab52423e7a9cc2698b7b2f53bd48a19b2b4e69d' and '0000000000000000000000000000000000000000')
21453:M 01 Feb 2023 13:01:45.101 * Replication backlog created, my new replication IDs are '80e59178579b00a78e9d399c061f36d2442b9f36' and '0000000000000000000000000000000000000000'
#通过BGSAVE将数据写入磁盘
21453:M 01 Feb 2023 13:01:45.101 * Starting BGSAVE for SYNC with target: disk
#开启一个后台线程
21453:M 01 Feb 2023 13:01:45.101 * Background saving started by pid 28109
28109:C 01 Feb 2023 13:01:45.104 * DB saved on disk
#还没有数据,所以是0M写入
28109:C 01 Feb 2023 13:01:45.105 * RDB: 0 MB of memory used by copy-on-write
21453:M 01 Feb 2023 13:01:45.127 * Background saving terminated with success
21453:M 01 Feb 2023 13:01:45.127 * Synchronization with replica 121.4.191.124:6374 succeeded
21453:M 01 Feb 2023 13:01:48.036 # Cluster state changed: ok
#6371的从节点6374
9051:C 01 Feb 2023 12:50:46.024 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
9051:C 01 Feb 2023 12:50:46.024 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=9051, just started
9051:C 01 Feb 2023 12:50:46.024 # Configuration loaded
9051:M 01 Feb 2023 12:50:46.025 * monotonic clock: POSIX clock_gettime
9051:M 01 Feb 2023 12:50:46.025 * No cluster configuration found, I'm 95381e925e3e740673928bda89a1f2dad2c4e75e
9051:M 01 Feb 2023 12:50:46.029 * Running mode=cluster, port=6374.
9051:M 01 Feb 2023 12:50:46.030 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
9051:M 01 Feb 2023 12:50:46.030 # Server initialized
9051:M 01 Feb 2023 12:50:46.030 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
9051:M 01 Feb 2023 12:50:46.030 * Ready to accept connections
9051:M 01 Feb 2023 13:01:43.094 # configEpoch set to 4 via CLUSTER SET-CONFIG-EPOCH
#变为从节点前的准备工作
9051:S 01 Feb 2023 13:01:45.100 * Before turning into a replica, using my own master parameters to synthesize a cached master: I may be able to synchronize with the new master with just a partial transfer.
#连接到主节点6371
9051:S 01 Feb 2023 13:01:45.100 * Connecting to MASTER 121.4.211.73:6371
9051:S 01 Feb 2023 13:01:45.100 * MASTER <-> REPLICA sync started
9051:S 01 Feb 2023 13:01:45.100 # Cluster state changed: ok
9051:S 01 Feb 2023 13:01:45.100 * Non blocking connect for SYNC fired the event.
#主节点回复了从节点,开始复制
9051:S 01 Feb 2023 13:01:45.100 * Master replied to PING, replication can continue...
9051:S 01 Feb 2023 13:01:45.101 * Trying a partial resynchronization (request 81acc08f6d738ec135b98c5f33e5fc13bba4bf55:1).
9051:S 01 Feb 2023 13:01:45.102 * Full resync from master: 80e59178579b00a78e9d399c061f36d2442b9f36:0
#抛弃之前缓存的数据
9051:S 01 Feb 2023 13:01:45.102 * Discarding previously cached master state.
9051:S 01 Feb 2023 13:01:45.128 * MASTER <-> REPLICA sync: receiving 175 bytes from master to disk
9051:S 01 Feb 2023 13:01:45.128 * MASTER <-> REPLICA sync: Flushing old data
9051:S 01 Feb 2023 13:01:45.128 * MASTER <-> REPLICA sync: Loading DB in memory
9051:S 01 Feb 2023 13:01:45.132 * Loading RDB produced by version 6.2.6
9051:S 01 Feb 2023 13:01:45.132 * RDB age 0 seconds
9051:S 01 Feb 2023 13:01:45.132 * RDB memory usage when created 2.59 Mb
9051:S 01 Feb 2023 13:01:45.132 # Done loading RDB, keys loaded: 0, keys expired: 0.
#主从复制顺利完成
9051:S 01 Feb 2023 13:01:45.132 * MASTER <-> REPLICA sync: Finished with success
#后台开启一个进程,进行AOF写入
9051:S 01 Feb 2023 13:01:45.132 * Background append only file rewriting started by pid 10585
9051:S 01 Feb 2023 13:01:45.156 * AOF rewrite child asks to stop sending diffs.
10585:C 01 Feb 2023 13:01:45.157 * Parent agreed to stop sending diffs. Finalizing AOF...
10585:C 01 Feb 2023 13:01:45.157 * Concatenating 0.00 MB of AOF diff received from parent.
10585:C 01 Feb 2023 13:01:45.157 * SYNC append only file rewrite performed
10585:C 01 Feb 2023 13:01:45.157 * AOF rewrite: 0 MB of memory used by copy-on-write
9051:S 01 Feb 2023 13:01:45.221 * Background AOF rewrite terminated with success
9051:S 01 Feb 2023 13:01:45.221 * Residual parent diff successfully flushed to the rewritten AOF (0.00 MB)
9051:S 01 Feb 2023 13:01:45.221 * Background AOF rewrite finished successfully
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值