zookeeper-02 部署详解大数据

 

1. 主机规划

主机名称

外网IP【外部访问】

内网IP

操作系统

备注

安装软件

docker01

10.0.0.11

172.16.1.11

CentOS 7.2

 

zookeeper-3.4.5【集群】

docker02

10.0.0.12

172.16.1.12

CentOS 7.2

 

zookeeper-3.4.5【集群】

docker03

10.0.0.13

172.16.1.13

CentOS 7.2

 

zookeeper-3.4.5【集群】

docker04

10.0.0.14

172.16.1.14

CentOS 7.2

 

zookeeper-3.4.5【单独/伪集群】

 

其中zoo.cfg 的连接数如下: 
maxClientCnxns=1000 
 
具体就不在每个配置文件中写了 
如果使用,请加上这个配置 

  

 

 

2. Jdk【java8】

2.1.  软件安装

 1 [[email protected] tools]# pwd 
 2 /root/tools 
 3 [[email protected] tools]# tar xf jdk-8u162-linux-x64.tar.gz  
 4 [[email protected] tools]# ll 
 5 total 201392 
 6 drwxr-xr-x 8   10  143      4096 Dec 20 13:27 jdk1.8.0_162 
 7 -rw-r--r-- 1 root root 189815615 Mar 12 16:47 jdk-8u162-linux-x64.tar.gz 
 8 -rw-r--r-- 1 root root  16402010 May 14 00:26 zookeeper-3.4.5.tar.gz 
 9 [[email protected] tools]# mv jdk1.8.0_162/ /app/ 
10 [[email protected] tools]# cd /app/ 
11 [[email protected] app]# ll 
12 total 8 
13 drwxr-xr-x  8   10   143 4096 Dec 20 13:27 jdk1.8.0_162 
14 [[email protected] app]# ln -s jdk1.8.0_162/ jdk 
15 [[email protected] app]# ll 
16 total 8 
17 lrwxrwxrwx  1 root root    13 May 16 23:19 jdk -> jdk1.8.0_162/ 
18 drwxr-xr-x  8   10   143 4096 Dec 20 13:27 jdk1.8.0_162

 

2.2.  环境变量

 1 [[email protected] ~]$ pwd 
 2 /app 
 3 [[email protected] ~]$ ll -d jdk*  # 可以根据实际情况选择jdk版本,其中jdk1.8 可以兼容 jdk1.7    
 4 lrwxrwxrwx 1 yun yun   11 Mar 15 14:58 jdk -> jdk1.7.0_71 
 5 drwxr-xr-x 8 yun yun 4096 Sep 27  2014 jdk1.7.0_71 
 6 drwxr-xr-x 8 yun yun 4096 Dec 20 13:27 jdk1.8.0_162 
 7 [[email protected] profile.d]$ pwd 
 8 /etc/profile.d 
 9 [[email protected] profile.d]$ cat jdk.sh # java环境变量    
10 export JAVA_HOME=/app/jdk 
11 export JRE_HOME=/app/jdk/jre 
12 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH 
13 export PATH=$JAVA_HOME/bin:$PATH

 

3. zookeeper【单机部署】

3.1.  配置信息

 1 # 路径 
 2 [[email protected] app]# pwd 
 3 /app 
 4 [[email protected] app]# ll 
 5 total 4 
 6 lrwxrwxrwx  1 root root    13 May 26 06:55 jdk -> jdk1.8.0_112/ 
 7 drwxr-xr-x  8   10   143  255 Sep 23  2016 jdk1.8.0_112 
 8 drwxr-xr-x 10  501 games 4096 Nov  5  2012 zookeeper-3.4.5 
 9  
