Linux安装Zookeeper

DevOps Zookeeper评论934字数 2775阅读9分15秒阅读模式

官网

  • https://zookeeper.apache.org/
  • https://zookeeper.apache.org/releases.html

选择版本

Linux安装Zookeeper

安装

[root@us-pre-ebu-english-1 ~]$ wget https://dlcdn.apache.org/zookeeper/zookeeper-3.5.9/apache-zookeeper-3.5.9-bin.tar.gz
[root@us-pre-ebu-english-1 centos]# tar  -zxvf apache-zookeeper-3.5.9-bin.tar.gz -C /usr/local/
[root@us-pre-ebu-english-1 centos]# mv /usr/local/apache-zookeeper-3.5.9-bin /usr/local/zookeeper-3.5.9
[root@us-pre-ebu-english-1 centos]# ls  /usr/local/zookeeper-3.5.9
bin  conf  docs  lib  LICENSE.txt  NOTICE.txt  README.md  README_packaging.txt

Zookeeper 配置文件

  • "conf"目录下,拷贝文件"zoo_sample.cfg"生成"zoo.cfg"

[root@us-pre-ebu-english-1 centos]# cp /usr/local/zookeeper-3.5.9/conf/zoo_sample.cfg /usr/local/zookeeper-3.5.9/conf/zoo.cfg
  • 编辑"zoo.cfg"其中内容如下

[root@us-pre-ebu-english-1 centos]# grep -v "^$" /usr/local/zookeeper-3.5.9/conf/zoo.cfg | grep -v "^#"
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/zookeeper
clientPort=2181
admin.serverPort=18080
  • tickTime:ZooKeeper使用的基本时间单位(毫秒)。它用于做心跳,并且最小会话超时将是tickTime的两倍。
  • dataDir:存储内存数据库快照的位置,除非另有说明,否则存储数据库更新的事务日志。
  • clientPort:用于侦听客户端连接的端口
  • Admin Server 绑定端口

ZooKeeper Server 服务命令

  • 修改java
[root@us-pre-ebu-english-1 bin]# pwd
/usr/local/zookeeper-3.5.9/bin
[root@us-pre-ebu-english-1 bin]# vim zkEnv.sh
JAVA_HOME="/data/app/jdk-13.0.1"

Linux安装Zookeeper

  • 运行 ZooKeeper Server(后台运行)
[root@us-pre-ebu-english-1 zookeeper-3.5.9]# pwd
/usr/local/zookeeper-3.5.9
[root@us-pre-ebu-english-1 zookeeper-3.5.9]# bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
  • 停止 ZooKeeper Server
[root@us-pre-ebu-english-1 zookeeper-3.5.9]# bin/zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5.9/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
  • 重启ZooKeeper Server
[root@us-pre-ebu-english-1 zookeeper-3.5.9]# bin/zkServer.sh restart
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5.9/bin/../conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5.9/bin/../conf/zoo.cfg
Stopping zookeeper ... no zookeeper to stop (could not find file /data/zookeeper/zookeeper_server.pid)
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
  • 查看 ZooKeeper Server 状态
[root@us-pre-ebu-english-1 zookeeper-3.5.9]# bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5.9/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: standalone

ZooKeeper 命令行客户端命令

  • 连接
[root@us-pre-ebu-english-1 zookeeper-3.5.9]# bin/zkCli.sh -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181
  • 显示根目录下、文件: ls /使用 ls 命令来查看当前 ZooKeeper 中所包含的内容
    [zk: 127.0.0.1:2181(CONNECTED) 0] ls \
    
    Path must start with / character
  • 获取节点数据: get path
    [zk: 127.0.0.1:2181(CONNECTED) 1] get /zk
    
    org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /zk
  • 退出客户端: quit 或 (Ctrl + C)
    [zk: 127.0.0.1:2181(CONNECTED) 2] quit

继续阅读
DevOps
  • 本文由 发表于 2022年4月27日 23:17:01
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
Zookeeper3.5.7集群部署 Zookeeper

Zookeeper3.5.7集群部署

简述 ZooKeeper 是 Apache 的一个顶级项目,为分布式应用提供高效、高可用的分布式协调服务。 ZooKeeper本质上是一个分布式的小文件存储系统。提供类似于文件系统目录树方式的...
Zookeeper3.8集群 Zookeeper

Zookeeper3.8集群

安装jdk 安装文档 集群规划 zookeper集群至少需要3台服务器,并且强烈建议使用奇数个服务器。因为zookeeper通过半数机制来判断整个集群是否可用,也就是说集群中有一半以...
评论  0  访客  0

发表评论