Docker安装Zookeeper,zookeeper集群
下载zookeeper:前置工作:centos7下Docker的安装部署1.从Docker Hub中获取zookeeper镜像:先查询:docker search zookeeper拉取对应的版本:docker pull zookeeper启动zookeeper:docker run --name myzookeeper -p 2181:2181 --restart always -d zooke
·
下载zookeeper:
前置工作:
centos7下Docker的安装部署
1.从Docker Hub中获取zookeeper镜像:
先查询:
docker search zookeeper
拉取对应的版本:
docker pull zookeeper
启动zookeeper:
docker run --name myzookeeper -p 2181:2181 --restart always -d zookeeper
说明:-p指定端口启动 :前的端口是linux虚拟机的端口 :后的端口是指docker容器的端口 2181:2181意思是指 把linux系统的2181端口映射到docker容器的2181端口
2.docker-compose.yml 方式安装zookeeper集群
version: '3.5'
services:
zoo1:
image: zookeeper
restart: always
hostname: zoo1
ports:
- 2181:2181
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
zoo2:
image: zookeeper
restart: always
hostname: zoo2
ports:
- 2182:2181
environment:
ZOO_MY_ID: 2
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
zoo3:
image: zookeeper
restart: always
hostname: zoo3
ports:
- 2183:2181
environment:
ZOO_MY_ID: 3
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
此为搭建 zookeeper 伪集群的文件,下载后可直接使用 docker-compose up -d 运行
该文件配置的 zookeeper 端口为 2181 2182 2183,可自行修改端口
更多推荐
已为社区贡献13条内容
所有评论(0)