10 # 配置文件 
11 [[email protected] conf]# pwd 
12 /app/zookeeper-3.4.5/conf 
13 [[email protected] conf]# cp -a zoo_sample.cfg zoo.cfg 
14 [[email protected] conf]# vim zoo.cfg  
15 # The number of milliseconds of each tick #心跳间隔时间,zookeeper中使用的基本时间单位,毫秒值。每隔2秒发送一个心跳 
16 tickTime=2000 
17 # The number of ticks that the initial  
18 # synchronization phase can take 
19 initLimit=10 
20 # The number of ticks that can pass between  
21 # sending a request and getting an acknowledgement 
22 syncLimit=5 
23 # the directory where the snapshot is stored. 
24 # do not use /tmp for storage, /tmp here is just  
25 # example sakes.  数据目录 单独目录存放 
26 dataDir=/app/bigdata/zookeeper/data 
27 # the port at which the clients will connect 
28 clientPort=2181 
29 # 
30 # Be sure to read the maintenance section of the  
31 # administrator guide before turning on autopurge. 
32 # 
33 # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance 
34 # 
35 # The number of snapshots to retain in dataDir 
36 #autopurge.snapRetainCount=3 
37 # Purge task interval in hours 
38 # Set to "0" to disable auto purge feature 
39 #autopurge.purgeInterval=1

 

3.2.  服务启动与停止

 1 # 启动服务 
 2 [[email protected] bin]# pwd 
 3 /app/zookeeper-3.4.5/bin 
 4 [[email protected] bin]# ./zkServer.sh start 
 5 JMX enabled by default 
 6 Using config: /app/zookeeper-3.4.5/bin/../conf/zoo.cfg 
 7 Starting zookeeper ... STARTED 
 8 [[email protected] bin]#  
 9 [[email protected] bin]# ./zkServer.sh status 
10 JMX enabled by default 
11 Using config: /app/zookeeper-3.4.5/bin/../conf/zoo.cfg 
12 Mode: standalone 
13  
14 # 停止服务 
15 [[email protected] bin]# ./zkServer.sh stop 
16 JMX enabled by default 
17 Using config: /app/zookeeper-3.4.5/bin/../conf/zoo.cfg 
18 Stopping zookeeper ... STOPPED 
19 [[email protected] bin]# ./zkServer.sh status 
20 JMX enabled by default 
21 Using config: /app/zookeeper-3.4.5/bin/../conf/zoo.cfg 
22 Error contacting service. It is probably not running.

 

4. zookeeper【单机伪集群】

一台机器,在该台机器上运行多个ZooKeeper Server进程。

 

4.1.  软件基本信息

 1 [[email protected] app]# pwd 
 2 /app 
 3 [[email protected] app]# ll 
 4 total 16 
 5 drwxr-xr-x  3 root root    23 May 26 07:01 bigdata 
 6 lrwxrwxrwx  1 root root    13 May 26 06:55 jdk -> jdk1.8.0_112/ 
 7 drwxr-xr-x  8   10   143  255 Sep 23  2016 jdk1.8.0_112 
 8 drwxr-xr-x 11  501 games 4096 May 26 07:04 zookeeper-3.4.5_01 
 9 drwxr-xr-x 11  501 games 4096 May 26 07:04 zookeeper-3.4.5_02 
10 drwxr-xr-x 11  501 games 4096 May 26 07:04 zookeeper-3.4.5_03

 

4.2.  配置文件

4.2.1.   zookeeper-3.4.5_01 配置信息

 1 [[email protected] conf]# pwd 
 2 /app/zookeeper-3.4.5_01/conf  
 3 [[email protected] conf]# ll 
 4 total 20 
 5 -rw-r--r-- 1 501 games  535 Oct  1  2012 configuration.xsl 
 6 -rw-r--r-- 1 501 games 2161 Oct  1  2012 log4j.properties 
 7 -rw-r--r-- 1 501 games  927 May 26 07:06 zoo.cfg 
 8 -rw-r--r-- 1 501 games  808 Oct  1  2012 zoo_sample.cfg 
 9 [[email protected] conf]# vim zoo.cfg   
