Centos7 启动Zookeeper 提示缺失:org.apache.zookeeper.server.quorum.QuorumPeerMain解析

访客 阅读:255 2021-03-31 16:55:17 评论:0

Centos7 搭建Zookeeper集群 一般步骤:

第一步:zookeeper 下载地址 
https://www-eu.apache.org/dist/zookeeper/stable/ 
 
第二步:解压zookeeper 
tar -xzvf zookeeper-3.5.6.tar.gz 
 
第三步:配置zookeeper 全局环境变量 
vi /etc/profile 
 
在文件中添加如下内容: 
export ZOOKEEPER_HOME=/usr/local/zookeeper/apache-zookeeper-3.5.6 
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$ZOOKEEPER_HOME/bin:$PATH 
 
第四步:修改zookeeper 配置文件 
cp /usr/local/zookeeper/apache-zookeeper-3.5.6/conf/zoo_sample.cfg /usr/local/zookeeper/apache-zookeeper-3.5.6/conf/zoo.cfg 
 
vi /usr/local/zookeeper/apache-zookeeper-3.5.6/conf/zoo.cfg 
 
编辑内容如下: 
# The number of milliseconds of each tick 
tickTime=2000 
# The number of ticks that the initial  
# synchronization phase can take 
initLimit=10 
# The number of ticks that can pass between  
# sending a request and getting an acknowledgement 
syncLimit=5 
# the directory where the snapshot is stored. 
# do not use /tmp for storage, /tmp here is just  
# example sakes. 
dataDir=/usr/local/zookeeper/data/data 
dataLogDir=/uar/local/zookeeper/data/logs 
# the port at which the clients will connect 
clientPort=2181 
# the maximum number of client connections. 
# increase this if you need to handle more clients 
#maxClientCnxns=60 
# 
# Be sure to read the maintenance section of the  
# administrator guide before turning on autopurge. 
# 
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance 
# 
# The number of snapshots to retain in dataDir 
#autopurge.snapRetainCount=3 
# Purge task interval in hours 
# Set to "0" to disable auto purge feature 
#autopurge.purgeInterval=1 
server.1=elk-server:2888:3888 
server.2=node1:2888:3888 
 
相关说明: 
dataDir: zookeeper 数据存储地址 
dataLogDir: zookeeper 日志文件存储地址 
 
第五步:复制elk-server节点上的zookeeper-3.5.6文件夹至node1 节点上 
scp /usr/local/zookeeper/apache-zookeeper-3.5.6 node1:/usr/local/zookeeper/apache-zookeeper-3.5.6 
 
第六步:分别编辑elk-server 和node1 的myid 
elk-server 虚拟机: 
在dataDir=/usr/local/zookeeper/data/data目录下创建空文件 
touch /usr/local/zookeeper/data/data/myid   
echo 1 > /usr/local/zookeeper/data/data/myid   
 
node1 虚拟机: 
在dataDir=/usr/local/zookeeper/data/data目录下创建空文件 
touch /usr/local/zookeeper/data/data/myid   
echo 2 > /usr/local/zookeeper/data/data/myid 
 
第七步:zookeeper 日志文件修改 
编辑/usr/local/zookeeper/apache-zookeeper-3.5.6/conf/zkEnv.sh 文件 
vi /usr/local/zookeeper/apache-zookeeper-3.5.6/conf/zkEnv.sh 
 
修改如下内容: 
if [ "x${ZOO_LOG_DIR}" = "x" ] 
then 
    # 服务运行日志输出路径 
    ZOO_LOG_DIR="/uar/local/zookeeper/data/logs" 
fi 
 
if [ "x${ZOO_LOG4J_PROP}" = "x" ] 
then 
    ZOO_LOG4J_PROP="INFO,ROLLINGFILE" 
fi 
 
第八步:zookeeper 服务启动和状态 
切换至zookeeper 文件夹下的bin 目录 
cd /usr/local/zookeeper/apache-zookeeper-3.5.6/bin 
 
启动zookeeper  
./zkServer.sh start 
 
zookeeper 状态信息 
./zkServer.sh status 
 
[root@elk-server bin]# ./zkServer.sh start 
ZooKeeper JMX enabled by default 
Using config: /usr/local/zookeeper/apache-zookeeper-3.5.6/bin/../conf/zoo.cfg 
Starting zookeeper ... STARTED 
[root@elk-server bin]# ./zkServer.sh status 
ZooKeeper JMX enabled by default 
Using config: /usr/local/zookeeper/apache-zookeeper-3.5.6/bin/../conf/zoo.cfg 
Client port found: 2181. Client address: localhost. 
Mode: follower 
 

在启动zookeeper 时,提示如下错误:org.apache.zookeeper.server.quorum.QuorumPeerMain 

解决办法:下载一个zookeeper带bin后缀的文件,因为改文件中包含lib 文件夹,将这个lib 文件夹拷贝至当前zookeeper-3.5.6 的安装目录.

截图所示:

声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

发表评论
搜索
KIKK导航

KIKK导航

关注我们