Linux redis-Sentinel配置

本文涉及的产品
云数据库 Redis 版,社区版 2GB
推荐场景:
搭建游戏排行榜
简介: Linux redis-Sentinel配置

下载

下载地址: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


相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
目录
相关文章
|
7天前
|
NoSQL Linux 测试技术
Redis的安装(Linux版)
Redis的安装(Linux版)
149 1
|
1天前
|
Oracle Java 关系型数据库
Linux环境安装配置JDK11
Linux环境安装配置JDK11
14 0
|
1天前
|
Ubuntu Linux
Linux(Ubuntu)系统临时IP以及静态IP配置(关闭、启动网卡等操作)
请注意,以上步骤是在临时基础上进行配置的。如果要永久保存静态IP地址,通常还需要修改 `/etc/network/interfaces`文件,以便在系统重启后保持配置。同时,确保备份相关配置文件以防止出现问题。
11 1
|
3天前
|
Ubuntu Linux 测试技术
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试(下)
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试
35 1
|
3天前
|
运维 网络协议 Linux
Linux(28) Linux双网卡配置为连接到Linux主机的PC提供外网访问
Linux(28) Linux双网卡配置为连接到Linux主机的PC提供外网访问
30 1
|
4天前
|
Ubuntu 网络协议 Linux
Linux(20) Ubuntu 20.04 网络接口自动切换路由配置
Linux(20) Ubuntu 20.04 网络接口自动切换路由配置
27 0
|
4天前
|
Linux
Linux(9)Debain EC25 quectel-CM usbnet0开机自动联网配置
Linux(9)Debain EC25 quectel-CM usbnet0开机自动联网配置
15 0
|
7天前
|
Linux 网络安全 开发工具
【GitLab私有仓库】在Linux上用Gitlab搭建自己的私有库并配置cpolar内网穿透
【GitLab私有仓库】在Linux上用Gitlab搭建自己的私有库并配置cpolar内网穿透
|
7天前
|
缓存 安全 Ubuntu
Linux配置代理上网
如何配置Linux代理
16 1
|
17天前
|
NoSQL Linux PHP
php添加redis扩展 linux和windos图文详解 l
php添加redis扩展 linux和windos图文详解 l
3 0