Zookeeper集群搭建

下载和安装

1.清华镜像站下载 zookeeper-3.4.10.tar.gz

wget http://apache.osuosl.org/zookeeper/stable/zookeeper-3.4.12.tar.gz

2.创建zookeeper文件夹
sudo mkdir /usr/local/zookeeper

创建dataDir、dataLogDir所需要文件夹

3.解压
sudo tar -zxvf zookeeper-3.4.10.tar.gz -C /usr/local/zookeeper

4.CD到zookeeper-3.4.10目录,复制conf下面的zoo_sample.cfg为zoo.cfg
sudo cp conf/zoo_sample.cfg conf/zoo.cfg
sudo gedit conf/zoo.cfg

5.修改zoo.cfg内容:

#set zookeeper
maxClientCnxns=60
tickTime=2000 
initLimit=10 
syncLimit=5
dataDir=/usr/local/zookeeper/dataDir
dataLogDir=/usr/local/zookeeper/dataLogDir clientPort=2181 server.1=192.168.86.140:2888:3888  server.2=192.168.86.142:2888:3888  server.3=192.168.86.133:2888:3888

6.在dataDir文件夹下面创建文件myid
sudo touch myid
sudo gedit myid :内容为1 / 2 / 3,server的编号

三台虚拟机都完成后:

7.cd /usr/local/zookeeper/zookeeper-3.4.10/bin

启动./zkServer.sh start

查看 ./zkCli.sh -server 127.0.0.1:2181

停止 ./zkServer.sh stop

配置zookeeper日志

修改config下面的log4j.properties
将:

zookeeper.root.logger=INFO, CONSOLE
log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender

改成:

zookeeper.root.logger=INFO, ROLLINGFILE log4j.appender.ROLLINGFILE=org.apache.log4j.DailyRollingFileAppender

修改bin下面的zkEnv.sh

将:

ZOO_LOG_DIR="."
ZOO_LOG4J_PROP="INFO,CONSOLE"

改成:

ZOO_LOG_DIR="/usr/local/zookeeper/logs" (指定日志输出目录)
ZOO_LOG4J_PROP="INFO,ROLLINGFILE"

zookeeper 启动报错 (nohup: failed to run command `java': No such file or directory )

https://blog.csdn.net/qq_22211217/article/details/80639492

zkServer.sh文件开头添加如下内容:

export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_191
export PATH=$JAVA_HOME/bin:$PATH  

zkCli.sh文件开头添加如下内容:

export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_191

启动zkui

1.下载Zkui https://github.com/DeemOpen/zkui

2.在 zkui目录下 mvn clean install

3.将生成的 config.cfg 和 target/zkui-2.0-SNAPSHOT-jar-with-dependencies.jar复制到想要放置zkui的目录下

4.配置config.cfg

serverPort=9090
zkServer=zookeeper001:2181,zookeeper002:2181,zookeeper003:2181 

5.启动 java -jar zkui-2.0-SNAPSHOT-jar-with-dependencies.jar
打开网址:
http://localhost:9090/home

创建节点

https://blog.csdn.net/xiaolang85/article/details/13021339

你可能感兴趣的:(Zookeeper集群搭建)