redis主从配置

  • 将上一文章安装好的redis环境复制一份做为slave,注意从新生成mac地址 不然没法链接网络。

  • 查看系统ip并记录,个人文
redis-master 192.168.129.135
redis-slave1 192.168.129.136
  • 打开slave1服务器的redis配置文件redis.conf,修改端口为6380,并制定master的ip和端口
# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
port 6380
slaveof 192.168.129.135 6379

# TCP listen() backlog.
  • 从新起到从redis服务,启动完成后可在master和slave分别执行info查看结果

master_link_status:up表示链接上,不然为down。redis

  • 测试,在master上set值,slave上查看

  • 安装中遇到的问题记录

1.master上set操做时报错或slave启动报错服务器

5053:S 10 Mar 21:03:19.834 * Connecting to MASTER 192.168.129.135:6379
5053:S 10 Mar 21:03:19.835 * MASTER <-> SLAVE sync started
5053:S 10 Mar 21:03:19.835 * Non blocking connect for SYNC fired the event.
5053:S 10 Mar 21:03:19.835 # Error reply to PING from master: '-MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.'

解决方法:在master上执行config set stop-writes-on-bgsave-error no网络

2.redis启动时报错socket

5053:S 10 Mar 21:12:38.167 * Connecting to MASTER 192.168.129.135:6379
5053:S 10 Mar 21:12:38.167 * MASTER <-> SLAVE sync started
5053:S 10 Mar 21:12:38.167 * Non blocking connect for SYNC fired the event.
5053:S 10 Mar 21:12:38.168 * Master replied to PING, replication can continue...
5053:S 10 Mar 21:12:38.168 * Partial resynchronization not possible (no cached master)
5053:S 10 Mar 21:12:38.168 * Full resync from master: e606a708c45e5fe0ce87c0d11ec246186fa8d668:1158
5053:S 10 Mar 21:12:43.171 # Opening the temp file needed for MASTER <-> SLAVE synchronization: Permission denied

解决方法:缘由是启动的当前用户对如下配置中的路径无写权限测试

redis.conf中code

3.redis启动报错ip

5135:S 10 Mar 21:28:25.447 * Connecting to MASTER 192.168.129.135:6379
5135:S 10 Mar 21:28:25.448 * MASTER <-> SLAVE sync started
5135:S 10 Mar 21:28:25.448 * Non blocking connect for SYNC fired the event.
5135:S 10 Mar 21:28:25.448 * Master replied to PING, replication can continue...
5135:S 10 Mar 21:28:25.448 * Partial resynchronization not possible (no cached master)
5135:S 10 Mar 21:28:25.448 * Full resync from master: e606a708c45e5fe0ce87c0d11ec246186fa8d668:2460
5135:S 10 Mar 21:28:25.541 # I/O error reading bulk count from MASTER: Resource temporarily unavailable

解决办法:缘由是主从服务之间没法通信,可以使用telnet进行测试。ci

相关文章
相关标签/搜索