1, the installation environment
The installation environment
Linux: CentOS7
Jdk: 1.7 or later (here java1.8)
Environmental reasons :
ZooKeeper is in java can run on windows, linux environment. You need to install jdk.
2, mounting step
Step 1: Install jdk (premise) - Completed skipped
refer to my java8 installation program 1: https://blog.csdn.net/rao991207823/article/details/102923314
or scheme 2: HTTPS: // Blog. csdn.net/rao991207823/article/details/102923974
Step two: the zookeeper's archive uploaded to the linux system. - tools used Xshell, of course, also be used other
third step: decompresses the compressed package, for example: zookeeper-3.4.6.tar.gz
tar -zxvf zookeeper-3.4.6.tar.gz
Screenshot as shown:
Step 4: Enter zookeeper-3.4.6 directory, create a data folder.
Step five: re-entering the conf directory, zoo_sample.cfg renamed zoo.cfg (I am here using the same name copy mode)
renamed
mv zoo_sample.cfg zoo.cfg
Copy Rename
cp -a zoo_sample.cfg zoo.cfg
Step Six: zoo.cfg modified file data attributes: dataDir = / root / zookeeper-3.4.6 / data (data path to the folder)
vim zoo.cfg
As shown in the screenshot:
Step Seven: Start zookeeper, executed in the bin directory under the directory zookeeper
./zkServer.sh start
关闭:[root@localhost bin]# ./zkServer.sh stop
查看状态:[root@localhost bin]# ./zkServer.sh status
注意:需要关闭防火墙,或者开放防火墙端口:2181(亦或者是自己设定其他端口)。
关闭防火墙
CentOS6.5 :
临时关闭:service iptables stop
永久关闭防火墙:chkconfig iptables off (修改配置开机不自启)
CentOS7:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
其他方案----添加开启访问端口
添加开放端口
firewall-cmd --zone=public --add-port=2181/tcp --permanent
命令含义:
–zone #作用域
–add-port=2181/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
重启生效:
firewall-cmd --reload
查看
firewall-cmd --zone= public --query-port=80/tcp
查看所有开放端口:
firewall-cmd --list-port
关闭开放的端口(删除):
firewall-cmd --zone= public --remove-port=80/tcp --permanent