1、创建数据目录(logs目录要给权限,要不然会报错)
mkdir -pv /data/redis/(data,logs} chmod 777 /data/redis/logs
2、redis.conf 配置文件 -—-主从配置
master 节点配置
cd /data/redis vim redis.conf port 6379 bind 0.0.0.0 daemonize no protected-mode no requirepass 123456 masterauth 123456 appendonly yes logfile "/var/log/redis/redis.log" #保存退出 :wq
slaveof 节点配置
cd /data/redis vim redis.conf port 6379 bind 0.0.0.0 daemonize no protected-mode no requirepass 123456 masterauth 123456 appendonly yes logfile "/var/log/redis/redis.log" slaveof 10.190.107.194 6379 #slaveof 节点需要知道master 节点地址 #slaveof 10.190.107.194 6379 #保存退出 :wq
3、docker 启动redis
docker run -id \ --restart=always \ --network=host \ --privileged=true \ --name=redis \ -p 6379:6379 \ -v /data/redis/redis.conf:/etc/redis/redis.conf \ -v /data/redis/data:/data \ -v /data/redis/logs:/var/log/redis \ redis:7.0.11 redis-server /etc/redis/redis.conf
4、进入容器中 执行以下命令 进行验证
redis-cli auth 密码 info replication
标签:log,redis,6379,conf,docker,data,主从,logs From: https://www.cnblogs.com/scfssq/p/17903814.html