hbase+zookeeper+kafka+docker部署及更改2181端口问题

标签:
it |
分类: 容器-docker |
同一台机器已经装了Hbase,hbase的默认hbase.zookeeper.property.clientPort占用2181端口。此时如果在想启动zookeeper,就不行。因为zookeeper的client
port也是默认2181.(详细默认端口情况可通过http://blog.csdn.net/haoxiaoyan/article/details/52884564查看)
hbase:
image:
hbase_service
hostname: hbase
container_name:
hbase
restart: always
environment:
-
DOCKER_IP=$DOCKER_IP
dns:
-
127.0.0.1
ports:
- 60000:60000
- 60010:60010
- 60020:60020
- 60030:60030
- 2181:2181
kafka:
image:
wurstmeister/kafka
hostname: kafka
container_name:
kafka
restart: always
environment:
-
DOCKER_IP=$DOCKER_IP
#-
HOST_IP=localhost
-
KAFKA_ADVERTISED_PORT=9092
-
KAFKA_BROKER_ID=1
-
KAFKA_ADVERTISED_HOST_NAME=localhost
# -
KAFKA_CREATE_TOPICS="test:1:1"
-
KAFKA_ZOOKEEPER_CONNECT=zookeeper:2182
-
KAFKA_AUTO_CREATE_TOPICS_ENABLE=true
links:
- zookeeper
ports:
- 9092:9092
zookeeper:
image:
wurstmeister/zookeeper
hostname: zookeeper
container_name:
zookeeper
restart: always
environment:
-
DOCKER_IP=$DOCKER_IP
# - clientPort=2182
volumes:
-
./zoo.cfg:/opt/zookeeper-3.4.9/conf/zoo.cfg
ports:
- 2182:2182
这样就需要更改其默认的端口。有两种方法:1、通过docker-compose.xml进行环境变量配置;2、通过在本地复制一个zookeeper的启动配置文件zoo.cfg,然后更改其内容2181端口为2182,然后在通过docker-compose文件进行挂载映射代替Docker内部的配置文件。
1、通过docker pull wurstmeister/kafka 和 docker
pull wurstmeister/zookeeper
对这两个docker image进行在线拉取。
2、配置docker-compose.xml文件
version: '2'
services:
3、zoo.cfg文件
root@no-volume# cat zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass
between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is
just
# example sakes.
dataDir=/opt/zookeeper-3.4.9/data
# the port at which the clients will connect
clientPort=2182
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of
the
# administrator guide before turning on autopurge.
#
#
http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
autopurge.purgeInterval=1
启动成功后截图: