REDIS 安装
下载地址 http://redis.io/download,Download the latest stable version.
tar xzf redis-4.0.9.tar.gz -C /usr/local
yum install -y make gcc
$ make
redis Simple configuration
#redis简单配置
cp redis.conf redis.conf.bak
vim redis.conf ---Revised as follows
bind 127.0.0.1 #Listen to intranet IP only
daemonize yes #Turn on background mode and change on to yes
timeout 300 #Connection timeout
port 6379 #prot number
databases 0 Redis library No. 16 storing session
dir ./ #Local database storage directory this directory needs to exist
pidfile /var/run/redis_6379.pid #Define PID file
logfile /var/log/redis_6379.log #Defind log file
requirepass tiger # set password
Configure redis to start for systemctl
#配置redis为systemctl启动
cd /lib/systemd/system
vim redis.service
[Unit]
Description=Redis
After=network.target
[Service]
ExecStart=/data/application/redis/src/redis-server /data/application/redis/redis.conf --daemonize no
ExecStop=/data/application/redis/src/redis-cli -h 127.0.0.1 -p 6379 shutdown
[Install]
WantedBy=multi-user.target
Start redis
#启动redis
#Default method
cd src
$ ./redis-server ../redis.conf
Redis master slave + sentry
#Master-slave
testing environment:centos7.4
redis-master:192.168.19.129 vm1
redis-slave1:192.168.19.136 vm4
redis-slave2:192.168.19.135 vm3
1.First, three servers complete the deployment of redis stand-alone.
Edit the redis profile of the master:
[root@redis-master ~]# cd /usr/local/redis-4.0.9
[root@redis-master redis]# vim redis.conf
modify bind为0.0.0.0 protected-mode为no
2.Modify the configuration file of slave1:
[root@redis-slave1 ~]# cd /data/application/redis/
[root@redis-slave1 redis]# vim redis.conf
modify
bind为0.0.0.0
protected-mode为no
Modify slavof as main IP
3.Modify the configuration file of slave2:
[root@redis-slave2 ~]# cd /data/application/redis/
[root@redis-slave2 redis]# vim redis.conf
modify
bind为0.0.0.0
Modify protected-mode as no
Modify slavof as main IP
4.reboot the three redis
Modify sentry
[root@redis-master src]# cd ..
[root@redis-master redis]# vim sentinel.conf
sentinel monitor mymaster 192.168.19.129 6379 2 (The slave indicates the IP address of the master. The master indicates its own IP address)
sentinel down-after-milliseconds mymaster 3000
sentinel failover-timeout mymaster 10000
protected-mode no
Each machine starts sentinel service:
# ./src/redis-sentinel sentinel.conf