centos7安装zookeeper-3.6.3

Posted 逃跑的沙丁鱼

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7安装zookeeper-3.6.3相关的知识,希望对你有一定的参考价值。

1 下载

https://www.apache.org/dyn/closer.lua/zookeeper/zookeeper-3.6.3/apache-zookeeper-3.6.3-bin.tar.gz

2 解压

[liucf@node1 softfile]$ tar -xzvf apache-zookeeper-3.6.3-bin.tar.gz -C /home/liucf/soft

3 重命名文件目录和配置文件

重命名目录

[liucf@node1 soft]$ mv apache-zookeeper-3.6.3-bin apache-zookeeper-3.6.3

重命名配置文件

[liucf@node1 conf]$ cp zoo_sample.cfg zoo.cfg 
[liucf@node1 conf]$ ll
total 16
-rw-r--r--. 1 liucf liucf  535 Apr  9 00:34 configuration.xsl
-rw-r--r--. 1 liucf liucf 3435 Apr  9 00:34 log4j.properties
-rw-r--r--. 1 liucf liucf 1148 May 12 21:26 zoo.cfg
-rw-r--r--. 1 liucf liucf 1148 Apr  9 00:34 zoo_sample.cfg
[liucf@node1 conf]$ 

4 修改配置文件配置

zoo.cfg 添加

server.1=node1:2888:3888
server.2=node2:2888:3888
server.3=node3:2888:3888

配置zookeeper数据文件存放目录

创建目录data

/home/liucf/soft/apache-zookeeper-3.6.3/data

[liucf@node1 apache-zookeeper-3.6.3]$ mkdir data

配置到zoo.cfg里

dataDir=/home/liucf/soft/apache-zookeeper-3.6.3/data

在目录/home/liucf/soft/apache-zookeeper-3.6.3/data下面创建myid文件并写入编号1

[liucf@node1 data]$ vim myid

1
~                                                                                                                     
~      

5 分发到其他机器

把apache-zookeeper-3.6.3从node1分发到node2,node3

[liucf@node1 soft]$ scp -r apache-zookeeper-3.6.3 liucf@node2:/home/liucf/soft
[liucf@node1 soft]$ scp -r apache-zookeeper-3.6.3 liucf@node3:/home/liucf/soft

6 修改node1,node2 上myid文件编号

这样保证了

node1->myid->1

node1->myid->3

node1->myid->3

[liucf@node2 data]$ vim myid 

2
~                                                                                                                                                                                                                
~                                                                                                                                                                                                                
~    
[liucf@node3 data]$ vim myid 

3
~                                                                                                                                                                                                                
~                                                                                                                                                                                                                
~    

7 配置ZOOKEEPER_HOME

node1,node2,node3都做

[liucf@node1 apache-zookeeper-3.6.3]$ sudo vim /etc/profile
export ZOOKEEPER_HOME=/home/liucf/soft/apache-zookeeper-3.6.3
PATH=$ZOOKEEPER_HOME/bin:$HADOOP_HOME/bin:$JAVA_HOME/bin:$PATH

8 启动zookeeper

[liucf@node1 data]$ zkServer.sh start
[liucf@node2 data]$ zkServer.sh start
[liucf@node3 data]$ zkServer.sh start

jps 

[liucf@node3 data]$ jps
48644 Jps
48599 QuorumPeerMain

9 编写同意启动脚本

#!/bin/bash
case $1 in
"start"){
	for i in node1 node2 node3 
	do
		echo -----------$i---------------
		ssh $i "source /etc/profile;/home/liucf/soft/apache-zookeeper-3.6.3/bin/zkServer.sh start"
	done		
};;
"stop"){
	for i in node1 node2 node3
	do
		echo -----------$i---------------
		ssh $i "source /etc/profile;/home/liucf/soft/apache-zookeeper-3.6.3/bin/zkServer.sh stop"
	done		
};;
"restart"){
	for i in node1 node2 node3
	do
		echo -----------$i---------------
		ssh $i "source /etc/profile;/home/liucf/soft/apache-zookeeper-3.6.3/bin/zkServer.sh stop;/home/liucf/soft/apache-zookeeper-3.6.3/bin/zkServer.sh start"
	done

};;
"status"){
	for i in node1 node2 node3
	do
		echo -----------$i---------------
		ssh $i "source /etc/profile;/home/liucf/soft/apache-zookeeper-3.6.3/bin/zkServer.sh status"
	done

};;
esac

 

以上是关于centos7安装zookeeper-3.6.3的主要内容,如果未能解决你的问题,请参考以下文章

zookeeper部署安装

zookeeper部署安装

8代cpu安装centos7

windows下安装zookeeper 步骤

单机安装zookeeper和kafka

Dubbo_zookeeper安装配置和服务器集群