找回密码
 立即注册
搜索
热搜: Java Linux Docker
查看: 42|回复: 0

[Linux] Zookeeper的部署

[复制链接]

24

主题

1

回帖

4万

积分

管理员

积分
40166
发表于 2024-8-29 22:55:45 | 显示全部楼层 |阅读模式
服务文件的下载


依赖环境的安装配置
Zookeeper的运行依赖于JDK11+

1. 将下载好的JDK文件上传至服务器;
2. 使用 tar 命令对下载的 tar.gz 格式的文件进行解压缩操作;
3. 将解压后的文件目录移动至一个自定义的路径中(/opt);
4. 修改 /etc/profile 文件,在文件中加入如下信息(加入Java的环境变量配置信息)
  1. export JAVA_HOME=/opt/jdk-11.0.23
  2. export JRE_HOME=${JAVA_HOME}/jre
  3. export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
  4. export PATH=${JAVA_HOME}/bin:$PATH
复制代码
5. 是修改后的环境变量配置生效
  1. source /etc/profile
复制代码

服务的安装
1. 将下载好的Zookeeper安装bin文件上传至服务器


2. 使用 tar 指令对下载的压缩文件解压
  1. tar -zxf apache-zookeeper-3.8.4-bin.tar.gz
复制代码

3. 配置conf配置文件
  1. # 将conf目录下的zoo_sample.cfg复制一份, 命名为zoo.cfg;
  2. cp zoo_sample.cfg zoo.cfg
复制代码

4. 启动服务
  1. # 运行bin目录下的zkServer.sh
  2. sh zkServer.sh start
复制代码

5. 放行防火墙端口
  1. firewall-cmd --zone=public --add-port=2181/tcp --permanent
复制代码

6. 重新加载防火墙配置
  1. firewall-cmd --reload
复制代码


服务的常用操作
  1. # 启动服务
  2. sh zkServer.sh start

  3. # 停止服务
  4. sh zkServer.sh stop

  5. # 重启服务
  6. sh zkServer.sh restart
复制代码


zoo.cfg
  1. # The number of milliseconds of each tick
  2. tickTime=2000
  3. # The number of ticks that the initial
  4. # synchronization phase can take
  5. initLimit=10
  6. # The number of ticks that can pass between
  7. # sending a request and getting an acknowledgement
  8. syncLimit=5
  9. # the directory where the snapshot is stored.
  10. # do not use /tmp for storage, /tmp here is just
  11. # example sakes.
  12. dataDir=/tmp/zookeeper
  13. # the port at which the clients will connect
  14. clientPort=2181
  15. # the maximum number of client connections.
  16. # increase this if you need to handle more clients
  17. #maxClientCnxns=60
  18. #
  19. # Be sure to read the maintenance section of the
  20. # administrator guide before turning on autopurge.
  21. #
  22. # https://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
  23. #
  24. # The number of snapshots to retain in dataDir
  25. #autopurge.snapRetainCount=3
  26. # Purge task interval in hours
  27. # Set to "0" to disable auto purge feature
  28. #autopurge.purgeInterval=1

  29. ## Metrics Providers
  30. #
  31. # https://prometheus.io Metrics Exporter
  32. #metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
  33. #metricsProvider.httpHost=0.0.0.0
  34. #metricsProvider.httpPort=7000
  35. #metricsProvider.exportJvmInfo=true
复制代码




本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|saotolls Inc.

GMT+8, 2025-11-8 18:18 , Processed in 0.156912 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表