先检查防火墙是否关闭
1.防火墙状态的查看 systemctl status firewalld 2. 关闭防火墙 systemctl stop firewalld 3. 开机防火墙不启动 systemctl disable firewalld1.将Zookeeper拉到下面文件下 注:版本不同名字不同 2.将Zookeeper解压到下列文件下
cd /opt/software/ tar -zxvf 安装包名 -C /opt/module/3、在下列文件下创建log文件夹和data文件夹
cd /opt/module/apache-zookeeper-3.5.7-bin/ mkdir data mkdir log4、 拷贝配置文件
cd /opt/module/apache-zookeeper-3.5.7-bin/conf/ cp zoo_sample.cfg zoo.cfg
对拷贝后的文件进行更改
vi zoo.cfg
将如下内容添加到编辑面板中 注 :最后三行和自己主机的ip地址对应
# 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:38885.创建服务器myid
在data目录下创建一个myid文件,并编辑在里面输入0
cd /opt/module/apache-zookeeper-3.5.7-bin/data/ touch myid6.集群拷贝
scp -r /opt/module/apache-zookeeper-3.5.7-bin root@hadoop101:/opt/module/apache-zookeeper-3.5.7-bin scp -r /opt/module/apache-zookeeper-3.5.7-bin root@hadoop102:/opt/module/apache-zookeeper-3.5.7-bin7.集群myid更改
注:将hadoop100的myid改为0
将hadoop101的myid改为1
将hadoop102的myid改为2
cd /opt/module/apache-zookeeper-3.5.7-bin/data/ touch myid8.添加系统环境变量
vi /etc/profile
在编辑面板添加如下内容
export ZOOKEEPER_HOME=/opt/module/apache-zookeeper-3.5.7-bin export PATH=$PATH:$ZOOKEEPER_HOME/bin9.集群启动
cd /opt/module/apache-zookeeper-3.5.7-bin
现在101启动zkServer.sh start
再在102启动zkServer.sh start
最后在100启动zkServer.sh start
zkServer.sh status
10.连接验证
zkCli.sh -server hadoop100:2181
按Ctrl+Z停止运行
用jsp查看是否成功
出现QuorumPeerMain就是成功了



