ZooKeeper单机版安装配置

IT
IT
IT
335
文章
1
评论
2020年4月22日13:44:12 评论 7,189 5171字阅读17分14秒

yum安装jdk

[root@iZ2zeflzb6atg5mhyyxn7oZ ~]#  yum -y install java-1.8.0-openjdk*

配置变量

[root@iZ2zeflzb6atg5mhyyxn7oZ ~]# vim /etc/profile
export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

使其生效

[root@iZ2zeflzb6atg5mhyyxn7oZ ~]# source /etc/profile
[root@iZ2zeflzb6atg5mhyyxn7oZ ~]# java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

安装ZooKeeper

[root@iZ2zeflzb6atg5mhyyxn7oZ ~]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
[root@iZ2zeflzb6atg5mhyyxn7oZ ~]# tar zxf zookeeper-3.4.14.tar.gz -C /usr/local/
[root@iZ2zeflzb6atg5mhyyxn7oZ ~]# ln -sv /usr/local/zookeeper-3.4.14/ /usr/local/zookeeper
‘/usr/local/zookeeper’ -> ‘/usr/local/zookeeper-3.4.14/’

设置配置文件

zookeeper默认读取的是conf/zoo.cfg配置文件

[root@iZ2zeflzb6atg5mhyyxn7oZ ~]# cp /usr/local/zookeeper/conf/zoo_sample.cfg /usr/local/zookeeper/conf/zoo.cfg

配置zookeeper启动服务脚本

[root@iZ2zeflzb6atg5mhyyxn7oZ ~]# vim /etc/init.d/zookeeper
#!/bin/bash
# chkconfig: 2345 10 90
# description: zookeeper
#Blog:blog.whsir.com
case $1 in
    start) /usr/local/zookeeper/bin/zkServer.sh start
    ;;
    stop) /usr/local/zookeeper/bin/zkServer.sh stop
    ;;
    status) su root /usr/local/zookeeper/bin/zkServer.sh status
    ;;
    restart) su /usr/local/zookeeper/bin/zkServer.sh restart
    ;;
    *) echo "require start|stop|status|restart"
    ;;
esac

赋予执行权限

[root@iZ2zeflzb6atg5mhyyxn7oZ ~]# chmod +x /etc/init.d/zookeeper
[root@iZ2zeflzb6atg5mhyyxn7oZ ~]# chkconfig --add zookeeper
[root@iZ2zeflzb6atg5mhyyxn7oZ ~]# /etc/init.d/zookeeper start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

连接测试

zookeeper默认连接端口2181,这里测试下客户端连接

如果连接本地zookeeper则直接运行bin目录下的zkCli.sh即可,如果要连接远程的zookeeper服务,则使用-server参数

[root@iZ2zeflzb6atg5mhyyxn7oZ ~]# /usr/local/zookeeper/bin/zkCli.sh -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181
2020-04-22 13:53:23,925 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf, built on 03/06/2019 16:18 GMT
2020-04-22 13:53:23,928 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=iZ2zeflzb6atg5mhyyxn7oZ
2020-04-22 13:53:23,928 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.8.0_242
2020-04-22 13:53:23,929 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2020-04-22 13:53:23,929 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre
2020-04-22 13:53:23,929 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/usr/local/zookeeper/bin/../zookeeper-server/target/classes:/usr/local/zookeeper/bin/../build/classes:/usr/local/zookeeper/bin/../zookeeper-server/target/lib/*.jar:/usr/local/zookeeper/bin/../build/lib/*.jar:/usr/local/zookeeper/bin/../lib/slf4j-log4j12-1.7.25.jar:/usr/local/zookeeper/bin/../lib/slf4j-api-1.7.25.jar:/usr/local/zookeeper/bin/../lib/netty-3.10.6.Final.jar:/usr/local/zookeeper/bin/../lib/log4j-1.2.17.jar:/usr/local/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/bin/../lib/audience-annotations-0.5.0.jar:/usr/local/zookeeper/bin/../zookeeper-3.4.14.jar:/usr/local/zookeeper/bin/../zookeeper-server/src/main/resources/lib/*.jar:/usr/local/zookeeper/bin/../conf:.:/usr/lib/jvm/jre-1.8.0-openjdk/lib/dt.jar:/usr/lib/jvm/jre-1.8.0-openjdk/lib/tools.jar
2020-04-22 13:53:23,930 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2020-04-22 13:53:23,930 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2020-04-22 13:53:23,930 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>
2020-04-22 13:53:23,930 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
2020-04-22 13:53:23,930 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2020-04-22 13:53:23,930 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.10.0-1062.18.1.el7.x86_64
2020-04-22 13:53:23,930 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=root
2020-04-22 13:53:23,930 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/root
2020-04-22 13:53:23,930 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/root
2020-04-22 13:53:23,931 [myid:] - INFO  [main:ZooKeeper@442] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@1a86f2f1
Welcome to ZooKeeper!
2020-04-22 13:53:23,946 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1025] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2020-04-22 13:53:23,993 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/127.0.0.1:2181, initiating session
[zk: 127.0.0.1:2181(CONNECTING) 0] 2020-04-22 13:53:24,013 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x100006cff570000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
继续阅读
  • 我的QQ
  • QQ扫一扫
  • weinxin
  • 我的头条
  • 头条扫一扫
  • weinxin
IT
  • 本文由 发表于 2020年4月22日13:44:12
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
zookeeper集群 zookeeper

zookeeper集群

简介 ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提...
zookeeper可视化界面 zookeeper

zookeeper可视化界面

安装maven 生成zkui的jar包 修改成自己所需信息 # git clone https://gitee.com/ilanni/zkui.git Cloning into 'zkui'... r...
zookeeper集群 zookeeper

zookeeper集群

简介 ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提...