Docker安装ZooKeeper
1.使用Docker安装ZooKeeper,首先下载它的Docker镜像;
docker pull zookeeper
2.创建好ZooKeeper的配置文件目录(-p 递归创建),并切换到该目录创建配置文件zoo.cfg;
mkdir /Users/ux/Applications/docker/zookeeper/conf/ -p
3.cd /Users/ux/Applications/docker/zookeeper/conf/
touch zoo.cfg
配置文件zoo.cfg内容如下,直接使用VIM编辑即可;
### 设置心跳时间,单位毫秒
tickTime=2000
### 存储内存数据库快照的文件夹
dataDir=/Users/ux/Applications/docker/zookeeper/tmp/zookeeper
### 监听客户端连接的端口
clientPort=2181
4.运行ZooKeeper容器。
docker run -d --name zookeeper -p 2181:2181 -p 2888:2888 -p 9008:8080 zookeeper
下面的命令安装会出错,应该是-v指定配置文件路径不对导致,mac下docker下zookeeper的conf路径是:/apache-zookeeper-3.7.0-bin/conf(改为/apache-zookeeper-3.7.0-bin/conf依旧无法启动,原因未知):
docker run -d --name zookeeper -p 2181:2181 -p 2888:2888 -p 3888:3888 -p 9008:8080 zookeeper -v /Users/ux/Applications/docker/zookeeper/conf/zoo.cfg:/conf/zoo.cfg
dockerHub上的:
This image includes EXPOSE 2181 2888 3888 8080
(the zookeeper client port, follower port, election port, AdminServer port respectively),
so standard container linking will make it automatically available to the linked containers.
Since the Zookeeper "fails fast" it's better to always restart it.
5.启动报audit is disabled日志:
后续搜索发现是因为zookeeper新版本启动的过程中,zookeeper新增的审核日志是默认关闭,
所以控制台输出ZooKeeper audit is disabled
标准的修改方式应该是在zookeeper的配置文件
zoo.cfg新增一行audit.enable=true即可
6.容器内无法使用vim命令:
apt-get update
apt-get install vim