Windows Docker环境下配置Redis replica 主从复制的相关问题
问题1:overcommit_memory is set to 0
问题详情
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.
解决方案
在%UserProfile%即 C:/User/用户名下创建.wslconfig文件,并键入以下内容
[wsl2]
kernelCommandLine = "sysctl.vm.overcommit_memory=1"
后重启wsl
问题2: slave出现 Failed trying to load the MASTER synchronization DB from disk: No such file or directory 并无法完成主从复制
Failed trying to load the MASTER synchronization DB from disk: No such file or directory
解决方案1.
官方配置中redis.conf中
# -----------------------------------------------------------------------------
#
# Replica can load the RDB it reads from the replication link directly from the
# socket, or store the RDB to a file and read that file after it was completely
# received from the master.
#
# In many cases the disk is slower than the network, and storing and loading
# the RDB file may increase replication time (and even increase the master's
# Copy on Write memory and replica buffers).
# However, parsing the RDB file directly from the socket may mean that we have
# to flush the contents of the current database before the full rdb was
# received. For this reason we have the following options:
#
# "disabled" - Don't use diskless load (store the rdb file to the disk first)
# "on-empty-db" - Use diskless load only when it is completely safe.
# "swapdb" - Keep current db contents in RAM while parsing the data directly
# from the socket. Replicas in this mode can keep serving current
# data set while replication is in progress, except for cases where
# they can't recognize master as having a data set from same
# replication history.
# Note that this requires sufficient memory, if you don't have it,
# you risk an OOM kill.
repl-diskless-load disabled
将主从服务器的所有上方属性设置为on-empty-db即可
解决方案2:
去除slave服务器中/data目录在本地的映射

浙公网安备 33010602011771号