-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第四期 作业六:使用 Docker 本地搭建一套 Redis Cluster 集群 #40
Comments
3主3从6节点: 指令测试(需要 redis-cli -c 客户端模式): |
1.准备配置文件模板
2.快速创建 IP=192.168.1.149 #替换成本机ip
for port in `seq 6379 6381`; do
mkdir -p ${port}/conf
&& PORT=${port} envsubst < redis.conf.tmpl> ${port}/conf/redis.conf
&& mkdir -p ${port}/data;
done 3.docker-compose.yml version: "3"
# 定义服务,可以多个
services:
redis-6379: # 服务名称
image: redis:6.2.7 # 创建容器时所需的镜像
container_name: redis-6379 # 容器名称
network_mode: "host" # host 网络模式
volumes: # 数据卷,目录挂载
- ./6379/config/redis.conf:/usr/local/etc/redis/redis.conf
- ./6379/data:/data
command: redis-server /usr/local/etc/redis/redis.conf # 覆盖容器启动后默认执行的命令
ports:
# 使用宿主机的端口映射到容器的端口
# 宿主机:容器
- 6379:6379
redis-6380:
image: redis:6.2.7
container_name: redis-6380
network_mode: "host"
volumes:
- ./6380/config/redis.conf:/usr/local/etc/redis/redis.conf
- ./6380/data:/data
command: redis-server /usr/local/etc/redis/redis.conf
ports:
# 使用宿主机的端口映射到容器的端口
# 宿主机:容器
- 6380:6380
redis-6381:
image: redis:6.2.7
container_name: redis-6381
network_mode: "host"
volumes:
- ./6381/config/redis.conf:/usr/local/etc/redis/redis.conf
- ./6381/6381/data:/data
command: redis-server /usr/local/etc/redis/redis.conf
ports:
# 使用宿主机的端口映射到容器的端口
# 宿主机:容器
- 6381:6381 4.启动容器 docker-compose up -d 5.进入任一容器
输入yes后得到正确提示,此时redis-cluster搭建成功
|
要求:
The text was updated successfully, but these errors were encountered: