1. Temporarily close selinux and then open it again

Disable selinux: setenforce 0 Enable selinux: setenforce 1Copy the code

2. Create a redis directory in the current folder

mkdir redis-sentinel
Copy the code

3. Access the directory redis

cd  redis
Copy the code

Docker-composemess. yml: docker-composemess. yml: docker-composemess. yml: docker-composemess. yml: docker-composemess. yml

Version: '3.7' services: master: image: redis container_name: redis-master restart: always command: redis-server --port 6379 --requirepass lch2199. --appendonly yes ports: - 6379:6379 volumes: - /app/data/redis:/data slave1: image: redis container_name: redis-slave-1 restart: always command: Redis-server --slaveof 192.168.0.6 6379 --port 6380 --requirepass lch2199. --masterauth lch2199.  - 6380:6380 volumes: - /app/data/redis:/data slave2: image: redis container_name: redis-slave-2 restart: always command: Redis-server --slaveof 192.168.0.6 6379 --port 6381 --requirepass lch2199. --masterauth lch2199.  - 6381:6381 volumes: - /app/data/redis:/dataCopy the code

Where /app/data/redis is the path of the host (/app/data/redis)

5. Start/close the Redis cluster

Docker-compose up -d Docker-compose DownCopy the code

6. Create a redis-sentinel directory in the current folder

mkdir redis-sentinel
Copy the code

7. Access the directory redis-sentinel

cd  redis-sentinel
Copy the code

8. Create docker-comemage. yml file to deploy redis-Sentinel

Version: '3.7' services: Sentinel1: image: redis container_name: Redis-sentinel-1 Command: redis-sentinel /usr/local/etc/redis/sentinel.conf restart: always ports: - 26379:26379 volumes: - ./sentinel1.conf:/usr/local/etc/redis/sentinel.conf sentinel2: image: redis container_name: redis-sentinel-2 command: redis-sentinel /usr/local/etc/redis/sentinel.conf restart: always ports: - 26380:26379 volumes: - ./sentinel2.conf:/usr/local/etc/redis/sentinel.conf sentinel3: image: redis container_name: redis-sentinel-3 command: redis-sentinel /usr/local/etc/redis/sentinel.conf restart: always ports: - 26381:26379 volumes: - ./sentinel3.conf:/usr/local/etc/redis/sentinel.confCopy the code

Create the sentinel.conf file

Port 26379 dir/TMP # User-defined cluster name, 192.168.8.188 is the IP address of redis-master, 6379 is the port of redis-master, 2 indicates the minimum number of votes. Sentinel monitor myMaster 192.168.0.6 6379 2 Sentinel Down-after-milliseconds mymaster 30000 sentinel parallel-syncs mymaster 1 sentinel auth-pass mymaster test@dbuser2018 sentinel failover-timeout mymaster 180000 sentinel deny-scripts-reconfig yesCopy the code

10. Make three copies of the sentinel.conf file

cp sentinel.conf sentinel1.conf
cp sentinel.conf sentinel2.conf
cp sentinel.conf sentinel3.conf
Copy the code

11. Start/close the Redis-Sentinel cluster

Docker-compose up -d Docker-compose DownCopy the code

Tutorial: www.e-learn.cn/content/jav…