Skip to content

Commit c500c79

Browse files
committed
feat: cluster
1 parent 381a44e commit c500c79

File tree

2 files changed

+372
-15
lines changed
  • content/post

2 files changed

+372
-15
lines changed

content/post/redis_in_action _error_notes/index.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,85 @@ Can't resolve instance hostname.
2727

2828
# 加上这句解决问题
2929
sentinel resolve-hostnames yes
30+
31+
### 1:M 11 Aug 2024 15:34:39.576 # Unable to obtain the AOF file appendonly-clusterMaster4.aof.3.incr.aof length. stat: No such file or directory
32+
不需要配置了appendfilename appendonly-clusterMaster4.aof
33+
34+
35+
### Failed trying to load the MASTER synchronization DB from disk, check server logs.
36+
37+
根据报错提示,回到主节点可以看到错误日志,可以看到和从节点的连接丢失,没有同步成功。
38+
```log
39+
1:M 12 Aug 2024 15:56:25.216 * Starting BGSAVE for SYNC with target: replicas sockets
40+
1:M 12 Aug 2024 15:56:25.222 * Background RDB transfer started by pid 220
41+
220:C 12 Aug 2024 15:56:25.222 * Fork CoW for RDB: current 0 MB, peak 0 MB, average 0 MB
42+
1:M 12 Aug 2024 15:56:25.225 * Diskless rdb transfer, done reading from pipe, 1 replicas still up.
43+
1:M 12 Aug 2024 15:56:25.231 * Connection with replica 172.17.0.9:16382 lost.
44+
1:M 12 Aug 2024 15:56:25.235 * Replica 172.17.0.9:16382 asks for synchronization
45+
1:M 12 Aug 2024 15:56:25.235 * Full resync requested by replica 172.17.0.9:16382
46+
1:M 12 Aug 2024 15:56:25.236 * Current BGSAVE has socket target. Waiting for next BGSAVE for SYNC
47+
1:M 12 Aug 2024 15:56:25.324 * Background RDB transfer terminated with success
48+
```
49+
50+
修改redis.config中的配置,将主从服务器的属性repl-diskless-load设置为on-empty-db即可
51+
52+
```sh
53+
# Replica can load the RDB it reads from the replication link directly from the
54+
# socket, or store the RDB to a file and read that file after it was completely
55+
# received from the master.
56+
#
57+
# In many cases the disk is slower than the network, and storing and loading
58+
# the RDB file may increase replication time (and even increase the master's
59+
# Copy on Write memory and replica buffers).
60+
# However, parsing the RDB file directly from the socket may mean that we have
61+
# to flush the contents of the current database before the full rdb was
62+
# received. For this reason we have the following options:
63+
#
64+
# "disabled" - Don't use diskless load (store the rdb file to the disk first)
65+
# "on-empty-db" - Use diskless load only when it is completely safe.
66+
# "swapdb" - Keep current db contents in RAM while parsing the data directly
67+
# from the socket. Replicas in this mode can keep serving current
68+
# data set while replication is in progress, except for cases where
69+
# they can't recognize master as having a data set from same
70+
# replication history.
71+
# Note that this requires sufficient memory, if you don't have it,
72+
# you risk an OOM kill.
73+
repl-diskless-load disabled
74+
75+
```
76+
77+
然后重启主从服务器,再次查看主节点日志,发现同步成功
78+
```log
79+
1:C 12 Aug 2024 15:56:32.400 # WARNING: Changing databases number from 16 to 1 since we are in cluster mode
80+
1:C 12 Aug 2024 15:56:32.401 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
81+
1:C 12 Aug 2024 15:56:32.402 * Redis version=7.2.5, bits=64, commit=00000000, modified=0, pid=1, just started
82+
1:C 12 Aug 2024 15:56:32.403 * Configuration loaded
83+
1:M 12 Aug 2024 15:56:32.404 * monotonic clock: POSIX clock_gettime
84+
1:M 12 Aug 2024 15:56:32.405 * Running mode=cluster, port=6382.
85+
1:M 12 Aug 2024 15:56:32.407 * Node configuration loaded, I'm 8ae631285a8532aaeb324b404ab48352a25658ff
86+
1:M 12 Aug 2024 15:56:32.408 * Server initialized
87+
1:M 12 Aug 2024 15:56:32.414 * Reading RDB base file on AOF loading...
88+
1:M 12 Aug 2024 15:56:32.416 * Loading RDB produced by version 7.2.5
89+
1:M 12 Aug 2024 15:56:32.416 * RDB age 961 seconds
90+
1:M 12 Aug 2024 15:56:32.417 * RDB memory usage when created 1.59 Mb
91+
1:M 12 Aug 2024 15:56:32.418 * RDB is base AOF
92+
1:M 12 Aug 2024 15:56:32.419 * Done loading RDB, keys loaded: 0, keys expired: 0.
93+
1:M 12 Aug 2024 15:56:32.420 * DB loaded from base file appendonly-clusterMaster4.2.base.rdb: 0.006 seconds
94+
1:M 12 Aug 2024 15:56:32.422 * DB loaded from incr file appendonly-clusterMaster4.2.incr.aof: 0.001 seconds
95+
1:M 12 Aug 2024 15:56:32.422 * DB loaded from append only file: 0.012 seconds
96+
1:M 12 Aug 2024 15:56:32.424 * Opening AOF incr file appendonly-clusterMaster4.2.incr.aof on server start
97+
1:M 12 Aug 2024 15:56:32.425 * Ready to accept connections tcp
98+
1:M 12 Aug 2024 15:56:33.495 * Replica 172.17.0.9:16382 asks for synchronization
99+
1:M 12 Aug 2024 15:56:33.496 * Partial resynchronization not accepted: Replication ID mismatch (Replica asked for 'a4e7ecbdc1e68bb729f8e293cdd37af350bcc946', my replication IDs are 'a3393f87f433bfd8bc8c205a0911ffa83a72831d' and '0000000000000000000000000000000000000000')
100+
1:M 12 Aug 2024 15:56:33.497 * Replication backlog created, my new replication IDs are '16dd21acae0e5ba18ee4699070c0046ef26ac227' and '0000000000000000000000000000000000000000'
101+
1:M 12 Aug 2024 15:56:33.498 * Delay next BGSAVE for diskless SYNC
102+
1:M 12 Aug 2024 15:56:34.442 * Cluster state changed: ok
103+
1:M 12 Aug 2024 15:56:38.373 * Starting BGSAVE for SYNC with target: replicas sockets
104+
1:M 12 Aug 2024 15:56:38.375 * Background RDB transfer started by pid 20
105+
20:C 12 Aug 2024 15:56:38.375 * Fork CoW for RDB: current 0 MB, peak 0 MB, average 0 MB
106+
1:M 12 Aug 2024 15:56:38.376 * Diskless rdb transfer, done reading from pipe, 1 replicas still up.
107+
1:M 12 Aug 2024 15:56:38.388 * Background RDB transfer terminated with success
108+
1:M 12 Aug 2024 15:56:38.389 * Streamed RDB transfer with replica 172.17.0.9:16382 succeeded (socket). Waiting for REPLCONF ACK from replica to enable streaming
109+
1:M 12 Aug 2024 15:56:38.390 * Synchronization with replica 172.17.0.9:16382 succeeded
110+
111+
```

0 commit comments

Comments
 (0)