zookeeper单机安装

zookeeper单机安装

文档

  1. linux安装java -centos安装java -linux配置java环境变量
  2. zookeeper单机安装
  3. zookeeper集群安装
  4. zookeeper客户端命令行操作、节点类型及监听器
  5. zookeeper集群写数据原理
  6. java操作zookeeper

下载地址

  1. 官网:https://zookeeper.apache.org/
  2. 最新版本下载页面:https://zookeeper.apache.org/releases.html
  3. 下载列表页面:https://archive.apache.org/dist/zookeeper/

说明

  1. 版本选择:apache-zookeeper-3.5.7-bin.tar.gz
  2. 下载地址:https://archive.apache.org/dist/zookeeper/zookeeper-3.5.7/apache-zookeeper-3.5.7-bin.tar.gz

安装前准备

  1. 在linux上安装,centos7上安装
  2. 安装java环境,参考:linux安装java -centos安装java -linux配置java环境变量

本地安装

  1. 复制下载的安装包到Linux服务器,安装包名:apache-zookeeper-3.5.7-bin.tar.gz

  2. 进入到安装包所在路径,将安装包解压到指定目录

    shell 复制代码
    tar -zxvf apache-zookeeper-3.5.7-bin.tar.gz -C /opt/module
  3. 重命名,将apache-zookeeper-3.5.7-bin重命名为zookeeper-3.5.7

    shell 复制代码
    cd /opt/module
    mv apache-zookeeper-3.5.7-bin/ zookeeper-3.5.7
  4. 复制配置zoo_sample.cfg文件并命名为zoo.cfg,默认加载的配置文件为zoo.cfg

    shell 复制代码
    cd /opt/module/zookeeper-3.5.7/conf/
    cp zoo_sample.cfg zoo.cfg
  5. 在zookeeper根目录创建zkData文件夹,用来存放zookeeper数据,在配置文件中指定该路径

    shell 复制代码
    cd /opt/module/zookeeper-3.5.7
    mkdir zkData
  6. 修改配置文件zoo.cfg

    仅需要指定数据存储路径,其它可以保持不变

    properties 复制代码
    # dataDir=/tmp/zookeeper
    dataDir=/opt/module/zookeeper-3.5.7/zkData

    完整配置文件

    properties 复制代码
    # The number of milliseconds of each tick
    # 通信心跳时间,zookeeper服务器与客户端及服务端与服务端心跳时间,单位毫秒 
    tickTime=2000
    # The number of ticks that the initial 
    # synchronization phase can take
    # LF(Leader与Follower)初始化时的通信时间,10表示10个心跳时间(tickTime),20s未建立连接,通信失败
    initLimit=10
    # The number of ticks that can pass between 
    # sending a request and getting an acknowledgement
    # LF同步通信时限,5个心跳,10s
    syncLimit=5
    # the directory where the snapshot is stored.
    # 快照数据
    # do not use /tmp for storage, /tmp here is just 
    # 不要存放在 /tmp 下
    # example sakes.
    # 自定义路径存放快照数据,仅此处有改动
    # dataDir=/tmp/zookeeper
    dataDir=/opt/module/zookeeper-3.5.7/zkData
    # 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

启动zookeeper服务端

  1. 启动zookeeper

    shell 复制代码
    cd /opt/module/zookeeper-3.5.7/bin
    ./zkServer.sh start
  2. 查看zookeeper进程,jps是java命令

    shell 复制代码
    jps -l
  3. 查看zookeeper状态

    shell 复制代码
    ./zkServer.sh status
  4. 停止zookeeper

    shell 复制代码
    ./zkServer.sh stop

启动zookeeper客户端

  1. 启动客户端,默认服务器为localhost

    shell 复制代码
    ./zkCli.sh

    输出信息:[zk: localhost:2181(CONNECTED) 0]

  2. 启动客户端,指定服务器

    shell 复制代码
    ./zkCli.sh -server 192.168.145.132:2181

    输出信息:[zk: 192.168.145.132:2181(CONNECTED) 0]

  3. 退出

    shell 复制代码
    quit
相关推荐
努力学编程呀(๑•ี_เ•ี๑)2 分钟前
【在 IntelliJ IDEA 中切换项目 JDK 版本】
java·开发语言·intellij-idea
码农小卡拉11 分钟前
深入解析Spring Boot文件加载顺序与加载方式
java·数据库·spring boot
向上的车轮19 分钟前
为什么.NET(C#)转 Java 开发时常常在“吐槽”Java:checked exception
java·c#·.net
Dragon Wu20 分钟前
Spring Security Oauth2.1 授权码模式实现前后端分离的方案
java·spring boot·后端·spring cloud·springboot·springcloud
跳动的梦想家h26 分钟前
环境配置 + AI 提效双管齐下
java·vue.js·spring
坚持就完事了28 分钟前
Java中的集合
java·开发语言
wjhx37 分钟前
QT中对蓝牙权限的申请,整理一下
java·数据库·qt
YCY^v^41 分钟前
JeecgBoot 项目运行指南
java·学习
人间打气筒(Ada)1 小时前
jenkins基于Pipeline发布项目
java·pipeline·jenkins·流水线·ci·cd·cicd
爬山算法1 小时前
Hibernate(88)如何在负载测试中使用Hibernate?
java·后端·hibernate