码迷,mamicode.com
首页 > 系统相关 > 详细

Linux/Centos Redis集群安装

时间:2018-06-12 13:37:05      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:Redis   Linux   Centos   系统   运维   

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

查看配置文件是否有变化
技术分享图片

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

技术分享图片

Linux/Centos Redis集群安装

标签:Redis   Linux   Centos   系统   运维   

原文地址:http://blog.51cto.com/11233498/2128398

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!