在redis安装目录下新建文件夹
cd redis-stable
mkdir redis-cluster
[root@zx redis-stable]# cp redis.conf redis-cluster/6379.conf
[root@zx redis-stable]# cp redis.conf redis-cluster/6380.conf
[root@zx redis-stable]# cp redis.conf redis-cluster/6381.conf
cd redis-cluster
vim 6380.conf
vim 6381.conf
从服务修改,主服务不变
port 6380
protected-mode no
daemonize yes
pidfile /var/run/redis_6380.pid
logfile “./redis6380.log”
slaveof 127.0.0.1 6379
#redis密码,关联到哨兵的配置
masterauth redis
[root@zx redis-stable]# cp sentinel.conf redis-cluster/26379.conf
[root@zx redis-stable]# cp sentinel.conf redis-cluster/26380.conf
[root@zx redis-stable]# cp sentinel.conf redis-cluster/26381.conf
修改哨兵配置,注意顺序,缺一不可
port 26380
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel auth-pass mymaster redis
启动
cd redis-stable/src
redis-server /root/redis-stable/redis-cluster/6379.conf
redis-server /root/redis-stable/redis-cluster/6380.conf
redis-server /root/redis-stable/redis-cluster/6381.conf
redis-sentinel /root/redis-stable/redis-cluster/26379.conf
redis-sentinel /root/redis-stable/redis-cluster/26380.conf
redis-sentinel /root/redis-stable/redis-cluster/26381.conf
查看
ps -ef | grep redis
使用客户端查看
redis-cli -p 6379
auth redis
info replication