问题1:
[root@m02 redis_cluster]# redis-cli
-bash: redis-cli: command not found
解决方法:
[root@m02 redis_cluster]# cd redis
[root@m02 redis]# make install
问题2:
[root@m02 ~]# redis-cli -h db02
Could not connect to Redis at db02:6379: Name or service not known
Could not connect to Redis at db02:6379: Name or service not known
not connected>
解决方法
[root@m02 ~]# vim /etc/hosts
10.0.0.52 db02
问题3:
主从复制后没有数据
db02:6379> keys *
(empty list or set)
db02:6379>
查看原因
[root@m02 ~]# tail -f /opt/redis_cluster/redis_6379/logs/redis_6379.log
1831:S 19 Apr 12:13:26.003 * MASTER <-> SLAVE sync started
1831:S 19 Apr 12:13:28.510 # Error condition on socket for SYNC: No route to host
解决办法
[root@m02 ~]# vim /etc/hosts
#添加主库对应的ip地址和主机名:
10.0.0.51 db01
问题4:
[root@db01 ~]# for i in $(seq 1 1000);do redis-cli -c -h db01 -p 6379 set lbz_${i} v_${i} && echo "set k_${i} is ok";done
(error) READONLY You can't write against a read only slave.
报错原因:
因为连接的是从节点,从节点只有读的权限,没有写的权限
解决办法:
[root@db01 ~]# vim /opt/redis_cluster/redis_6379/conf/redis_6379.conf
删除这一行:
slaveof 10.0.0.53 6379