REDIS集群配置

REDIS 安装

下载地址 http://redis.io/download,Download the latest stable version.
wget http://download.redis.io/releases/redis-4.0.9.tar.gz tar xzf redis-4.0.9.tar.gz -C /usr/local
cd redis-4.0.9 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
src/redis-server 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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。