sentinel.sh
脚本
1
|
docker run -it --rm --privileged= true -v=/root/docker-config/redis/conf/:/etc/redis/ redis chown -R redis /etc/redis |
主要语句:==chown -R redis /etc/redis==
1
2
3
4
5
6
7
8
|
root@DESKTOP-Q13EI52:~/docker-config/redis# docker run -it --rm --privileged= true -v=/root/docker-config/redis/conf/:/etc/redis/ redis ls -l /etc/redis/ total 204 -rw-r--r-- 1 redis root 61793 May 10 07:41 redis_6379.conf -rw-r--r-- 1 redis root 61864 May 10 12:52 redis_6380.conf -rw-r--r-- 1 redis root 61890 May 10 12:52 redis_6381.conf -rw-r--r-- 1 redis root 459 May 10 12:52 sentinel_26379.conf -rw-r--r-- 1 redis root 161 May 10 07:56 sentinel_26380.conf -rw-r--r-- 1 redis root 161 May 10 10:16 sentinel_26381.conf |
1
|
sh scripts/run.sh 6379 |
1
2
|
sh scripts/run.sh 6380 sh scripts/run.sh 6381 |
1
2
3
4
5
6
7
|
docker exec -it redis_6380 bash docker exec -it redis_6381 bash # 进入容器后执行命令 redis-cli # 设置为从服务 slaveof 172.17.0.2 6379 |
效果图
1
|
sh scripts/sentinel.sh |
效果图
1
2
3
4
5
6
|
root@DESKTOP-Q13EI52:~/docker-config/redis# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e518580ce8eb redis "docker-entrypoint.s…" About a minute ago Up About a minute 6379/tcp, 0.0.0.0:26379->26379/tcp sentinel_26379 e2ef253d3513 redis "docker-entrypoint.s…" 2 hours ago Up 2 hours 0.0.0.0:6381->6379/tcp redis_6381 15fdc81eb530 redis "docker-entrypoint.s…" 2 hours ago Up 2 hours 0.0.0.0:6380->6379/tcp redis_6380 77f4fdc84cb1 redis "docker-entrypoint.s…" 2 hours ago Up 2 hours 0.0.0.0:6379->6379/tcp redis_6379 |