10 # The number of milliseconds of each tick 
11 tickTime=2000 
12 # The number of ticks that the initial  
13 # synchronization phase can take 
14 initLimit=10 
15 # The number of ticks that can pass between  
16 # sending a request and getting an acknowledgement 
17 syncLimit=5 
18 # the directory where the snapshot is stored. 
19 # do not use /tmp for storage, /tmp here is just  
20 # example sakes.  数据目录 单独目录存放  确保该目录存在 
21 dataDir=/app/bigdata/zookeeper1/data 
22 # the port at which the clients will connect 
23 # 客户端端口  多个实例的端口配置不可重复 
24 clientPort=2181 
25 # 
26 # Be sure to read the maintenance section of the  
27 # administrator guide before turning on autopurge. 
28 # 
29 # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance 
30 # 
31 # The number of snapshots to retain in dataDir 
32 #autopurge.snapRetainCount=3 
33 # Purge task interval in hours 
34 # Set to "0" to disable auto purge feature 
35 #autopurge.purgeInterval=1 
36  
37 #server.NUM=IP:port1:port2  NUM表示本机为第几号服务器;IP为本机ip地址; 
38 #port1为leader与follower通信端口;port2为参与竞选leader的通信端口 
39 #多个实例的端口配置不能重复,如下: 
40 server.1=172.16.1.14:2222:2225 
41 server.2=172.16.1.14:3333:3335 
42 server.3=172.16.1.14:4444:4445

 

4.2.2.   zookeeper-3.4.5_02 配置信息

 1 [[email protected] conf]# pwd 
 2 /app/zookeeper-3.4.5_02/conf 
 3 [[email protected] conf]# ll 
 4 total 16 
 5 -rw-r--r-- 1 501 games  535 Oct  1  2012 configuration.xsl 
 6 -rw-r--r-- 1 501 games 2161 Oct  1  2012 log4j.properties 
 7 -rw-r--r-- 1 501 games 1269 May 26 10:43 zoo.cfg 
 8 -rw-r--r-- 1 501 games  808 Oct  1  2012 zoo_sample.cfg 
 9 [[email protected] conf]# vim zoo.cfg   
10 # The number of milliseconds of each tick 
11 tickTime=2000 
12 # The number of ticks that the initial  
13 # synchronization phase can take 
14 initLimit=10 
15 # The number of ticks that can pass between  
16 # sending a request and getting an acknowledgement 
17 syncLimit=5 
18 # the directory where the snapshot is stored. 
19 # do not use /tmp for storage, /tmp here is just  
20 # example sakes.  数据目录 单独目录存放  确保该目录存在 
21 dataDir=/app/bigdata/zookeeper2/data 
22 # the port at which the clients will connect 
23 # 客户端端口  多个实例的端口配置不可重复 
24 clientPort=2182 
25 # 
26 # Be sure to read the maintenance section of the  
27 # administrator guide before turning on autopurge. 
28 # 
29 # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance 
30 # 
31 # The number of snapshots to retain in dataDir 
32 #autopurge.snapRetainCount=3 
33 # Purge task interval in hours 
34 # Set to "0" to disable auto purge feature 
35 #autopurge.purgeInterval=1 
36  
37 #server.NUM=IP:port1:port2  NUM表示本机为第几号服务器;IP为本机ip地址; 
38 #port1为leader与follower通信端口;port2为参与竞选leader的通信端口 
39 #多个实例的端口配置不能重复,如下: 
40 server.1=172.16.1.14:2222:2225 
41 server.2=172.16.1.14:3333:3335 
42 server.3=172.16.1.14:4444:4445

 

4.2.3.   zookeeper-3.4.5_03 配置信息

 

 1 [[email protected] conf]# pwd 
 2 /app/zookeeper-3.4.5_03/conf 
 3 [[email protected] conf]# ll 
 4 total 16 
 5 -rw-r--r-- 1 501 games  535 Oct  1  2012 configuration.xsl 
 6 -rw-r--r-- 1 501 games 2161 Oct  1  2012 log4j.properties 
 7 -rw-r--r-- 1 501 games 1268 May 25 23:39 zoo.cfg 
 8 -rw-r--r-- 1 501 games  808 Oct  1  2012 zoo_sample.cfg 
 9 [[email protected] conf]# vim zoo.cfg   
