zookeeper安装部署

实验环境

test1.com  

192.168.255.128
test2.com   192.168.255.129
test3.com 192.168.255.130
安装路径 /data/sever

 

 

 

 

 

zookeeper安装

1.配置java环境变量(3台同样配置)

[tx@test1 ~]$ tar -zxvf jdk-7u80-linux-x64.tar.gz -C /data/servers/

[tx@test1 servers]$ mv jdk1.7.0_80/ jdk1.7
[tx@test1 ~]$ vim .profile

export JAVA_HOME=/data/servers/jdk1.7
export PATH=$JAVA_HOME/bin:$PATH

[tx@test1 ~]$ source .profile

[tx@test1 ~]$ echo $JAVA_HOME
/data/servers/jdk1.7

[tx@test1 ~]$ java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

   

2.解压安装包,配置文件(3台同样配置)

[tx@test1 server]# tar -zxvf zookeeper-3.4.5.tar.gz
[tx@test1 zookeeper-3.4.5]# cd conf
[tx@test1 conf]# ls
 configuration.xsl log4j.properties zoo_sample.cfg
[tx@test1 conf]# vim zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/zookeeper   #zookeeper数据存储路径
clientPort=2182

server.1=test1:2888:3888
server.2=test2:2888:3888
server.3=test3:2888:3888

3.配置myid文件

在配置的dataDir指定的目录下面,创建一个myid文件,里面内容为一个数字,用来标识当前主机,conf/zoo.cfg文件中配置的server.X中是什么数字,则myid文件中就输入这个数字:

[tx@test1 data]# mkdir zookeeper(3台都创建)
[tx@test1 data]# echo 1 > ./zookeeper/myid
[tx@test2 data]# echo 2 > ./zookeeper/myid
[tx@test3 data]# echo 3 > ./zookeeper/myid
4,启动zookeeper,查看状态
[tx@test1 bin]$ ./zkServer.sh start
JMX enabled by default
Using config: /data/servers/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[tx@test1 bin]$ ./zkServer.sh status
JMX enabled by default
Using config: /data/servers/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: follower

[tx@test2 bin]$ ./zkServer.sh start
JMX enabled by default
Using config: /data/servers/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[tx@test2 bin]$ ./zkServer.sh status
JMX enabled by default
Using config: /data/servers/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: follower

[tx@test3 bin]$ ./zkServer.sh start
JMX enabled by default
Using config: /data/servers/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[tx@test3 bin]$ ./zkServer.sh status
JMX enabled by default
Using config: /data/servers/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: leader

4.可以通过命令jps,ps查看Zookeeper进程

[tx@test1 ~]$ jps
43603 Jps
23370 QuorumPeerMain

[tx@test1 ~]$ ps -ef | grep zookeeper

 zookeeper优化

如果不配置dataLogDir,那么事务日志也会写在dataDir目录中。这样会严重影响zk的性能。因为在zk吞吐量很高的时候,产生的事务日志和快照日志太多。最好是为datalogDir单独分配一块磁盘

修改配置文件,添加如下内容:

#vim zoo.cfg

tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/zookeeper/dataDir
dataLogDir=/data/zookeeper/dataLogDir
clientPort=2182

server.1=test1:2888:3888
server.2=test2:2888:3888
server.3=test3:2888:3888

 

 

posted @ 2018-01-24 14:58  cornerxin  阅读(150)  评论(0编辑  收藏  举报