zookeeper搭建前提关闭防火墙
1.将zookeeper安装包拖至cd /opt/software文件夹下
2.解压zookeeper到cd /opt/module/文件夹下
-
cd /opt/software/
-
tar -zxvf apache-zookeeper-3.5.5-bin.tar.gz -C /opt/module/
3.在解压后的zookeeper文件夹下,创建log文件夹和data文件夹
-
cd /opt/module/apache-zookeeper-3.5.7-bin/
-
mkdir data
-
mkdir log
4.拷贝配置文件
-
cd /opt/module/apache-zookeeper-3.5.7-bin/conf/
-
cp zoo_sample.cfg zoo.cfg
5.配置文件更改
vi 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/module/apache-zookeeper-3.5.5-bin/data
-
dataLogDir=/opt/module/apache-zookeeper-3.5.5-bin/log
-
the port at which the clients will connect
-
clientPort=2181
-
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
-
server.0=192.168.1.100:2888:3888
-
server.1=192.168.1.101:2888:3888
-
server.2=192.168.1.102:2888:3888
6.创建服务器myid
在data目录下创建一个myid的文件,里面的值可以给个任意的值,但要和上述服务起server.x对应
-
cd /opt/module/apache-zookeeper-3.5.7-bin/data/
-
touch myid
7.集群拷贝
-
scp -r /opt/module/apache-zookeeper-3.5.5-bin root@hadoop101:/opt/module/apache-zookeeper-3.5.5-bin
-
scp -r /opt/module/apache-zookeeper-3.5.5-bin root@hadoop102:/opt/module/apache-zookeeper-3.5.5-bin
8.集群myid更改
进入每个节点进行更改myid的值
Hadoop101改为1
Hadoop102改为2
9.添加系统环境变量
vi /etc/profile
在编辑面板中添加如下内容
-
export ZOOKEEPER_HOME=/opt/module/apache-zookeeper-3.5.7-bin
-
export PATH=$PATH:$ZOOKEEPER_HOME/bin
然后
source /etc/profile
10.集群启动
进入到每个节点启动
-
cd /opt/module/apache-zookeeper-3.5.5-bin
-
zkServer.sh start
-
zkServer.sh status
启动zkServer.sh satus时,要先找到leader,leader可能在3个服务器之中的某一个里
所以现在每个服务器中启动一下找到leader,然后再启动另外的服务器
11.zkCli连接验证
zkCli.sh -server hadoop100:2181
然后jps查看进程