In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
This article is about Docker Compose stand-alone configuration of Redis and Senti to share with you. The editor thought it was very practical, so I shared it with you to learn. The following information is about the steps of Docker Compose stand-alone configuration of Redis and Senti.
Uninstall the old version of docker uninstall old version
Sudo yum remove docker\
Docker-client\
Docker-client-latest\
Docker-common\
Docker-latest\
Docker-latest-logrotate\
Docker-logrotate\
Docker-engine
Install repo install docker repo
Sudo yum install-y yum-utils\
Device-mapper-persistent-data\
Lvm2
Sudo yum-config-manager\
-- add-repo\
Https://download.docker.com/linux/centos/docker-ce.repo
Install the community version of install Docker Engine-Community
Sudo yum install-y docker-ce docker-ce-cli containerd.io-- skip-broken
Set up service startup and test images
Sudo systemctl start docker
Sudo systemctl enable docker
Sudo docker run hello-world
Install git and download code
Sudo yum install-y git
Git clone https://github.com/AliyunContainerService/redis-cluster
Cd redis-cluster
Check the docker compose file
Cat docker-compose.yml
Master:
Image: redis:3
Slave:
Image: redis:3
Command: redis-server-- slaveof redis-master 6379
Links:
-master:redis-master
Sentinel:
Build: sentinel
Environment:
-SENTINEL_DOWN_AFTER=5000
-SENTINEL_FAILOVER=5000
Links:
-master:redis-master
-slave
The following series of services are defined in the template
Master: Redis masterslave: Redis slavesentinel: Redis Sentinel
Cat sentinel.conf
# Example sentinel.conf can be downloaded from http://download.redis.io/redis-stable/sentinel.conf
Port 26379
Dir / tmp
Sentinel monitor mymaster redis-master 6379 $SENTINEL_QUORUM
Sentinel down-after-milliseconds mymaster $SENTINEL_DOWN_AFTER
Sentinel parallel-syncs mymaster 1
Sentinel failover-timeout mymaster $SENTINEL_FAILOVER
And start the container in sentinel mode. The configuration file is as follows, which contains the sentinel monitoring configuration for the cluster named "mymaster"
Note:
The Redis master node hostname of the initialization configuration of slave and sentinel containers is "redis-master". Here we use the alias mechanism of Docker container connection to connect master and sentinel/slave container instances. Since we will deploy three Sentinel, we set the "quorum" of sentinel to 2. Only the two sentinel agree to failover, the corresponding redis master node will be switched.
Sudo yum install-y docker-compose
Sudo docker-compose up-d
The toilet is all ready.
Docker ps
Why are there only two sentinels, expanded to three?
Docker-compose scale sentinel=3
Expand the capacity of 2 slave redis through defecation
Docker-compose scale slave=2
Take a look at the contents of the current run.
Docker ps | sort-K2
Change a script to test redis downtime
Vi test.sh
MASTER_IP=$ (docker inspect-- format'{{.NetworkSettings.IPAddress}} 'rediscluster_master_1)
SLAVE_IP=$ (docker inspect-- format'{{.NetworkSettings.IPAddress}} 'rediscluster_slave_1)
SENTINEL_IP=$ (docker inspect-- format'{{.NetworkSettings.IPAddress}} 'rediscluster_sentinel_1)
Echo Redis master: $MASTER_IP
Echo Redis Slave: $SLAVE_IP
Echo
Echo Initial status of sentinel
Echo
Docker exec rediscluster_sentinel_1 redis-cli-p 26379 info Sentinel
Echo Current master is
Docker exec rediscluster_sentinel_1 redis-cli-p 26379 SENTINEL get-master-addr-by-name mymaster
Echo
Echo Stop redis master
Docker pause rediscluster_master_1
Echo Wait for 10 seconds
Sleep 10
Echo Current infomation of sentinel
Docker exec rediscluster_sentinel_1 redis-cli-p 26379 info Sentinel
Echo Current master is
Docker exec rediscluster_sentinel_1 redis-cli-p 26379 SENTINEL get-master-addr-by-name mymaster
Echo
Echo Restart Redis master
Docker unpause rediscluster_master_1
Sleep 5
Echo Current infomation of sentinel
Docker exec rediscluster_sentinel_1 redis-cli-p 26379 info Sentinel
Echo Current master is
Docker exec rediscluster_sentinel_1 redis-cli-p 26379 SENTINEL get-master-addr-by-name mymaster
. / test.sh
Redis master was found to have switched.
However, 3 redis and 3 sentinel of one host are not highly available, so redis and sentinel need to be deployed to multiple hosts in different regions.
These are the details of Docker Compose stand-alone configuration of Redis and Senti. Have you gained anything after reading it? If you want to know more about it, you are welcome to follow the industry information!
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
© 2024 shulou.com SLNews company. All rights reserved.