首页 > 其他分享 >【Zookeeper】(二)安装与配置

【Zookeeper】(二)安装与配置

时间:2023-01-31 23:23:20浏览次数:38  
标签:bin 10 配置 Zookeeper 3.5 zookeeper apache hadoop100 安装

1 安装

  1. 安装JDK(参考项目部署)

  2. 将Zookeeper拷贝到Linux下

  3. 解压

     tar -zxvf apache-zookeeper-3.5.10-bin.tar.gz -C /opt/module/
    
  4. 修改配置文件

    1. 将/opt/module/apache-zookeeper-3.5.10-bin下的zoo_sample.cfg文件修改为zoo.cfg

      [root@hadoop100 apache-zookeeper-3.5.10-bin]# cd conf/
      [root@hadoop100 conf]# ls
      configuration.xsl  log4j.properties  zoo_sample.cfg
      [root@hadoop100 conf]# mv zoo_sample.cfg zoo.cfg
      
    2. 在opt/module/apache-zookeeper-3.5.10-bin中创建文件夹zkData

      [root@hadoop100 conf]# cd ..
      [root@hadoop100 apache-zookeeper-3.5.10-bin]# pwd
      /opt/module/apache-zookeeper-3.5.10-bin
      [root@hadoop100 apache-zookeeper-3.5.10-bin]# mkdir zkData
      
    3. 在zoo.cfg中修改dataDir路径

      dataDir=/opt/module/apache-zookeeper-3.5.10-bin/zkData
      

2 操作Zookeeper

2.1 启动Zookeeper服务端

在bin目录下执行:

[root@hadoop100 bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/module/apache-zookeeper-3.5.10-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@hadoop100 bin]# jps
106928 QuorumPeerMain
107947 Jps

jps是java提供的命令,用于查看当前linux系统中运行的java进程

2.2 查看Zookeeper服务端状态
[root@hadoop100 bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/module/apache-zookeeper-3.5.10-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: standalone

standalone表示单例模式

2.3 启动Zookeeper客户端
[root@hadoop100 bin]# ./zkCli.sh
Connecting to localhost:2181
2023-01-30 18:27:33,440 [myid:] - INFO  [main:Environment@109] - Client environment:zookeeper.version=3.5.10-a32c7183d42325b03e44a06aade6a0f16955bf13, built on 05/29/2022 12:50 GMT
2023-01-30 18:27:33,441 [myid:] - INFO  [main:Environment@109] - Client environment:host.name=hadoop100
2023-01-30 18:27:33,441 [myid:] - INFO  [main:Environment@109] - Client environment:java.version=19.0.2
2023-01-30 18:27:33,441 [myid:] - INFO  [main:Environment@109] - Client environment:java.vendor=Oracle Corporation
...
2.4 关闭Zookeeper服务端
[root@hadoop100 bin]# ./zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /opt/module/apache-zookeeper-3.5.10-bin/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
[root@hadoop100 bin]# jps
119525 Jps

3 配置参数zoo.cfg解读

# The number of milliseconds of each tick
# 心跳时间帧
tickTime=2000 
# The number of ticks that the initial 
# synchronization phase can take
# 主从最大延迟时间:10个心跳帧
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
# 成功启动后,主从同步延迟时间:5个心跳帧
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/opt/module/apache-zookeeper-3.5.10-bin/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

标签:bin,10,配置,Zookeeper,3.5,zookeeper,apache,hadoop100,安装
From: https://www.cnblogs.com/tod4/p/17081150.html

相关文章