Linux redis-Sentinel配置

栏目: 数据库 · 发布时间: 7年前

内容简介:下载地址:在/usr/local/src目录下执行下载。解压到/usr/local/src目录,放源码包。

下载地址: https://redis.io/download

在/usr/local/src目录下执行下载。

wget http://download.redis.io/releases/redis-3.2.8.tar.gz

安装

解压到/usr/local/src目录,放源码包。

tar xzf redis-3.2.8.tar.gz

创建目录/usr/local/redis:

make dir /usr/local/redis

进入源码目录:

cd /usr/local/src/redis-3.2.8

然后执行下面make命令编译安装到目录/usr/local/redis/ (放执行文件)。

make PREFIX=/usr/local/redis install

软连接

程序做软连接到bin目录,方便直接执行。

ln -s /usr/local/redis/bin/redis-cli /usr/local/bin/redis-cli
ln -s /usr/local/redis/bin/redis-sentinel /usr/local/bin/redis-sentinel
ln -s /usr/local/redis/bin/redis-server /usr/local/bin/redis-server

配置文件

复制配置文件,在源码包里有sentinel.conf和redis.conf文件,复制到/etc/redis/目录下,如果有多个实例,建议改名,如本实例用的 redis 端口是7021,sentinel是17021:

mkdir /etc/redis
cp /usr/local/src/redis-3.2.8/redis.conf /etc/redis/redis_6379.conf 
cp /usr/local/src/redis-3.2.8/sentinel.conf /etc/redis/sentinel_26379.conf

redis_master_6379.conf配置

修改配置以下参数:

port 6379
daemonize yes
#requirepass 123456
#masterauth 123456

其中,daemonize属性改为yes(后台运行)。

redis_slave_6380.conf 配置:

修改配置以下参数:

port 6380
daemonize yes
#requirepass yingjun
slaveof 192.168.248.128 6379
masterauth 123456

其他slave配置同此配置。

sentinel_26379.conf 配置

port 23791
daemonize yes
logfile "/var/log/sentinel_63791.log"
#master-1
sentinel monitor master-1 192.168.248.128 6379 2
#sentinel auth-pass master-1 yingjun

sentinel_26380.conf 配置

port 23780
daemonize yes
logfile "/var/log/sentinel_63780.log"
#master-1
sentinel monitor master-1 192.168.248.128 6379 2
#sentinel auth-pass master-1 yingjun

启动

顺序依次启动服务。

redis-server /etc/redis/redis_master_6379.conf
redis-server /etc/redis/redis_slave_6380.conf  
redis-sentinel /etc/redis/sentinel_26379.conf
redis-sentinel /etc/redis/sentinel_26380.conf

查看进程是否都已经启动

[root@iZj6cqZ redis]# ps -ef | grep redis
root     10910     1  0 08:11 ?        00:00:00 redis-server 127.0.0.1:6379
root     10918     1  0 08:11 ?        00:00:00 redis-server 127.0.0.1:6380
root     10939     1  0 08:15 ?        00:00:00 redis-sentinel *:26379 [sentinel]
root     10944     1  0 08:15 ?        00:00:00 redis-sentinel *:26380 [sentinel]
root     10948 10851  0 08:15 pts/1    00:00:00 grep --color=auto redis

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

领域特定语言

领域特定语言

Martin Fowler / ThoughtWorks中国 / 机械工业出版社华章公司 / 2013-3 / 89.00元

本书是DSL领域的丰碑之作,由世界级软件开发大师和软件开发“教父”Martin Fowler历时多年写作而成,ThoughtWorks中国翻译。全面详尽地讲解了各种DSL及其构造方式,揭示了与编程语言无关的通用原则和模式,阐释了如何通过DSL有效提高开发人员的生产力以及增进与领域专家的有效沟通,能为开发人员选择和使用DSL提供有效的决策依据和指导方法。 全书共57章,分为六个部分:第一部分介......一起来看看 《领域特定语言》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

SHA 加密
SHA 加密

SHA 加密工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试