redis yum master installation configuration from redis

1. Installation
yum the install EPEL release.noarch -Y-
yum the install Redis -Y
2. configure the master from
the master:
Vim /etc/redis.conf # modify the configuration file
bind 10.1.1.111 # listening modify the IP
requirepass # 233233 Add Password

From:
vim /etc/redis.conf # modify the configuration file
bind 10.1.1.112 # modify monitor IP
slaveof 10.1.1.111 # 6379 designated the Lord's ip and port
masterauth 233233 # Specify the main password
to another is also from this configuration


systemctl start redis  #同时启动三台主机
redis-cli -h 10.1.1.111 -a 233233 #登陆主服务器
10.1.1.111:6379> INFO replication  #查看主从信息
#Replication
role:master
connected_slaves:2
slave0:ip=10.1.1.112,port=6379,state=online,offset=1135,lag=0
slave1:ip=10.1.1.113,port=6379,state=online,offset=1135,lag=1
master_repl_offset:1135
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:1134
10.1.1.111:6379> 

Create a key in the primary server

11.10.1.1.111:6379> set ID 001
OK
10.1.1.111:6379> get ID
"001"
10.1.1.111:6379> 

Switch to the View from the server

[root@cs112 ~]# redis-cli  -h 10.1.1.112 -a 233233  #登陆112服务器
10.1.1.112:6379> get ID   #查看ID键值
"001"
10.1.1.112:6379> 

Command from the master configuration (configuration command to automatically synchronize the configuration file)
[the root web1 @ ~] # Redis-CLI -H 10.1.1.233

10.1.1.233:6379> slaveof 10.1.1.111 6379
OK  
10.1.1.233:6379> config set masterauth 233233 
OK
10.1.1.233:6379> 

Log in to view the main server from the master

10.1.1.111:6379> INFO replication
# Replication
role:master
connected_slaves:3
slave0:ip=10.1.1.112,port=6379,state=online,offset=2602,lag=1
slave1:ip=10.1.1.113,port=6379,state=online,offset=2602,lag=1
slave2:ip=10.1.1.233,port=6379,state=online,offset=2602,lag=1
master_repl_offset:2602
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:2

# It can be seen from the server side has a three

redis replication master-slave configuration

The following are some of the tunable redis master copy from the scene, according to the practical needs adjustment

slave-serve-stale-data yes : 是否可以把不新鲜的数据服务与客户端
slave-read-only yes : 从节点只读,启用slaveof定义后才生效
repl-diskless-sync no :是否同时向多个从节点同时发数据
repl-diskless-sync-delay 5 :发送的延迟时间
repl-ping-slave-period 10 探测从节点状态
repl-timeout 60 探测节点超时时间
repl-disable-tcp-nodelay no : 启用nodelay
repl-backlog-size 1mb
slave-priority 100 : 从节点优先级,复制集群中,主节点故障时,sentinel应用场景中的主节点选举时使用的优先级;数字越小优先级越高,但0表示不参与选举;
min-slaves-to-write 3:主节点仅允许其能够通信的从节点数量大于等于此处的值时接受写操作;
min-slaves-max-lag 10:从节点延迟时长超出此处指定的时长时,主节点会拒绝写入操作;

3. availability
go first to the server from a raised priority
vim /etc/redis.conf # 112 modified from the configuration server
slave-priority 110 # adjusted to 110, default 100
systemctl the restart # restart the Redis

Find three server arrangement sentinel service
vim /etc/redis-sentinel.conf
the bind 10.1.1.112 # monitor IP
sentinel Monitor mymaster 10.1.1.111 6379 # 2 set the main server ip
sentinel auth-Pass mymaster 233233 # master server authentication
# other two Taiwan in addition to IP configuration are not the same as other

View
first primary server services to redis stopped
redis-cli -h 10.1.112 -p 26379 # landing sentinel Service

 10.1.1.112:26379>  SENTINEL masters #查看主服务器状态
1)  1) "name"
    2) "mymaster"
    3) "ip"
    4) "10.1.1.113"
    5) "port"
    6) "6379"
    7) "runid"
    8) "7ee5fe0e808bd06638f0f4c365d95c7694c6770c"
    9) "flags"
   10) "master"

Above we have been able to see the home has been transferred to the host computer 113, can be found from other open server configuration, the main configuration file to point 10.1.1.111 has been changed to a 113.

redis-cli -h 10.1.1.112 -a 233233 # 112 and the like from the server

10.1.1.112:6379> iNFO replication
# Replication
role:slave
master_host:10.1.1.113
master_port:6379
master_link_status:down
master_last_io_seconds_ago:-1
master_sync_in_progress:0
slave_repl_offset:1
master_link_down_since_seconds:1574609981
slave_priority:110
slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
10.1.1.112:6379> 

The above can be seen from # 112 from the server 113 has become a main server of

Guess you like

Origin blog.51cto.com/13620944/2453118