centos7 下zookeeper 部署 单机多实例模式

  centos7 下zookeeper 部署

    本文参考https://www.linuxidc.com/Linux/2016-09/135052.htm

  1.创建/usr/local/zookeeper文件夹

    mkdir /usr/local/zookeeper

  2.进入/usr/local/zookeeper文件夹

    cd /usr/local/zookeeper

  3.下载zookeeper

    wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz 也可以自己下载到本地,然后上传到服务器

  4.解压zookeeper

    tar -zxvf zookeeper-3.4.9.tar.gz

  5.进入到 /usr/local/zookeeper/zookeeper-3.4.9/conf 目录中

    cd zookeeper-3.4.9/conf/

  6.复制 zoo_sample.cfg 文件的并命名为为 zoo.cfg:

    cp zoo_sample.cfg zoo.cfg

  7.用 vim 打开 zoo.cfg 文件并修改其内容为如下

    vim 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=/usr/local/zookeeper/zookeeper-3.4.9/data/data1

     # 数据文件夹
      dataDir=/usr/local/zookeeper/zookeeper-3.4.9/data/data1
 
      # 日志文件夹
      dataLogDir=/usr/local/zookeeper/zookeeper-3.4.9/logs/log1
 
      # 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

   8.保存并关闭 zoo.cfg 文件:

      按esc后,:wq   回车

   9.进入到 根目录中

    cd

   10.用 vim 打开 /etc/ 目录下的配置文件 profile

     vim /etc/profile

    加入:

     export ZOOKEEPER_HOME=/usr/local/services/zookeeper/zookeeper-3.4.9/
        export PATH=$ZOOKEEPER_HOME/bin:$PATH
        export PATH 

   11.使 /etc/ 目录下的 profile 文件即可生效

      source  /etc/profile

   12.启动 zookeeper 服务

      zkServer.sh start      (不指定配置文件的话默认为conf/zoo.cfg)

      如打印如下信息则表明启动成功:
          ZooKeeper JMX enabled by default
          Using config: /usr/local/zookeeper/zookeeper-3.4.9/bin/../conf/zoo.cfg
          Starting zookeeper ... STARTED

    13.常用的命令:

      查询 zookeeper 状态      zkServer.sh status

       关闭 zookeeper 服务    zkServer.sh stop

      重启zookeeper 服务    zkServer.sh  restart

    

配置单机多实例,需要复制一份zoo.cfg文件修改clientPort的端口号,修改dataDir 和 dataLogDir的路径,然后启动zookeeper,启动命令需要指定配置文件

    zkServer.sh start  ../conf/zooother.cfg

  

    

上一篇:程序自我销毁(VB源代码)


下一篇:【Python开发】Url中文字符时记得转码edcode("utf-8")