In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
For the construction process of redis, please refer to https://blog.51cto.com/12445535/2385106
Next, we find another server to install redis to implement the master-slave architecture of redis
Build a redis with the above method
It's just.
Write from the configuration file in redis
[root@prd3-redis02-10-184conf] # grep slaveof 6379.conf
# slaveof
Slaveof 192.168.10.183 6379 / / add this line directly, and then
Start redis
[root@prd3-redis02-10-184conf] # redis-server / ivargo/app/redis/conf/6379.conf
The next step is to see the gap.
Can be seen in the main redis
[root@prd3-redis01-10-183 conf] # redis-cli-a XXX
Warning: Using a password with'- a 'option on the command line interface may not be safe.
127.0.0.1 purl 6379 > info
Replication
Role:master
Connected_slaves:1
You can see it on redis.
[root@prd3-redis02-10-184conf] # redis-cli-aXXX
Warning: Using a password with'- a 'option on the command line interface may not be safe.
127.0.0.1 purl 6379 > info
# Replication
Role:slave
Master_host:192.168.10.183
Master_port:6379
In this way, the master and follower of redis will be set up.
After building the redis, the directory structure
[root@prd3-redis01-10-183 ivargo] # pwd/ivargo [root@prd3-redis01-10-183 ivargo] # tree. ├── app │ ├── redis │ │ ├── 6379.pid │ │ ├── conf │ └── 6379.conf │ │ ├── data │ ├── 6379.rdb │ └── appendonly_6379. Aof │ │ └── log │ └── sentinel │ └── conf └── log └── 6379.log8 directories 5 files sentinel [root@prd3-redis01-10-183 conf] # pwd/ivargo/app/sentinel/conf [root@prd3-redis01-10-183 conf] # cat sentinel.conf / / this configuration file is the configuration file for sentinel on prd3 We need to modify # Example sentinel.conf# bind 127.0.0.1 192.168.1.1bind 0.0.0.0protected-mode noport 26379daemonize yesloglevel noticelogfile "/ ivargo/log/sentinel.log" dir "/ tmp" # sentinel auth-pass # sentinel down-after-milliseconds # Default is 30 seconds.sentinel myid ba794535d3a65e14b266e28462fa7c68de609f39# sentinel parallel-syncs sentinel deny-scripts-reconfig yes# sentinel failover-timeout # Default is 3 minutes = 180000.sentinel monitor mymaster 10.80.85.20 6379 "Generated by CONFIG REWRITEsentinel down-after-milliseconds mymaster 6000sentinel auth-pass mymaster xxxsentinel config-epoch mymaster 0sentinel leader-epoch mymaster 1sentinel known-slave mymaster 10.80.85.21 6379sentinel known-sentinel mymaster 10.80.85.21 26379 c3002e02c6a2d0041afd2569f3fd1985bc38993esentinel current-epoch 1 [root@prd3-redis01-10-188conf] # cat sentinel.conf / / these are all specified by ourselves The contents of his other documents The sentinel configuration file on # Example sentinel.conf# bind 127.0.0.1 192.168.1.1bind 0.0.0.0protected-mode noport 26379daemonize yesloglevel noticelogfile "/ ivargo/log/sentinel.log" pidfile "/ ivargo/app/sentinel/26379.pid" dir "/ tmp" sentinel monitor mymaster 192.168.10.183 6379 2sentinel auth-pass mymaster XXX184 is the same as [root@prd3-redis01-10-183 conf] # redis-sentinel / ivargo/app/. Sentinel/conf/sentinel.conf [root@prd3-redis02-10-184conf] # redis-sentinel / ivargo/app/sentinel/conf/sentinel.conf [root@prd3-redis01-10-183conf] # cat sentinel.conf# Example sentinel.conf# bind 127.0.0.1 192.168.1.1bind 0.0.0.0protected-mode noport 26379daemonize yesloglevel noticelogfile "/ ivargo/log/sentinel.log" pidfile "/ ivargo / app/sentinel/26379.pid "dir" / tmp "sentinel myid 6075d58bdc7c2602f98d90c0aa48470c4dbb50d9sentinel deny-scripts-reconfig yes# Generated by CONFIG REWRITEsentinel monitor mymaster 192.168.10.183 6379 2sentinel auth-pass mymaster XXXsentinel config-epoch mymaster 0sentinel leader-epoch mymaster 0sentinel known-slave mymaster 192.168.10.184 6379sentinel known-sentinel mymaster 192.168.10.184 26379 039bd11a572245b6c16c6e204523d781ffb6ba4csentinel current-epoch 0 View different points We check [root@prd3-redis01-10-183 conf] # redis-cli-h 192.168.10.183-p 26379 Info # Sentinelsentinel_masters:1sentinel_tilt:0sentinel_running_scripts:0sentinel_scripts_queue_length:0sentinel_simulate_failure_flags:0master0:name=mymaster Status=ok,address=192.168.10.183:6379,slaves=1,sentinels=2 verifies that sentinel High availability [root@prd3-redis01-10-183 redis] # kill `cat 6379.pid` kills the 183s process and then looks at [root@prd3-redis02-10-184conf] # redis-cli-h 192.168.10.183-p 26379 info # Sentinelsentinel_masters:1sentinel_tilt:0sentinel_running_scripts:0sentinel_scripts_queue_length:0sentinel_simulate_failure_flags:0master0:name=mymaster,status=ok,address=192.168.10.184:6379,slaves=1 The sentinels=2 / / master node becomes 184 after launching 183 [root@prd3-redis01-10-183 redis] # redis-server / ivargo/app/redis/conf/6379.conf [root@prd3-redis01-10-183 redis] # redis-cli-h 192.168.10.183-p 26379 info# Sentinelsentinel_masters:1sentinel_tilt:0sentinel_running_scripts:0sentinel_scripts_queue_length:0sentinel_simulate_failure_flags:0master0:name=mymaster,status=ok,address=192.168.10.184:6379,slaves=1 Sentinels=2 then check that the original 183of redis is the master node. Now the slave node [root@prd3-redis01-10-183 redis] # redis-cli-h 192.168.10.183-p 6379-a XXX info # Replicationrole:slavemaster_host:192.168.10.184master_port: 6379 [root @ prd3-redis02-10-184 conf] # redis-cli-h 192.168.10.184-p 6379-a XXX info # Replicationrole:masterconnected_slaves:1slave0:ip=192.168.10.183,port=6379,state=online,offset=169470,lag=1 has implemented the sentinel mechanism of redis, that is, HA mechanism.
In fact, for the current environment, when master-slave switching occurs in redis, such as the ip of program calls, it is obviously unreasonable to write two ip and two sentinel addresses. We can achieve automatic switching of vip mechanism to achieve program calls with only one ip. Please look forward to the relevant content.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un