linux安装zookeeper真集群

/ Linux服务安装搭建 / 没有评论 / 1002浏览

环境

ubuntu 16.04

java 1.8

机器1:192.168.0.169

机器2:192.168.0.170

机器3:192.168.0.166

获取源码

下载

官网:https://zookeeper.apache.org/releases.html#download

解压

# wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz
# tar xf zookeeper-3.4.13.tar.gz
# mv zookeeper-3.4.13 /usr/local/
# mv /usr/local/zookeeper-3.4.13 /usr/local/zookeeper

第一台机器配置zookeeper

创建数据目录

root@hadoop-master:/usr/local/zookeeper# mkdir data

修改配置zoo.cfg

root@hadoop-master:/usr/local/zookeeper/conf# cp zoo_sample.cfg zoo.cfg

在那个节点内就将那个节点的ip改为0.0.0.0

在那个节点内就将那个节点的ip改为0.0.0.0

root@hadoop-master:/usr/local/zookeeper/conf# cat zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
dataDir=/var/data/zookeeper
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
···
server.1=0.0.0.0:2888:3888
server.2=192.168.0.170:2888:3888
server.3=192.168.0.166:2888:3888

创建myid文件

root@hadoop-master:/usr/local/zookeeper/data# touch myid
root@hadoop-master:/usr/local/zookeeper/data# echo "1">>myid

拷贝至node节点

root@hadoop-master:/usr/local/zookeeper/data# scp -r /usr/local/zookeeper root@192.168.0.170:/usr/local/

其他机器节点配置

修改配置zoo.cfg

在那个节点内就将那个节点的ip改为0.0.0.0

vim zoo.cfg

# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=192.168.0.169:2888:3888
server.2=0.0.0.0:2888:3888
server.3=192.168.0.166:2888:3888

myid值为2

依次类推

root@hadoop-slave1:~# cd /usr/local/zookeeper/data
root@hadoop-slave1:/usr/local/zookeeper/data# echo "2">myid

防火墙

开放 or 卸载掉

过程 略

启动

所有节点都需要启动

root@hadoop-master:/usr/local/zookeeper/data# /usr/local/zookeeper/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

状态检查

# /usr/local/zookeeper/bin/zkServer.sh status