服务文件的下载
依赖环境的安装配置
1. 将下载好的JDK文件上传至服务器; 2. 使用 tar 命令对下载的 tar.gz 格式的文件进行解压缩操作; 3. 将解压后的文件目录移动至一个自定义的路径中(/opt); 4. 修改 /etc/profile 文件,在文件中加入如下信息(加入Java的环境变量配置信息) - export JAVA_HOME=/opt/jdk-11.0.23
- export JRE_HOME=${JAVA_HOME}/jre
- export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
- export PATH=${JAVA_HOME}/bin:$PATH
复制代码5. 是修改后的环境变量配置生效
服务的安装 1. 将下载好的Zookeeper安装bin文件上传至服务器
2. 使用 tar 指令对下载的压缩文件解压 - tar -zxf apache-zookeeper-3.8.4-bin.tar.gz
复制代码
3. 配置conf配置文件 - # 将conf目录下的zoo_sample.cfg复制一份, 命名为zoo.cfg;
- cp zoo_sample.cfg zoo.cfg
复制代码
4. 启动服务 - # 运行bin目录下的zkServer.sh
- sh zkServer.sh start
复制代码
5. 放行防火墙端口 - firewall-cmd --zone=public --add-port=2181/tcp --permanent
复制代码
6. 重新加载防火墙配置
服务的常用操作 - # 启动服务
- sh zkServer.sh start
- # 停止服务
- sh zkServer.sh stop
- # 重启服务
- sh zkServer.sh restart
复制代码
zoo.cfg - # The number of milliseconds of each tick
- tickTime=2000
- # The number of ticks that the initial
- # synchronization phase can take
- initLimit=10
- # The number of ticks that can pass between
- # sending a request and getting an acknowledgement
- syncLimit=5
- # the directory where the snapshot is stored.
- # do not use /tmp for storage, /tmp here is just
- # example sakes.
- dataDir=/tmp/zookeeper
- # 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.
- #
- # https://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
- ## Metrics Providers
- #
- # https://prometheus.io Metrics Exporter
- #metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
- #metricsProvider.httpHost=0.0.0.0
- #metricsProvider.httpPort=7000
- #metricsProvider.exportJvmInfo=true
复制代码
|