安装1.修改操作系统/etc/hosts,添加如下zookeeper servers192.168.104.102 zookeeper-01 2. 官网下载地址:http://mirrors.hust.edu.cn/apache/zookeeper/$ wget http://mirrors.hust.edu.cn/apache/zookeeper/ 3. 解压$ tar -zxvf zookeeper-3.4.6.tar.gz 4. 创建数据和日志文件夹$ cd /usr/local/zookeeper-3.4.6 $ mkdir data $ mkdir logs 5. 将zookeeper目录下conf下的zoo_sample.cfg拷贝一份,命名为zoo.cfg$ cp zoo_sample.cfg zoo.cfg 6. 修改zoo.cfg配置文件$ vi zoo.cfg tickTime=2000 initLimit=10 syncLimit=5 dataDir=/usr/local/zookeeper/data dataLogDir=/usr/local/zookeeper/logs clientPort=2181 //下面的ip也可以用hosts别名zookeeper-01 server.1=192.168.104.156:2888:3888 server.2=192.168.104.157:2888:3888 //其中2888是zookeeper服务之间通信的端口 //3888是zookeeper与其他应用程序通信端口 zoo.cfg参数说明
7. 在上面创建的/home/www/zookeeper-3.4.8/data下创建myid文件,并在其中写入对应的ip的机器的编号(上面的server.1)中的1$ vi myid 1 8. 配置环境变量,进入root(也可以是其他用户)用户目录下,编辑.bash_profile,并使修改生效$ cd ~ $ vi .bash_profile #zookeeper env export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.8 export PATH=$ZOOKEEPER_HOME/bin:$PATH $ source .bash_profile 9. 开启防火墙,开启上述几个端口$ chkconfig iptables on $ service iptables start $ vi /etc/sysconfig/iptables -A FORWARD -j REJECT --reject-with icmp-host-prohibited RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT -A FORWARD -j REJECT --reject-with icmp-host-prohibited RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 2181 -j ACCEPT -A FORWARD -j REJECT --reject-with icmp-host-prohibited RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 2888 -j ACCEPT -A FORWARD -j REJECT --reject-with icmp-host-prohibited RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3888 -j ACCEPT $ service iptables restart $ service iptables status
10 启动zookeeper测试$ ./zkServer.sh start $ jps //查看进程 //产看状态 $ ./zkServer.sh status //停止服务 $ ./zkServer.sh stop 11 设置开机启动$ vi /etc/rc.local su - root -c '/usr/local/jie/zookeeper-3.4.8/bin/./zkServer.sh start' (责任编辑:IT) |