准备
先从redis官网下载redis到linux
安装
#解压
tar –zxvf redis.tar.gz
#解压好后进入目录
cd redis
#编译安装
#先make如果编译环境缺失会有报错信息,按照报错信息安装相应的环境
make
#如果不确定是否编译通过可以使用下面这条命令,输出0表示编译通过
echo $?
make install
配置前通用操作
#备份默认配置文件
cp redis.conf redis.conf.bak
cp sentinel.conf sentinel.conf.bak
#创建文件存放目录
mkdir /app/logs
mkdir /app/logs/redis
mkdir /app/data
mkdir /app/data/redis
#新建用户和组
groupadd redis
useradd -d /usr/redis -m -g redis redis
echo "redis" | passwd --stdin redis
#给用户和组赋予权限
chown -R redis:redis /app
哨兵模式配置
修改redis.conf
port 6379
daemonize yes
pidfile "/app/data/redis/redis_6379.pid"
logfile "/app/logs/redis/6379.log"
dbfilename "dump6379.rdb"
dir "/app/data/redis"
requirepass "yourpassword"
#配置了requirepass,就需要配置从节点连接的masterauth
masterauth "yourpassword"
#slaveof只配置在从节点中,master中不需要配置
slaveof 10.192.201.146 6379
修改sentinel.conf
port 26379
daemonize yes
pidfile "/app/data/redis/redis-sentinel_26379.pid"
logfile "/app/logs/redis/26379.log"
dir "/app/logs/redis"
sentinel monitor mymaster 10.192.201.146 6379 2
sentinel auth-pass mymaster yourpassword
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 180000
sentinel deny-scripts-reconfig yes
启动
#启动redis
src/redis-server redis.conf
#启动sentinel
src/redis-sentinel sentinel.conf
#停止redis
src/redis-cli
AUTH yourpassword
shutdown
2932

被折叠的 条评论
为什么被折叠?



