zookeeper install

java install

1
2
3
4
5
6
7
8
9
[root@localhost app]# tar xzf jdk-8u73-linux-x64.tar.gz
[root@localhost app]# mv jdk1.8.0_73 /mnt/app/java
[root@localhost app]# chown -R root.root /mnt/app/java

[root@localhost app]# echo 'export JAVA_HOME=/mnt/app/java' | tee /etc/profile.d/java.sh
[root@localhost app]# echo 'export JRE_HOME=${JAVA_HOME}/jre' | tee -a /etc/profile.d/java.sh
[root@localhost app]# echo 'export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib' | tee -a /etc/profile.d/java.sh
[root@localhost app]# echo 'export PATH=${JAVA_HOME}/bin:$PATH' | tee -a /etc/profile.d/java.sh
[root@localhost app]# source /etc/profile

zookeeper standard install

1
2
3
4
5
6
7
[root@10 app]# tar xzf zookeeper-3.4.6.tar.gz
[root@10 app]# mv zookeeper-3.4.6 /mnt/app/zookeeper

[root@10 app]# chown -R wisdom.wisdom /mnt/app/zookeeper

[root@10 app]# mkdir -p /mnt/{data,log}/zookeeper
[root@10 app]# chown -R wisdom.wisdom /mnt/{data,log}/zookeeper
1
2
3
4
[root@10 app]# echo 'export ZK_HOME=/mnt/app/zookeeper' | tee /etc/profile.d/zookeeper.sh
[root@10 app]# echo 'export ZK_BIN=${ZK_HOME}/bin' | tee -a /etc/profile.d/zookeeper.sh
[root@10 app]# echo 'export PATH=${ZK_BIN}:$PATH' | tee -a /etc/profile.d/zookeeper.sh
[root@10 app]# source /etc/profile
1
2
3
4
5
6
7
8
9
10
11
[root@10 app]# cat > /mnt/app/zookeeper/conf/zoo.cfg <<EOF
> tickTime=2000
> initLimit=10
> syncLimit=5
> clientPort=2181
> clientPortAddress=10.0.2.113
> dataDir=/mnt/data/zookeeper
> dataLogDir=/mnt/log/zookeeper
> autopurge.snapRetainCount=3
> autopurge.purgeInterval=1
> EOF
1
2
3
[root@10 app]# cat > /mnt/app/zookeeper/conf/zookeeper-env.sh <<EOF
> ZOO_LOG_DIR=/mnt/log/zookeeper
> EOF
1
2
3
4
[root@10 ~]# cat > /mnt/app/zookeeper/conf/java.env <<EOF
> export JAVA_HOME=/mnt/app/java
> export JVMFLAGS="-Xms1024m -Xmx1024m $JVMFLAGS"
> EOF
1
2
3
[root@10 app]# su - wisdom
[wisdom@10 ~]$ /mnt/app/zookeeper/bin/zkServer.sh start
[wisdom@10 ~]$ /mnt/app/zookeeper/bin/zkServer.sh status

zookeeper cluster install

1
2
3
4
5
6
7
[root@localhost app]# tar xzf zookeeper-3.4.6.tar.gz
[root@localhost app]# mv zookeeper-3.4.6 /mnt/app/zookeeper

[root@localhost app]# chown -R root.root /mnt/app/zookeeper

[root@localhost app]# mkdir -p /mnt/{data,log}/zookeeper
[root@localhost app]# chown -R wisdom.wisdom /mnt/{data,log}/zookeeper
1
2
3
4
[root@localhost app]# echo 'export ZK_HOME=/mnt/app/zookeeper' | tee /etc/profile.d/zookeeper.sh
[root@localhost app]# echo 'export ZK_BIN=${ZK_HOME}/bin' | tee -a /etc/profile.d/zookeeper.sh
[root@localhost app]# echo 'export PATH=${ZK_BIN}:$PATH' | tee -a /etc/profile.d/zookeeper.sh
[root@localhost app]# source /etc/profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
ZK-cluster-1:
[root@localhost app]# cat > /mnt/app/zookeeper/conf/zookeeper-env.sh <<EOF
> ZOO_LOG_DIR=/mnt/log/zookeeper
> EOF

[root@localhost app]# cat > /mnt/data/zookeeper/myid <<EOF
> 228
> EOF

