时间:2017年08月02日星期三
说明:基于CentOS7-64bit。在单台Linux主机上搭建Redis伪集群哨兵模式。
步骤一:安装Redis 1.下载Redis安装包Redis官网:https://redis.io/
下载地址:https://redis.io/download
2.上传Redis安装包使用ftp工具,将下载好的Redis安装包上传到linux服务器
步骤二:配置文件修改 1.节点规划6301:主
6302:从
6303:从
26301:哨兵模式节点一
26302:哨兵模式节点二
26303:哨兵模式节点三
创建文件夹
mkdir redis-group
复制配置文件
cp redis.conf ../redis-group/redis-6301.conf cp redis.conf ../redis-group/redis-6302.conf cp redis.conf ../redis-group/redis-6303.conf3.修改配置文件
修改redis-6301.conf配置文件
vim redis-6301.conf
将参数的值改为以下
daemonize yes pidfile /var/run/redis6301.pid port 6301 logfile "6301.log" dbfilename dump6301.rdb
修改redis-6302.conf和redis-6303.conf
vim redis-6302.conf daemonize yes pidfile /var/run/redis6302.pid port 6302 logfile "6302.log" dbfilename dump6302.rdb vim redis-6303.conf daemonize yes pidfile /var/run/redis6303.pid port 6303 logfile "6303.log" dbfilename dump6303.rdb步骤三:主从同步 1.启动Redis
进入到redis安装目录的bin目录下,分别启动
./redis-server /home/midware/redis-group/redis-6301.conf ./redis-server /home/midware/redis-group/redis-6302.conf ./redis-server /home/midware/redis-group/redis-6303.conf2.主从关系
进入redis客户端
./redis-cli -p 6301 ./redis-cli -p 6302 ./redis-cli -p 6303
查看当前redis主机节点信息
info replication
在6302和6303客户端分别执行,完成主从关系建立
SLAVEOF 127.0.0.1 6301步骤四:哨兵模式 1.哨兵配置
创建哨兵配置文件
touch sentinel-26301.conf touch sentinel-26302.conf touch sentinel-26303.conf
修改哨兵配置文件
vim sentinel-26301.conf vim sentinel-26302.conf vim sentinel-26303.conf
修改为以下内容,26302和26303配置内容差不多,只需修改对应端口即可
# 使用宿主进程启动 daemonize yes # 启动目录 dir "/home/midware/redis-3.0.7/bin" # 日期文件路径 logfile "/home/midware/redis-group/sentinel-26301.log" # 监听Redis主机地址及端口 sentinel monitor host6379 172.17.0.3 6301 12.哨兵启动
分别启动哨兵
./redis-sentinel /home/midware/redis-group/sentinel-26301.conf ./redis-sentinel /home/midware/redis-group/sentinel-26302.conf ./redis-sentinel /home/midware/redis-group/sentinel-26303.conf
查看哨兵日志
tail -f /home/midware/redis-group/sentinel-26301.log tail -f /home/midware/redis-group/sentinel-26302.log tail -f /home/midware/redis-group/sentinel-26303.log
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/10199.html
时间:2017年08月02日星期三 说明:基于CentOS7-64bit。在单台Linux主机上搭建Redis伪集群哨兵模式。 步骤一:安装Redis 1.下载Redis安装包 Redis官网:https://redis.io/ 下载地址:https://redis.io/download 2.上传Redis安装包 使用ftp工具,将下载好的Redis安装包上传到linux服务器 步骤二:配置文件...
摘要:时间年月日星期二说明基于,开始本教程前,请确保您的系统已安装。为了保证集群的高可用,下面开始配置哨兵模式。 时间:2017年07月11日星期二 说明:基于Ubuntu16.04-64bit,开始本教程前,请确保您的Linux系统已安装Docker。 步骤一:Redis镜像安装 1、下载Redis镜像 镜像中心 推荐使用网易蜂巢的镜像中心 地址:https://c.163.com/hub...
摘要:时间年月日星期二说明基于,开始本教程前,请确保您的系统已安装。为了保证集群的高可用,下面开始配置哨兵模式。 时间:2017年07月11日星期二 说明:基于Ubuntu16.04-64bit,开始本教程前,请确保您的Linux系统已安装Docker。 步骤一:Redis镜像安装 1、下载Redis镜像 镜像中心 推荐使用网易蜂巢的镜像中心 地址:https://c.163.com/hub...
摘要:时间年月日星期二说明基于,开始本教程前,请确保您的系统已安装。为了保证集群的高可用,下面开始配置哨兵模式。 时间:2017年07月11日星期二 说明:基于Ubuntu16.04-64bit,开始本教程前,请确保您的Linux系统已安装Docker。 步骤一:Redis镜像安装 1、下载Redis镜像 镜像中心 推荐使用网易蜂巢的镜像中心 地址:https://c.163.com/hub...
摘要:启动服务先主服务,后从服务没错,就是这样搭建完毕了六源代码地址地址知了一笑码云地址知了一笑 一、环境和版本 Linux:centos7 三台 三台Linux服务 192.168.72.129 192.168.72.130 192.168.72.131 Redis:redis-4.0.14 二、上传Redis软件 1、创建软件目录 [root@localhost local]# cd /...
阅读 1162·2023-04-25 22:42
阅读 1965·2021-09-22 15:16
阅读 657·2021-09-09 09:33
阅读 3352·2021-08-30 09:44
阅读 385·2019-08-29 16:44
阅读 3204·2019-08-29 16:20
阅读 2404·2019-08-29 16:12
阅读 3285·2019-08-29 16:07