小知识:Linux redis-Sentinel配置详解

下载

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

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

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

安装

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

?
1
tar xzf redis-3.2.8.tar.gz

创建目录/usr/local/redis:

?
1
make dir /usr/local/redis

进入源码目录:

?
1
cd /usr/local/src/redis-3.2.8

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

?
1
make PREFIX=/usr/local/redis install

软连接

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

?
1
2
3
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:

?
1
mkdir /etc/redis
?
1
2
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配置

修改配置以下参数:

?
1
2
3
4
port 6379
daemonize yes
#requirepass 123456
#masterauth 123456

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

redis_slave_6380.conf 配置

修改配置以下参数:

?
1
2
3
4
5
port 6380
daemonize yes
#requirepass yingjun
slaveof 192.168.248.128 6379
masterauth 123456

其他slave配置同此配置。

sentinel_26379.conf 配置

?
1
2
3
4
5
6
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 配置

?
1
2
3
4
5
6
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

启动

顺序依次启动服务。

?
1
2
3
4
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

查看进程是否都已经启动

?
1
2
3
4
5
6
[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

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:http://www.choupangxia.com/topic/detail/149

声明: 猿站网有关资源均来自网络搜集与网友提供,任何涉及商业盈利目的的均不得使用,否则产生的一切后果将由您自己承担! 本平台资源仅供个人学习交流、测试使用 所有内容请在下载后24小时内删除,制止非法恶意传播,不对任何下载或转载者造成的危害负任何法律责任!也请大家支持、购置正版! 。本站一律禁止以任何方式发布或转载任何违法的相关信息访客发现请向站长举报,会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。本网站的资源部分来源于网络,如有侵权烦请发送邮件至:2697268773@qq.com进行处理。
建站知识

小知识:Nginx流量拷贝ngx_http_mirror_module模块使用方法详解

2023-3-17 3:07:10

建站知识

小知识:Nginx速查手册及常见问题

2023-3-17 3:16:24

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索