Linux redis-Sentinel配置详解
下载
下载地址:https://redis.io/download
在/usr/local/src目录下执行下载。
wgethttp://download.redis.io/releases/redis-3.2.8.tar.gz
安装
解压到/usr/local/src目录,放源码包。
tarxzfredis-3.2.8.tar.gz
创建目录/usr/local/redis:
makedir/usr/local/redis
进入源码目录:
cd/usr/local/src/redis-3.2.8
然后执行下面make命令编译安装到目录/usr/local/redis/(放执行文件)。
makePREFIX=/usr/local/redisinstall
软连接
程序做软连接到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配置
修改配置以下参数:
port6379 daemonizeyes #requirepass123456 #masterauth123456
其中,daemonize属性改为yes(后台运行)。
redis_slave_6380.conf配置:
修改配置以下参数:
port6380 daemonizeyes #requirepassyingjun slaveof192.168.248.1286379 masterauth123456
其他slave配置同此配置。
sentinel_26379.conf配置
port23791 daemonizeyes logfile"/var/log/sentinel_63791.log" #master-1 sentinelmonitormaster-1192.168.248.12863792 #sentinelauth-passmaster-1yingjun
sentinel_26380.conf配置
port23780 daemonizeyes logfile"/var/log/sentinel_63780.log" #master-1 sentinelmonitormaster-1192.168.248.12863792 #sentinelauth-passmaster-1yingjun
启动
顺序依次启动服务。
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@iZj6cqZredis]#ps-ef|grepredis root109101008:11?00:00:00redis-server127.0.0.1:6379 root109181008:11?00:00:00redis-server127.0.0.1:6380 root109391008:15?00:00:00redis-sentinel*:26379[sentinel] root109441008:15?00:00:00redis-sentinel*:26380[sentinel] root1094810851008:15pts/100:00:00grep--color=autoredis
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。