美文网首页
centOS 7 安装zookeeper 单节点(安装前需要安装

centOS 7 安装zookeeper 单节点(安装前需要安装

作者: SetsunaHao | 来源:发表于2019-01-01 16:00 被阅读0次

上传安装包并且解压

将安装包上传到 linux服务器 zookeeper-3.5.2-alpha.tar.gz
tar -zvxf zookeeper-3.5.2-alpha.tar.gz
 可以专门定义存放数据文件和日志文件的夹
 mkdir data #数据文件存储位置
 mkdir logs #日志文件存储位置
cd zookeeper-3.5.2-alpha/conf/
 cp zoo_sample.cfg zoo.cfg
   用 vi 打开 zoo.cfg 文件并修改其内容为如下:
    # The number of milliseconds of each tick
    # zookeeper 定义的基准时间间隔,单位:毫秒
    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
 
    # 数据文件夹
    dataDir=/usr/local/services/zookeeper/zookeeper-3.4.9/data
 
    # 日志文件夹
    dataLogDir=/usr/local/services/zookeeper/zookeeper-3.4.9/logs
 
    # the port at which the clients will connect
    # 客户端访问 zookeeper 的端口号
    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
   # 数据文件夹
    dataDir=/usr/local/services/zookeeper/zookeeper-3.4.9/data
 
    # 日志文件夹
    dataLogDir=/usr/local/services/zookeeper/zookeeper-3.4.9/logs
 vi /etc/profile
source /etc/profile
zkServer.sh start

使用jps打印出如下

jps

38347 Jps
38303 QuorumPeerMain
zkServer.sh status
zkServer.sh stop
zkServer.sh restart

开机自启脚本

zoo是自己新建的

vim /etc/init.d/zoo

加入以下脚本
#!/bin/sh
# chkconfig: 345 99 10
# description: Auto-starts zookeeper
# /etc/init.d/zoo
# zookeeper auto-start

export JAVA_HOME=/usr/java/jdk1.8.0_144
export JRE_HOME=/usr/java/jdk1.8.0_144/jre
zoo=/opt/frank/zookeeper/zookeeper-3.4.9/bin/zkServer.sh

case "$1" in
start) 
       $zoo start
       ;;
stop)  
       $zoo stop
       ;;
status)  
       $zoo status
       ;;                                                
restart)
       $zoo restart
        ;;
*)
       echo "require start|stop|status|restart"
       ;;
esac


修改启动文件的权限
chmod +x /etc/init.d/zoo

设定开机启动服务
chkconfig zoo on 

启动,停止zoo
service zoo start  
service zoo stop   


firewall-cmd --zone=public --add-port=2181/tcp --permanent

查看防火墙状态
firewall-cmd --state

相关文章

网友评论

      本文标题:centOS 7 安装zookeeper 单节点(安装前需要安装

      本文链接:https://www.haomeiwen.com/subject/zzbnlqtx.html