10 # The number of milliseconds of each tick 
11 tickTime=2000 
12 # The number of ticks that the initial  
13 # synchronization phase can take 
14 initLimit=10 
15 # The number of ticks that can pass between  
16 # sending a request and getting an acknowledgement 
17 syncLimit=5 
18 # the directory where the snapshot is stored. 
19 # do not use /tmp for storage, /tmp here is just  
20 # example sakes.  数据目录 单独目录存放 
21 dataDir=/app/bigdata/zookeeper3/data 
22 # the port at which the clients will connect 
23 # 客户端端口  多个实例的端口配置不可重复 
24 clientPort=2183 
25 # 
26 # Be sure to read the maintenance section of the  
27 # administrator guide before turning on autopurge. 
28 # 
29 # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance 
30 # 
31 # The number of snapshots to retain in dataDir 
32 #autopurge.snapRetainCount=3 
33 # Purge task interval in hours 
34 # Set to "0" to disable auto purge feature 
35 #autopurge.purgeInterval=1 
36  
37 #server.NUM=IP:port1:port2  NUM表示本机为第几号服务器;IP为本机ip地址; 
38 #port1为leader与follower通信端口;port2为参与竞选leader的通信端口 
39 #多个实例的端口配置不能重复,如下: 
40 server.1=172.16.1.14:2222:2225 
41 server.2=172.16.1.14:3333:3335 
42 server.3=172.16.1.14:4444:4445

 

4.3.  添加myid文件

 

1 [[email protected] bigdata]# cat /app/bigdata/zookeeper1/data/myid  
2 1 
3 [[email protected] bigdata]# cat /app/bigdata/zookeeper2/data/myid  
4 2 
5 [[email protected] bigdata]# cat /app/bigdata/zookeeper3/data/myid  
6 3

 

4.4.  启动与查看状态

4.4.1.   依次启动

 

 1 # 第一台 
 2 [[email protected] bin]# pwd 
 3 /app/zookeeper-3.4.5_01/bin 
 4 [[email protected] bin]# ./zkServer.sh start 
 5 JMX enabled by default 
 6 Using config: /app/zookeeper-3.4.5_01/bin/../conf/zoo.cfg 
 7 Starting zookeeper ... STARTED 
 8  
 9 # 第二台 
10 [[email protected] bin]# pwd 
11 /app/zookeeper-3.4.5_02/bin 
12 [[email protected] bin]# ./zkServer.sh start 
13 JMX enabled by default 
14 Using config: /app/zookeeper-3.4.5_02/bin/../conf/zoo.cfg 
15 Starting zookeeper ... STARTED 
16  
17 # 第三台 
18 [[email protected] bin]# pwd 
19 /app/zookeeper-3.4.5_03/bin 
20 [[email protected] bin]# ./zkServer.sh start 
21 JMX enabled by default 
22 Using config: /app/zookeeper-3.4.5_03/bin/../conf/zoo.cfg 
23 Starting zookeeper ... STARTED

 

4.4.2.   查看状态

 1 # 第一台 
 2 [[email protected] bin]# pwd 
 3 /app/zookeeper-3.4.5_01/bin 
 4 [[email protected] bin]# ./zkServer.sh status 
 5 JMX enabled by default 
 6 Using config: /app/zookeeper-3.4.5_01/bin/../conf/zoo.cfg 
 7 Mode: follower 
 8  
 9 # 第二台 
10 [[email protected] bin]# pwd 
11 /app/zookeeper-3.4.5_02/bin 
12 [[email protected] bin]# ./zkServer.sh status 
13 JMX enabled by default 
14 Using config: /app/zookeeper-3.4.5_02/bin/../conf/zoo.cfg 
15 Mode: leader 
16  
17 # 第三台 
18 [[email protected] bin]# pwd 
19 /app/zookeeper-3.4.5_03/bin 
20 [[email protected] bin]# ./zkServer.sh status 
21 JMX enabled by default 
22 Using config: /app/zookeeper-3.4.5_03/bin/../conf/zoo.cfg 
23 Mode: follower

 

