1.安装redis服务 文中涉及到的软件包加下方微信 免费获取 #mkdir /usr/local/redis/data –p

#mkdir /usr/local/redis/log -p

#cd /usr/local/src

#tar -zxf redis-3.0.6.tar.gz

#cd redis-2.8.9

#make && make install

2.复制配置文件 #cp redis.conf /usr/local/bin/

#cd /usr/local/bin

#cp redis.conf redis-slave1

#cp redis.conf redis-slave2

3.修改配置文件 #vi redis.conf

daemonize yes //开启后台运行模式

pidfile /var/run/redis.pid

logfile "/usr/local/redis/log/redis-log"

bind 192.168.0.156

dbfilenamedump.rdb

dir /usr/local/redis/data

port 6379

#vi redis-slave1

daemonize yes

pidfile /var/run/redis-slave1.pid

logfile "/usr/local/redis/log/redis-slave-log"

port 63791

bind 192.168.0.156

dbfilename dump-slave1.rdb

dir /usr/local/redis/data

slaveof 192.168.0.156 6379

slave-read-only yes

#vi redis-slave2

daemonize yes

pidfile /var/run/redis-slave2.pid

logfile "/usr/local/redis/log/redis-slave2-log"

port 63792

bind 192.168.0.156

dbfilename dump-slave2.rdb

dir /usr/local/redis/data

slaveof 192.168.0.156 6379

4.配置redis-sentinel服务 cp /usr/local/src/redis-3.0.6/src/redis-sentinel /usr/bin/

cp /usr/local/src/redis-3.0.6/sentinel.conf /usr/local/bin/

cd /usr/local/bin

5.修改配置文件 #egrep -v "^#|^$" sentinel.conf port 26379 daemonize yes dir /tmp logfile "/usr/local/redis/log/sentinel.log" sentinel monitor mymaster 192.168.0.156 6379 2 sentinel down-after-milliseconds mymaster 30000 sentinel parallel-syncs mymaster 1 sentinel failover-timeout mymaster 180000 6.启动服务 6.1.启动redis服务 [root@master bin]# redis-server redis.conf

[root@master bin]# redis-server redis-slave1

[root@master bin]# redis-server redis-slave2

[root@master bin]# ps -ef|grepredis

root 2579 1 023:55 ? 00:00:00 redis-server 10.0.0.3:6379

root 2585 1 023:55 ? 00:00:00 redis-server 10.0.0.3:63792

root 2590 1 0 23:55? 00:00:00 redis-server 10.0.0.3:63791

6.3.启动redis-sentinel服务 [root@master bin]# redis-sentinel sentinel.conf

[root@master bin]# ps -ef|grepredis-sentinel

root 2638 1 0 01:05? 00:00:04 redis-sentinel*:26379

查看配置文件是否有变化

如果对此有兴趣,请扫下面二维码免费获取更多详情