Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
redis slave赢了';无法与主机同步_Redis_Replication - Fatal编程技术网

redis slave赢了';无法与主机同步

redis slave赢了';无法与主机同步,redis,replication,Redis,Replication,redis从站将不会与主站同步 连通性: 我可以在发布时连接到主机 HOST_NAME=fakehost redis-cli -h $HOST_NAME 并使用类似于INFO的命令检查主机状态,因此连接不是问题 设置: 我从奴隶箱里发出 SLAVEOF $HOST_NAME 6379 并收到一个OK 当我在从机上发出INFO命令时,我得到 # Replication role:slave master_host:<removed> master_port:6379 master_

redis从站将不会与主站同步

连通性: 我可以在发布时连接到主机

HOST_NAME=fakehost
redis-cli -h $HOST_NAME
并使用类似于
INFO
的命令检查主机状态,因此连接不是问题

设置: 我从奴隶箱里发出

SLAVEOF $HOST_NAME 6379
并收到一个
OK

当我在从机上发出
INFO
命令时,我得到

# Replication
role:slave
master_host:<removed>
master_port:6379
master_link_status:down
master_last_io_seconds_ago:-1
master_sync_in_progress:0
master_link_down_since_seconds:1379450797
slave_priority:100
slave_read_only:1
connected_slaves:0
所以很明显我没有联系

日志 测试是否在保存时创建dump.rdb

SAVE
> OK

提前谢谢。

我今天遇到了类似的情况。对于使用sysctl的系统,您可能需要执行以下操作:

sysctl vm.overcommit_memory=1

然后重新启动从redis服务器。可能会有帮助。

这个问题有点棘手

从机无法同步的原因在于主机本身

注意日志输出: 主机复制中止,出现错误:ERR无法执行后台保存

这意味着主机无法进行后台保存,因为主机上的内存储备不足

为了解决这个问题,我重新启动了主redis服务器,
然后,所有从机都已自行同步。

我遇到了相同的问题,我的原因是我的两台服务器没有使用相同的
redis版本。让我们检查两台服务器上的版本:

127.0.0.1:6379> info server
# Server
redis_version:3.2.8

在我的例子中,它与SELINUX有关,将其更改为许可模式解决了问题。

对我来说,这是因为我设置了
requirepass
,但没有设置
masterauth
设置。

我在redis.conf中的默认设置启用了requirepass,在“SLAVEOF”之前在从机终端中执行“masterauth[passwordOfMaster]”将解决此问题。

我通过以下方式解决了此问题:

sudo -i
service redis-server stop
apt remove --purge redis-server
rm /var/lib/redis/dump.rdb
apt install redis-server
systemctl enable redis-server
service redis-server start

# i have not tried, but it is possible this is enough
service redis-server stop
rm /var/lib/redis/dump.rdb
service redis-server start

当我尝试使用Redis 5.0.5设置时,我发现保护模式已打开。当我登录到假定主机的eth0接口(与环回或UNIX套接字相反)时,我在尝试运行“INFO”时收到了以下消息:

我按照说明操作,从机立即连接。

可能的修复方法:

确保所有服务器(主/从服务器)上的masterauthrequirepass值相同

注意:masterauth值基本上是向主机请求身份验证密码,用于尝试连接的从机,因此与主机本身不完全相关,但在尝试与主机同步时与从机相关。这就是requirepass(您在主计算机上的redis配置中设置的)的用途-即,您在主计算机上为requirepass设置的值,与您需要在redis配置从计算机上的masterauth参数前面输入的值相同。最好在主机上也这样做,以避免进一步混淆(尽管这与主机无关)

您可以查看其中一个从机redis日志文件的更多线索:


Linux命令:tail-f path to redis.log

工作目录设置为什么,用户是否具有写入权限?是的,它具有写入权限。当我执行保存或启动/停止时,它将写入
dump.rdb
。为我工作,我运行了redis cli shutdown save,它在保存所有密钥时重新启动了redis,并在几秒钟内同步了从机。要100%清除,要发出的命令是
config set masterauth[passwordOfMaster]
修复SELinux问题比禁用它更好。清理dump.rdb也修复了我的同步问题。谢谢你的建议。
sysctl vm.overcommit_memory=1
127.0.0.1:6379> info server
# Server
redis_version:3.2.8
sudo -i
service redis-server stop
apt remove --purge redis-server
rm /var/lib/redis/dump.rdb
apt install redis-server
systemctl enable redis-server
service redis-server start

# i have not tried, but it is possible this is enough
service redis-server stop
rm /var/lib/redis/dump.rdb
service redis-server start
IP_ADDRESS_REDACTED:6379> info
DENIED Redis is running in protected mode because protected mode is
enabled, no bind address was specified, no authentication password
is requested to clients. In this mode connections are only accepted
from the loopback interface. If you want to connect from external
computers to Redis you may adopt one of the following solutions:
1) Just disable protected mode sending the command 'CONFIG SET 
protected-mode no' from the loopback interface by connecting to Redis
from the same host the server is running, however MAKE SURE Redis is
not publicly accessible from internet if you do so. Use CONFIG REWRITE 
to make this change permanent. 2) Alternatively you can just disable
the protected mode by editing the Redis configuration file, and
setting the protected mode option to 'no', and then restarting the
server. 3) If you started the server manually just for testing,
restart it with the '--protected-mode no' option. 4) Setup a bind
address or an authentication password. NOTE: You only need to do one
of the above things in order for the server to start accepting
connections from the outside.