前提:关闭防火墙
(1)查看防火墙是否关闭
systemctl status firewalld
(2)关闭防火墙
systemctl stop firewalld
(3)设置防火墙开机不启动
systemctl disable firewalld
1、将zookeeper安装包拉到/opt/software/文件夹中 安装包版本:apache-zookeeper-3.5.7-bin.tar.gz2、解压
cd /opt/module/
tar -zxvf apache-zookeeper-3.5.7-bin.tar.gz
3、创建数据文件和目录文件在zookeeper的跟目录下创建两个文件夹data和log
cd /opt/module/apache-zookeeper-3.5.7-bin/
mkdir data
mkdir log
4、拷贝配置文件cd /opt/module/apache-zookeeper-3.5.5-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.7-bin/data
dataLogDir=/opt/module/apache-zookeeper-3.5.7-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
最后所增加的是根据自己的主机名与IP地址相对应
6、创建服务器myid在data目录下创建一个myid的文件,里面的值可以给个任意的值,但要和上述服务起server.x对应
cd /opt/module/apache-zookeeper-3.5.5-bin/data/
touch myid
7、集群拷贝scp -r /opt/module/apache-zookeeper-3.5.7-bin root@hadoop101:/opt/module/apache-zookeeper-3.5.5-bin
scp -r /opt/module/apache-zookeeper-3.5.7-bin root@hadoop102:/opt/module/apache-zookeeper-3.5.5-bin
8、集群myid更改进入到每个节点,修改myid值
集群系统环境变量添加:vi /etc/profile
export ZOOKEEPER_HOME=/opt/module/apache-zookeeper-3.5.7-bin
export PATH=$PATH:$ZOOKEEPER_HOME/bin
保存系统环境变量:source /etc/profile
关闭集群防火墙
9、集群启动进入到每个节点启动(在100、101、102 里都要启动)
cd /opt/module/apache-zookeeper-3.5.7-bin
zkServer.sh start
zkServer.sh status
如若在100启动时报错那么就先在101、102上启动再回头启动100就可以了
在启动之后在最下面会有一个leader和两个follower就是正确的
这是在100上先运行就会报错
在101上面运行就不会报错
102上面运行也不会报错
当在101、102上运行完再运行100就可以了
10、zkCli连接验证
zkCli.sh -server hadoop100:2181
输入这个命令后它会一直运行,按Ctrl+Z停止运行
用jps查看出现ZooKeeperMain进程
出现QuorumPeerMain则说明zookeeper启动成功
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)