当前位置:网站首页>Redis active / standby configuration dockercompose version
Redis active / standby configuration dockercompose version
2022-06-22 13:13:00 【gsls200808】
redis In the master-slave configuration, the slave server is read-only and cannot be written , Automatically switch between active and standby through sentinel mode , The program configuration needs to configure all nodes
Prepare two virtual machines , System centos7
ip Distribute
host1:192.168.3.53
host2:192.168.3.54
install docker
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
yum install -y docker-ce-18.09.0 docker-ce-cli-18.09.0
systemctl start docker.service
systemctl enable docker.service
docker versioninstall docker-compose
curl -L https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose versionhost1 Of docker-compose.yml
version: '3'
services:
redis-rs1:
container_name: 'redis_rs1'
image: 'redis:5.0.3'
restart: always
volumes:
- ~/commpwr/redis/data:/data
- ~/commpwr/redis/conf/redis.conf:/etc/redis/redis.conf
ports:
- 6379:6379
command: redis-server /etc/redis/redis.conf --port 6379 --requirepass 123456 --appendonly yes
sentinel:
container_name: 'sentinel'
image: 'redis:5.0.3'
restart: always
volumes:
- ~/commpwr/sentinel/conf/sentinel.conf:/etc/redis/sentinel.conf
ports:
- 26379:26379
command: redis-sentinel /etc/redis/sentinel.conf
host2 Of docker-compose.yml
version: '3'
services:
redis-rs2:
container_name: 'redis_rs2'
image: 'redis:5.0.3'
restart: always
volumes:
- ~/commpwr/redis/data:/data
- ~/commpwr/redis/conf/redis.conf:/etc/redis/redis.conf
ports:
- 6379:6379
command: redis-server /etc/redis/redis.conf --port 6379 --requirepass 123456 --appendonly yes --slaveof 192.168.3.53 6379 --masterauth 123456
sentinel:
container_name: 'sentinel'
image: 'redis:5.0.3'
restart: always
volumes:
- ~/commpwr/sentinel/conf/sentinel.conf:/etc/redis/sentinel.conf
ports:
- 26379:26379
command: redis-sentinel /etc/redis/sentinel.confredis.conf download
Official website Redis configuration | Redis
5.0 edition
wget https://raw.githubusercontent.com/redis/redis/5.0/redis.confModify the following content after downloading
Comment out bind
Add or modify masterauth 123456host1 Of sentinel.conf
# bind 127.0.0.1 192.168.1.1
# protected-mode no
port 26379
#daemonize yes
#pidfile /var/run/redis-sentinel.pid
logfile "sentinel.log"
sentinel myid 02ba5344dfb96dc699bcefc2e1d105190c0e85e3
sentinel deny-scripts-reconfig yes
sentinel monitor master001 192.168.3.53 6379 1
sentinel down-after-milliseconds master001 10000
sentinel auth-pass master001 123456
sentinel config-epoch master001 4
sentinel leader-epoch master001 5
sentinel known-replica master001 192.168.3.54 6379
# Generated by CONFIG REWRITE
dir "/data"
sentinel known-sentinel master001 192.168.3.54 26379 f5e14a1e2d376544dcc2ce88a37a710d5c8a65a4
sentinel known-sentinel master001 192.168.3.53 26379 02ba5344dfb96dc699bcefc2e1d105190c0e85e3
sentinel current-epoch 11
sentinel announce-ip "192.168.3.53"
sentinel announce-port 26379
masterauth "123456"
host2 Of sentinel.conf
# bind 127.0.0.1 192.168.1.1
# protected-mode no
port 26379
#daemonize yes
#pidfile /var/run/redis-sentinel.pid
logfile "sentinel.log"
sentinel myid f5e14a1e2d376544dcc2ce88a37a710d5c8a65a4
sentinel deny-scripts-reconfig yes
sentinel monitor master001 192.168.3.53 6379 1
sentinel down-after-milliseconds master001 10000
sentinel auth-pass master001 123456
sentinel config-epoch master001 4
sentinel leader-epoch master001 11
sentinel known-replica master001 192.168.3.54 6379
# Generated by CONFIG REWRITE
dir "/data"
sentinel known-sentinel master001 192.168.3.53 26379 02ba5344dfb96dc699bcefc2e1d105190c0e85e3
sentinel current-epoch 11
sentinel announce-ip "192.168.3.54"
sentinel announce-port 26379
Firewall configuration
firewall-cmd --permanent --add-port=6379/tcp
firewall-cmd --permanent --add-port=26379/tcp
firewall-cmd --reloadSwitch drill
host1 perform
docker stop redis_rs1host2 redis Console execution
info replication
You can see host2 Turned into master
host1 perform
docker start redis_rs1host1redis Console execution
info replication
You can see host1 It becomes a slave node and connects host2 The primary node of .
边栏推荐
猜你喜欢

Pycharm shell script cannot be run

How to improve customer conversion rate on the official website

Isn't this another go bug?

Heavyweight live | bizdevops: the way to break the technology situation under the tide of digital transformation

leetcode 第 297 场周赛

Precautions for upgrading php8 of diyun CMS

In C # development, the third-party components lambdaparser, dynamicexpresso and z.expressions are used to dynamically parse / evaluate string expressions

769. Max Chunks To Make Sorted

SICF批量激活服务节点

MySQL_创建和管理表
随机推荐
SequoiaDB分布式数据库2022.5月刊
310. Minimum Height Trees
阿里云磁盘性能分析
SNC processing failed SAP Router证书重新生成
Application of motion capture system in positioning and mapping of mobile robot in underground tunnel
SAP SPRO configure how to display the corresponding t-code
AcWing第53场周赛
PostGIS through St_ Dwithin retrieves elements within a certain distance
gradle笔记
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
Isn't the execution process of ODPs SQL executed from top to bottom
Automatically delete the log files in the specified directory and within the specified time
think php环境搭建笔记
windows系统安装多个mysql版本(不用卸载原版本),新旧版本兼容。
Hurun Research Institute launched the list of potential enterprises of China's meta universe, and Jushan database was selected as the future star enterprise
769. Max Chunks To Make Sorted
On the routing tree of gin
Universaldependencies dependency label interpretation
Jushan database won two honors of China's information innovation industry in 2022 by AI media consulting
[QT] QT get standard system path