docker镜像创建redis5.0.3容器集群
拉取redis5.0.3镜像
# docker pull daocloud.io/library/redis:5.0.3
[root@localhost ~]# docker pull daocloud.io/library/redis:5.0.
5.0.: Pulling from library/redis
5e6ec7f28fb7: Pull complete
7fdf7fb3ec49: Pull complete
4bd5dbe7bfa7: Pull complete
71f540684935: Pull complete
8c6dbecedd0f: Pull complete
9d190b6684fc: Pull complete
Digest: sha256:e1dc07bf1465661b90b18c1c766c00f733254bf64fcf2ad7a335b2fc1fa31870
Status: Downloaded newer image for daocloud.io/library/redis:5.0.
[root@localhost ~]#
[root@localhost ~]# docker images
centos latest 9f38484d220f weeks ago 202MB
daocloud.io/library/redis 5.0. 82629e941a38 months ago 95MB
ubuntu 16.04 7e87e2b3bf7a months ago 117MB
mysql latest 102816b1ee7d months ago 486MB
给redis5.0.3镜像打标签
# docker tag 82629e941a38 redis
删除源镜像标签
# docker rmi daocloud.io/library/redis:5.0.3
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 9f38484d220f weeks ago 202MB
daocloud.io/library/redis 5.0. 82629e941a38 months ago 95MB
redis latest 82629e941a38 months ago 95MB
ubuntu 16.04 7e87e2b3bf7a months ago 117MB
mysql latest 102816b1ee7d months ago 486MB
[root@localhost ~]#
[root@localhost ~]# docker rmi daocloud.io/library/redis:5.0.
Untagged: daocloud.io/library/redis:5.0.
Untagged: daocloud.io/library/redis@sha256:e1dc07bf1465661b90b18c1c766c00f733254bf64fcf2ad7a335b2fc1fa31870
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 9f38484d220f weeks ago 202MB
redis latest 82629e941a38 months ago 95MB
ubuntu 16.04 7e87e2b3bf7a months ago 117MB
mysql latest 102816b1ee7d months ago 486MB
创建6个redis容器集群
以redis7000为例:
# docker run --name redis7000 -p 7000:6379 -d redis redis-server --requirepass "123456" --appendonly yes --protected-mode no --cluster-enabled yes
说明:
redis的密码为123456
Redis持久化功能已启动
保护模式已经关闭
集群模式已开启
[root@localhost ~]# docker run --name redis7000 -p : -d redis redis-server --requirepass "" --appendonly yes --protected-mode no --cluster-enabled yes
d8b4eb2b5459b2eaceca1d957b9422123ac906c41a5bf8d23bd65545dda33c77
[root@localhost ~]# docker run --name redis7001 -p : -d redis redis-server --requirepass "" --appendonly yes --protected-mode no --cluster-enabled yes
163c705af09706b38e2f327febdecbf9c37d3b1528f7d4bfb667eb257d3a0be7
[root@localhost ~]# docker run --name redis7002 -p : -d redis redis-server --requirepass "" --appendonly yes --protected-mode no --cluster-enabled yes
e4604f44be05811a9dbcf0af9f3f0b6db976dde9c8c2772d8773e6979fbb7284
[root@localhost ~]# docker run --name redis7003 -p : -d redis redis-server --requirepass "" --appendonly yes --protected-mode no --cluster-enabled yes
a76f43511bb20945695943d009041b2f8398b1e3a5217524edfa34589ad91311
[root@localhost ~]# docker run --name redis7004 -p : -d redis redis-server --requirepass "" --appendonly yes --protected-mode no --cluster-enabled yes
9eace890c3a44314a01ef58fc0d09086f752be95300165868435b8dfbb1f61b2
[root@localhost ~]# docker run --name redis7005 -p : -d redis redis-server --requirepass "" --appendonly yes --protected-mode no --cluster-enabled yes
e91e99f1c31f2deab8f87f0af75625087a2913ff382ef15e62bce2b8d472e60f
[root@localhost ~]#
查看容器状态
# docker ps
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e91e99f1c31f redis "docker-entrypoint.s…" seconds ago Up seconds 0.0.0.0:->/tcp redis7005
9eace890c3a4 redis "docker-entrypoint.s…" seconds ago Up seconds 0.0.0.0:->/tcp redis7004
a76f43511bb2 redis "docker-entrypoint.s…" seconds ago Up seconds 0.0.0.0:->/tcp redis7003
e4604f44be05 redis "docker-entrypoint.s…" seconds ago Up seconds 0.0.0.0:->/tcp redis7002
163c705af097 redis "docker-entrypoint.s…" seconds ago Up seconds 0.0.0.0:->/tcp redis7001
d8b4eb2b5459 redis "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:->/tcp redis7000
查看6个redis容器的IP
# docker inspect redis7000 | grep IPAddress
[root@localhost ~]# docker inspect redis7000 | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.6",
"IPAddress": "172.17.0.6",
[root@localhost ~]#
[root@localhost ~]# docker inspect redis7001 | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.8",
"IPAddress": "172.17.0.8",
[root@localhost ~]#
[root@localhost ~]# docker inspect redis7002 | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.9",
"IPAddress": "172.17.0.9",
[root@localhost ~]#
[root@localhost ~]# docker inspect redis7003 | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.10",
"IPAddress": "172.17.0.10",
[root@localhost ~]# docker inspect redis7004 | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.11",
"IPAddress": "172.17.0.11",
[root@localhost ~]#
[root@localhost ~]# docker inspect redis7005 | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.12",
"IPAddress": "172.17.0.12",
[root@localhost ~]#
进入redis7000容器
# docker exec -it redis7000 bash
客户端交互
[root@localhost ~]# docker exec -it redis7000 bash
root@d8b4eb2b5459:/data#
root@d8b4eb2b5459:/data# redis-cli
127.0.0.1:> exit
root@d8b4eb2b5459:/data#
root@d8b4eb2b5459:/data# redis-cli -h 172.17.0.6 -p
172.17.0.6:>
172.17.0.6:> exit
root@d8b4eb2b5459:/data#
root@d8b4eb2b5459:/data# redis-cli -h 172.17.0.8 -p
172.17.0.8:>
172.17.0.8:> exit
root@d8b4eb2b5459:/data#
集群创建
# redis-cli -a 123456 --cluster create 172.17.0.6:6379 172.17.0.8:6379 172.17.0.9:6379 172.17.0.10:6379 172.17.0.11:6379 172.17.0.12:6379 --cluster-replicas 1
root@d8b4eb2b5459:/data#
root@d8b4eb2b5459:/data# redis-cli -a --cluster create 172.17.0.6: 172.17.0.8: 172.17.0.9: 172.17.0.10: 172.17.0.11: 172.17.0.12: --cluster-replicas
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing hash slots allocation on nodes...
Master[] -> Slots -
Master[] -> Slots -
Master[] -> Slots -
Adding replica 172.17.0.10: to 172.17.0.6:
Adding replica 172.17.0.11: to 172.17.0.8:
Adding replica 172.17.0.12: to 172.17.0.9:
M: 19519487a7db6f2fa5fda5f6e1807befe75665e5 172.17.0.6:
slots:[-] ( slots) master
M: f6adb618124c791db4e31347982d086cd8b58646 172.17.0.8:
slots:[-] ( slots) master
M: 1b5b85bd1f068a656b88e0e396f7da8bc0242ebf 172.17.0.9:
slots:[-] ( slots) master
S: ca40bc6c36c7c14a7e91b04bec51bc6bb75eebea 172.17.0.10:
replicates 19519487a7db6f2fa5fda5f6e1807befe75665e5
S: b25431b20840b04fc2262d246482981a1a49c1cf 172.17.0.11:
replicates f6adb618124c791db4e31347982d086cd8b58646
S: 53515a889f77bbe553c8fb664983cded5d767826 172.17.0.12:
replicates 1b5b85bd1f068a656b88e0e396f7da8bc0242ebf
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join
...
>>> Performing Cluster Check (using node 172.17.0.6:)
M: 19519487a7db6f2fa5fda5f6e1807befe75665e5 172.17.0.6:
slots:[-] ( slots) master
additional replica(s)
M: 1b5b85bd1f068a656b88e0e396f7da8bc0242ebf 172.17.0.9:
slots:[-] ( slots) master
additional replica(s)
S: b25431b20840b04fc2262d246482981a1a49c1cf 172.17.0.11:
slots: ( slots) slave
replicates f6adb618124c791db4e31347982d086cd8b58646
S: 53515a889f77bbe553c8fb664983cded5d767826 172.17.0.12:
slots: ( slots) slave
replicates 1b5b85bd1f068a656b88e0e396f7da8bc0242ebf
M: f6adb618124c791db4e31347982d086cd8b58646 172.17.0.8:
slots:[-] ( slots) master
additional replica(s)
S: ca40bc6c36c7c14a7e91b04bec51bc6bb75eebea 172.17.0.10:
slots: ( slots) slave
replicates 19519487a7db6f2fa5fda5f6e1807befe75665e5
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All slots covered.
root@d8b4eb2b5459:/data#
end
docker镜像创建redis5.0.3容器集群的更多相关文章
- Docker&Kubernetes沙龙干货集锦:容器集群管理利器kubernetes详谈-CSDN.NET
Docker&Kubernetes沙龙干货集锦:容器集群管理利器kubernetes详谈-CSDN.NET undefined Package - crawler undefined 科学网- ...
- Redis5.0.8 Cluster集群部署
目录 一.Redis Cluster简介 二.部署 三.创建主库 一.Redis Cluster简介 Redis Cluster集群是一种去中心化的高可用服务,其内置的sentinel功能可以提供高可 ...
- 使用Docker方式创建3节点的Etcd集群
一.简要说明 二.运行容器 三.验证集群 四.运行截图 五.参考链接 一.简要说明 参考etcd官网文档, 在node1.node2.node3三个节点上,分别运行etcd容器,创建etcd集 ...
- Docker:Swarm + Stack 一站式部署容器集群
参考1 参考2 1.注意docker的版本,yum默认安装的版本比较低,可能出现 unsupported Compose file version: 3.7 docker版本升级 2.docker-c ...
- 容器、容器集群管理平台与 Kubernetes 技术漫谈
原文:https://www.kubernetes.org.cn/4786.html 我们为什么使用容器? 我们为什么使用虚拟机(云主机)? 为什么使用物理机? 这一系列的问题并没有一个统一的标准答案 ...
- Docker应用:Kubernetes(容器集群)
阅读目录: Docker应用:Hello World Docker应用:Docker-compose(容器编排) Docker应用:Kubernetes(容器集群) 前言: 终于出第三篇了,上个月就已 ...
- Docker容器集群管理之Swarm
Docker容器集群管理主流方案 Swarm Docker公司自研发的集群管理系统. Kubernetes Google开源的一个容器集群管理系统,用于自动化部署.扩展和管理容器应用.也称为K8S ...
- 测试环境docker化—容器集群编排实践
本文来自网易云社区 作者:孙婷婷 背景 在前文<测试环境docker化-基于ndp部署模式的docker基础镜像制作>中已经详述了docker镜像制作及模块部署的过程,按照上述做法已可以搭 ...
- Win10上的Docker应用:Kubernetes(容器集群)
阅读目录: Docker应用:Hello World Docker应用:Docker-compose(容器编排) Docker应用:Kubernetes(容器集群) 前言: 终于出第三篇了,上个月就已 ...
随机推荐
- LeetCode - Find K Closest Elements
Given a sorted array, two integers k and x, find the k closest elements to x in the array. The resul ...
- 【BZOJ4553】【TJOI2016】【HEOI2016】序列
cdq和整体二分之间的关系好迷啊 原题: 佳媛姐姐过生日的时候,她的小伙伴从某宝上买了一个有趣的玩具送给他.玩具上有一个数列,数列中某些项的值 可能会变化,但同一个时刻最多只有一个值发生变化.现在佳媛 ...
- LOJ2135 「ZJOI2015」幻想乡战略游戏
题意 题目描述 傲娇少女幽香正在玩一个非常有趣的战略类游戏,本来这个游戏的地图其实还不算太大,幽香还能管得过来,但是不知道为什么现在的网游厂商把游戏的地图越做越大,以至于幽香一眼根本看不过来,更别说和 ...
- LG4213 【【模板】杜教筛(Sum)】
sum\(\mu\)求法 设 \[S(n)=\sum_{i=1}^n \mu(i)\] 回顾公式 \[\sum_{d|n}\mu(d)=[n=1]\] 对\(n\)求和 \[\sum_{i=1}^n\ ...
- 每天进步一点点-Java IO操作-Java Serializable(对象序列化)的理解和总结
往硬盘文件里写数据 序列化:序列化是将对象转换为容易传输的格式的过程.例如,可以序列化一个对象,然后使用 HTTP 通过 Internet 在客户端和服务器之间传输该对象.在另一端,反序列化将从该流重 ...
- sudo权限的设置
什么是sudo,为什么要sudo呢?就我个人愚见普通用户sudo之后拥有root用户的所有权限,其优点在于,虽然该用户拥有root权限,但他却不需要知道root用户密码,需要输入的是他本身的密码. 那 ...
- Android学习--------实现增删改查数据库操作以及实现相似微信好友对话管理操作
版权声明:本文为博主原创文章,转载请注明原文地址.谢谢~ https://blog.csdn.net/u011250851/article/details/26169409 近期的一个实验用到东西挺多 ...
- C#中Socket关闭 Close、Dispose、Shutdown、Disconnect
An answer on StackOverflow made me think I have finally reached some glimpse of an understanding. Th ...
- Bartender 使用 Excel xlsx 数据库时出现 0x800A0E7A
Bartender 使用 Excel 数据库时出现 0x800A0E7A 这是因为没有装 数据库驱动的原因. 安装微软的驱动就可以. 注意是安装 32 位的驱动. https://www.micros ...
- DefinePlugin插件
这个插件允许你创建全局常量用于编译时解析.如果设置mode:"production",webpack默认会设置"process.env.NODE_ENV": J ...