调整系统参数
sed -i '$i\echo never > /sys/kernel/mm/transparent_hugepage/enabled' /etc/rc.local
编译安装redis
mkdir -p /data/redis-6379
mkdir -p /data/redis-26379
cd /data
wget http://download.redis.io/releases/redis-4.0.11.tar.gz
tar zxvf redis-4.0.11.tar.gz
cd redis-4.0.11
yum install gcc -y
make MALLOC=libc
cd src && make install
安装redis-Master服务
cat > /data/redis-6379/redis.conf << EOF
port 6379
bind 0.0.0.0
timeout 0
daemonize yes
protected-mode no
#requirepass Centaur*123
logfile "6379.log"
dbfilename "dump-6379.rdb"
save 900 1
save 300 10
save 60 10000
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
dir "/data/redis-6379/"
pidfile "/var/run/redis_6379.pid"
EOF
cp /data/redis-4.0.11/utils/redis_init_script /etc/init.d/redis_6379
sed -i 's/^.*CONF=.*$/CONF="\/data\/redis-6379\/redis.conf"/' /etc/init.d/redis_6379
chkconfig --add redis_6379
chkconfig redis_6379 on
/etc/init.d/redis_6379 start
安装redis-Slave服务
cat > /data/redis-6379/redis.conf << EOF
port 6379
bind 0.0.0.0
timeout 0
daemonize yes
protected-mode no
#requirepass Centaur*123
logfile "6379.log"
dbfilename "dump-6379.rdb"
save 900 1
save 300 10
save 60 10000
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
dir "/data/redis-6379/"
pidfile "/var/run/redis_6379.pid"
slaveof 10.173.32.10 6379
#masterauth Centaur*123
EOF
cp /data/redis-4.0.11/utils/redis_init_script /etc/init.d/redis_6379
sed -i 's/^.*CONF=.*$/CONF="\/data\/redis-6379\/redis.conf"/' /etc/init.d/redis_6379
chkconfig --add redis_6379
chkconfig redis_6379 on
/etc/init.d/redis_6379 start
安装redis-Sentinel服务
cat > /data/redis-26379/sentinel.conf << EOF
port 26379
bind 0.0.0.0
daemonize yes
logfile "26379.log"
dir "/data/redis-26379/"
pidfile "/var/run/redis_26379.pid"
sentinel monitor mymaster 10.173.32.10 6379 2
#sentinel auth-pass mymaster Centaur*123
sentinel down-after-milliseconds mymaster 10000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 180000
sentinel deny-scripts-reconfig yes
EOF
cp /data/redis-4.0.11/utils/redis_init_script /etc/init.d/redis_26379
sed -i 's/^.*CONF=.*$/CONF="\/data\/redis-26379\/sentinel.conf"/' /etc/init.d/redis_26379
sed -i 's/^.*REDISPORT=.*$/REDISPORT=26379/' /etc/init.d/redis_26379
sed -i 's/redis-server/redis-sentinel/' /etc/init.d/redis_26379
chkconfig --add redis_26379
chkconfig redis_26379 on
/etc/init.d/redis_26379 start