外观
基于Docker部署Redis数据库
创建网络
docker network create ssn-network
提示
如已创建过则不需要重复创建
运行一个redis容器
docker run -d --name ssn-redis-db
-p 25901:6379
-v /ssndisk/sh/redis-healthcheck.sh:/opt/redis-healthcheck.sh
--network ssn-network
--restart=always
--health-cmd="sh /opt/redis-healthcheck.sh"
--health-interval=10s
--health-retries=10
--health-timeout=5s
redis:alpine
--requirepass RedisPasswordDiyPassxxx
--bind "0.0.0.0"
[附]心跳检查的SH程序
vi /ssndisk/sh/redis-healthcheck.sh
#!/bin/bash
redisPWD="RedisPasswordDiyPassxxx"
if ping="$(redis-cli -a "$redisPWD" 2>/dev/null ping)" && [ "$ping" = 'PONG' ]; then
exit 0
else
exit 1
fi