内容包括:
安装Redis
cd /tools
scp root@10.xx.xx.223:/tools/redis-5.0.5.tar.gz /tools
yum install -y gcc
tar -zxvf redis-5.0.5.tar.gz -C /usr/local/
cd /usr/local/redis-5.0.5/
make install prefix=/usr/local/bin
mkdir /etc/redis
cp /usr/local/redis-5.0.5/redis.conf /etc/redis/
chmod 777 /etc/redis/redis.conf
sed -i 's/daemonize no/daemonize yes/g' /etc/redis/redis.conf
sed -i 's/bind 127.0.0.1/bind 0.0.0.0/g' /etc/redis/redis.conf
sed -i 's/# requirepass foobared/requirepass ljfirst/g' /etc/redis/redis.conf
cp /usr/local/redis-5.0.5/utils/redis_init_script /etc/init.d/redis
chmod +x /etc/init.d/redis
sed -i 's/REDISPORT=6379/REDISPORT=redis/g' /etc/init.d/redis
chkconfig --add redis
systemctl enable redis
systemctl status redis.service
systemctl start redis.service
protected-mode yes
bind 0.0.0.0
port 6379
daemonize yes
pidfile "/var/run/redis_6379.pid"
logfile "/etc/redis/redis.log"
dir "/etc/redis"
dbfilename "dump.rdb"
replica-read-only yes
masterauth "ljfirst"
requirepass "ljfirst"
replicaof 10.xxx.xxx.214 6379 # 从节点才配置这个
port 26379
daemonize yes
protected-mode no
pidfile "/var/run/redis-sentinel.pid"
logfile "/etc/redis/sentinel.log"
dir "/tmp"
sentinel myid 9632dc4e6abd37cfbc1cf347bcf38f3aa81a2450
sentinel deny-scripts-reconfig yes
sentinel monitor mymaster01 10.xxx.xxx.214 6379 2
sentinel down-after-milliseconds mymaster01 5000
sentinel failover-timeout mymaster01 10000
sentinel client-reconfig-script mymaster01 /etc/redis/transip.sh # 启用VIP的语句
sentinel auth-pass mymaster01 Sxx3d3xxx4
#!/bin/bash
MASTER_IP=$6
LOCAL_IP='10.xxx.xxx.212'
VIP