5. zookeeper【集群】

5.1.   配置信息

 1 [[email protected] conf]# pwd 
 2 /app/zookeeper-3.4.5/conf 
 3 [[email protected] conf]# vim zoo.cfg  
 4 # The number of milliseconds of each tick 
 5 tickTime=2000 
 6 # The number of ticks that the initial  
 7 # synchronization phase can take 
 8 initLimit=10 
 9 # The number of ticks that can pass between  
10 # sending a request and getting an acknowledgement 
11 syncLimit=5 
12 # the directory where the snapshot is stored. 
13 # do not use /tmp for storage, /tmp here is just  
14 # example sakes. 
15 dataDir=/app/bigdata/zookeeper/data 
16 # the port at which the clients will connect 
17 clientPort=2181 
18 # 
19 # Be sure to read the maintenance section of the  
20 # administrator guide before turning on autopurge. 
21 # 
22 # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance 
23 # 
24 # The number of snapshots to retain in dataDir 
25 #autopurge.snapRetainCount=3 
26 # Purge task interval in hours 
27 # Set to "0" to disable auto purge feature 
28 #autopurge.purgeInterval=1 
29  
30 # leader和follow通信端口和投票选举端口   
31 server.1=172.16.1.11:2888:3888  
32 server.2=172.16.1.12:2888:3888 
33 server.3=172.16.1.13:2888:3888

 

5.2.  添加myid文件

1 [[email protected] conf]# cd /app/bigdata/zookeeper/data   #    
2 [[email protected] data]# vim myid  # 3台机器的myid分别为 123  # 见开头的主机规划  
3 1

 

5.3.  启动zk服务

 

 1 ##### 第1台、2台、3台 依次启动 
 2 [[email protected] bin]# pwd 
 3 /app/zookeeper-3.4.5/bin 
 4 [[email protected] bin]# ll 
 5 total 60 
 6 -rwxr-xr-x 1  501 games   238 Oct  1  2012 README.txt 
 7 -rwxr-xr-x 1  501 games  1909 Oct  1  2012 zkCleanup.sh 
 8 -rwxr-xr-x 1  501 games  1049 Oct  1  2012 zkCli.cmd 
 9 -rwxr-xr-x 1  501 games  1512 Oct  1  2012 zkCli.sh 
10 -rwxr-xr-x 1  501 games  1333 Oct  1  2012 zkEnv.cmd 
11 -rwxr-xr-x 1  501 games  2599 Oct  1  2012 zkEnv.sh 
12 -rwxr-xr-x 1  501 games  1084 Oct  1  2012 zkServer.cmd 
13 -rwxr-xr-x 1  501 games  5467 Oct  1  2012 zkServer.sh 
14 [[email protected] bin]# ./zkServer.sh start   
15 JMX enabled by default 
16 Using config: /app/zookeeper-3.4.5/bin/../conf/zoo.cfg 
17 Starting zookeeper ... STARTED

 

5.4.  查询运行状态

 1 # 第一台 
 2 [[email protected] bin]# ./zkServer.sh status   
 3 JMX enabled by default 
 4 Using config: /app/zookeeper-3.4.5/bin/../conf/zoo.cfg 
 5 Mode: follower 
 6  
 7 # 第二台 
 8 [[email protected] bin]# ./zkServer.sh status   
 9 JMX enabled by default 
10 Using config: /app/zookeeper-3.4.5/bin/../conf/zoo.cfg 
11 Mode: leader 
12  
13 # 第三台 
14 [[email protected] bin]# ./zkServer.sh status   
15 JMX enabled by default 
16 Using config: /app/zookeeper-3.4.5/bin/../conf/zoo.cfg 
17 Mode: follower

 

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/bigdata/9107.html

(0)
上一篇 2021年7月19日 09:12
下一篇 2021年7月19日 09:12

相关推荐

发表回复

登录后才能评论