Linux/Centos Redis集群安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux/Centos Redis集群安装相关的知识,希望对你有一定的参考价值。
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服务
[[email protected] bin]# redis-server redis.conf
[[email protected] bin]# redis-server redis-slave1
[[email protected] bin]# redis-server redis-slave2
[[email protected] 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服务
[[email protected] bin]# redis-sentinel sentinel.conf
[[email protected] bin]# ps -ef|grepredis-sentinel
root 2638 1 0 01:05? 00:00:04 redis-sentinel*:26379
查看配置文件是否有变化
如果对此有兴趣,请扫下面二维码免费获取更多详情
以上是关于Linux/Centos Redis集群安装的主要内容,如果未能解决你的问题,请参考以下文章
Linux(CentOS7) 环境搭建 redis5.0.8 集群