1.从http://mirror.bit.edu.cn/apache/zookeeper/上面找到你想要的版本,我找到的是
  http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
2.切换到自己想要的下载目录,下载压缩包
  cd /opt
  wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
3.解压缩
  tar -zxvf zookeeper-3.4.9.tar.gz
4.移动到/usr/local/
  mv zookeeper-3.4.9 /usr/local/
5.创建data及logs目录
   mkdir data
   mkdir logs
6.将zookeeper-3.4.9/conf目录下的zoo_sample.cfg拷贝备份一份,命名为zoo_sample_bak.cfg
  cp zoo_sample.cfg  zoo_sample_bak.cfg
7.把data及logs目录配置好
  vi zoo_sample.cfg
  dataDir=/usr/local/zookeeper-3.4.9/data
  dataLogDir=/usr/local/zookeeper-3.4.9/logs
8.在配置文件中添加服务节点
  server.1=192.168.0.136:2888:3888
9.在~/.bash_profile中添加环境变量,增加zookeeper配置
  vi ~/.bash_profile  添加如下两行
  export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.9
  export PATH=$PATH:$ZOOKEEPER_HOME/bin
  刷新环境变量
  source ~/.bash_profile
10.修改防火墙配置
  vi /etc/sysconfig/iptables
  添加如下3行
  -A INPUT -m state --state NEW -m tcp -p tcp --dport 2181 -j ACCEPT
  -A INPUT -m state --state NEW -m tcp -p tcp --dport 2888 -j ACCEPT
  -A INPUT -m state --state NEW -m tcp -p tcp --dport 3888 -j ACCEPT
  重启防火墙
  service iptables restart
11.进入/usr/local/zookeeper-3.4.9/bin 启动服务
  ./zkServer.sh start
  出现如下提示:
  Using config: /usr/local/zookeeper-3.4.9/bin/../conf/zoo.cfg
  grep: /usr/local/zookeeper-3.4.9/bin/../conf/zoo.cfg: No such file or directory
  mkdir: cannot create directory `': No such file or directory
  Starting zookeeper ... STARTED
12.把/usr/local/zookeeper-3.4.9/conf/zoo_sample.cfg 重命名为zoo.cfg
   mv zoo_sample.cfg zoo.cfg
13../zkServer.sh stop,然后重复步骤11,启动成功
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