[root@localhost app]# cat > /mnt/app/zookeeper/conf/zoo.cfg <<EOF
> tickTime=2000
> initLimit=5
> syncLimit=2
> clientPort=2181
> clientPortAddress=192.168.18.228
> maxClientCnxns=2000
> autopurge.snapRetainCount=5
> autopurge.purgeInterval=3
> dataDir=/mnt/data/zookeeper
> dataLogDir=/mnt/log/zookeeper
> server.228=192.168.18.228:3181:4181
> server.229=192.168.18.229:3181:4181
> server.230=192.168.18.230:3181:4181
> EOF

[root@localhost app]# cat > /mnt/app/zookeeper/conf/java.env <<EOF
> export JAVA_HOME=/mnt/app/java
> export JVMFLAGS="-Xms1024m -Xmx1024m $JVMFLAGS"
> EOF

[root@localhost app]# chown -R wisdom.wisdom /mnt/app/zookeeper/conf
[root@localhost app]# su - wisdom
[wisdom@localhost ~]$ /mnt/app/zookeeper/bin/zkServer.sh start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
ZK-cluster-2:
[root@localhost app]# cat > /mnt/app/zookeeper/conf/zookeeper-env.sh <<EOF
> ZOO_LOG_DIR=/mnt/log/zookeeper
> EOF

[root@localhost app]# cat > /mnt/data/zookeeper/myid <<EOF
> 229
> EOF

[root@localhost app]# cat > /mnt/app/zookeeper/conf/zoo.cfg <<EOF
> tickTime=2000
> initLimit=5
> syncLimit=2
> clientPort=2181
> clientPortAddress=192.168.18.229
> maxClientCnxns=2000
> autopurge.snapRetainCount=5
> autopurge.purgeInterval=3
> dataDir=/mnt/data/zookeeper
> dataLogDir=/mnt/log/zookeeper
> server.228=192.168.18.228:3181:4181
> server.229=192.168.18.229:3181:4181
> server.230=192.168.18.230:3181:4181
> EOF

[root@localhost app]# cat > /mnt/app/zookeeper/conf/java.env <<EOF
> export JAVA_HOME=/mnt/app/java
> export JVMFLAGS="-Xms1024m -Xmx1024m $JVMFLAGS"
> EOF

[root@localhost app]# chown -R wisdom.wisdom /mnt/app/zookeeper/conf
[root@localhost app]# su - wisdom
[wisdom@localhost ~]$ /mnt/app/zookeeper/bin/zkServer.sh start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
ZK-cluster-3:
[root@localhost app]# cat > /mnt/app/zookeeper/conf/zookeeper-env.sh <<EOF
> ZOO_LOG_DIR=/mnt/log/zookeeper
> EOF

[root@localhost app]# cat > /mnt/data/zookeeper/myid <<EOF
> 230
> EOF

[root@localhost app]# cat > /mnt/app/zookeeper/conf/zoo.cfg <<EOF
> tickTime=2000
> initLimit=5
> syncLimit=2
> clientPort=2181
> clientPortAddress=192.168.18.230
> maxClientCnxns=2000
> autopurge.snapRetainCount=5
> autopurge.purgeInterval=3
> dataDir=/mnt/data/zookeeper
> dataLogDir=/mnt/log/zookeeper
> server.228=192.168.18.228:3181:4181
> server.229=192.168.18.229:3181:4181
> server.230=192.168.18.230:3181:4181
> EOF

[root@localhost app]# cat > /mnt/app/zookeeper/conf/java.env <<EOF
> export JAVA_HOME=/mnt/app/java
> export JVMFLAGS="-Xms1024m -Xmx1024m $JVMFLAGS"
> EOF

[root@localhost app]# chown -R wisdom.wisdom /mnt/app/zookeeper/conf
[root@localhost app]# su - wisdom
[wisdom@localhost ~]$ /mnt/app/zookeeper/bin/zkServer.sh start

zookeeper cluster info

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@localhost app]# cat /mnt/app/zookeeper/conf/zoo.cfg
tickTime=2000
initLimit=5
syncLimit=2
clientPort=2181
clientPortAddress=192.168.18.230
maxClientCnxns=2000
autopurge.snapRetainCount=5
autopurge.purgeInterval=3
dataDir=/mnt/data/zookeeper
dataLogDir=/mnt/log/zookeeper
server.228=192.168.18.228:3181:4181
server.229=192.168.18.229:3181:4181
server.230=192.168.18.230:3181:4181

集群参数说明:
server.A=B:C:D
* A是一个数字,表示这个是第几号服务器
* B是这个服务器的ip地址
* C表示这个服务器与集群中的Leader服务器交换信息的端口
* D表示的是集群选举通信端口.例如:集群中的Leader服务器挂了,需要一个端口来重新进行选举,选出一个新的Leader,而这个端口就是用来执行选举时服务器相互通信的端口