@w1992wishes
2018-07-07T14:13:18.000000Z
字数 1527
阅读 1111
软件安装
https://archive.apache.org/dist/zookeeper/
选择需要下载的版本,下载以 tar.gz 结尾的文件。
可以安装 VMware tools ,然后手动拖到虚拟机中,安装方法参考下面博客:
也可以用 WinSCP 工具,或者直接在 Ubuntu 系统页面下载。
tar -xzf zookeeper-3.4.6.tar.gz -C /usr/local/services
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/services/zookeeper-3.4.6/data
dataLogDir=/usr/local/services/zookeeper-3.4.6/logs
clientPort=2181
/etc/profile文件里存放的是系统的环境变量,对所有用户都有效果,要对其更改的话,必须要在root用户权限下才能进行。
export ZOOKEEPER_HOME=/usr/local/services/zookeeper-3.4.6/
export PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH
source /etc/profile
/usr/local/services/zookeeper-3.4.6/bin$ zkServer.sh start
JMX enabled by default
Using config: /usr/local/services/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
/usr/local/services/zookeeper-3.4.6/bin$ zkServer.sh status
JMX enabled by default
Using config: /usr/local/services/zookeeper-3.4.6/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
发现根本没有真正启动成功,查看当前目录下的输出 zookeeper.out
nohup: failed to run command ‘java’: No such file or directory
原来 zookeeper 需要 java ,所以先安装 jdk,安装后又报了另一个错:
Invalid config, exiting abnormally
说明配置文件有误,网上查找资料,在官网看到这样一句话:
Change the value of dataDir to specify an existing (empty to start with) directory.
所以需要先将 dataDir 和 dataLogDir 指向的文件夹创建出来。
到此问题解决。
/usr/local/services/zookeeper-3.4.6$ zkServer.sh status
JMX enabled by default
Using config: /usr/local/services/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: standalone