zoukankan      html  css  js  c++  java
  • Zookeeper集群安装

    转载请注明出处:http://www.cnblogs.com/blazer/p/4977217.html

    CentOs6.4 Zookeeper-3.4.6

    下载解压如图:

    当前目录为

    /home/BlazerHe/zookeeper/zookeeper-3.4.6/

    先创建个data和logs目录,你也可以创建到其他地方

    mkdir data
    mkdir logs

    修改配置文件zoo.cfg

    vi conf/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=/home/BlazerHe/zookeeper/zookeeper-3.4.6/data
    dataLogDir=/home/BlazerHe/zookeeper/zookeeper-3.4.6/logs
    # the port at which the clients will connect
    clientPort=2181
    server.1=test1:2888:3888
    #server.2=test1:2888:3888
    #server.3=test1:2889:3889
    # 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和dataLogDir为之前创建的目录

    配置zookeeper集群,需要配置server.x

    如下:

    在一台机器上,用端口来区分(你需要复制2个一模一样的目录作为server.2和server.3)

             如拷贝同样的目录

             /home/BlazerHe/zookeeper/zookeeper-3.4.6-server-2/

             /home/BlazerHe/zookeeper/zookeeper-3.4.6-server-3/

    server.1=test1:2887:3887
    server.2=test1:2888:3888
    server.3=test1:2889:3889

    在多台机器上,用IP来区分

    server.1=test1:2888:3888
    server.2=test2:2888:3888
    server.3=test3:2888:3888

    然后需要在配置的每一个zookeeper目录的dataDir目录下创建一个myid文件,内容为server.x中x的值

    echo 1 > /home/BlazerHe/zookeeper/zookeeper-3.4.6/data/myid

    最后可以启动了。

    sh bin/zkServer.sh start

    连接上去试试命令

    sh bin/zkCli.sh -server 127.0.0.1

    ls /

     

    如果出现如下错误:

    [zk: localhost:2181(CONNECTING) 1] stat2016-01-27 20:22:32,713 [myid:] - INFO  [main-SendThread(211.98.70.227:2181):ClientCnxn$SendThread@975] - Opening socket connection to server 211.98.70.227/211.98.70.227:2181. Will not attempt to authenticate using SASL (unknown error)

    则非常有可能的原因是:

    1.zoo.cfg里面配置的是ip

    2./etc/hosts里面没有127.0.0.1 localhost

    get /my_data

    set /my_data oknon.com

    get /my_data

    常用命令:

    sh bin/zkServer.sh status
  • 相关阅读:
    netty 服务端 启动阻塞主线程
    idea踩过的坑
    bat批量重命名
    图片上传
    TCP/IP入门指导
    CPU governor调节器汇总
    IT咨询顾问:一次吐血的项目救火
    python 数组
    Python字符串
    基于Python实现对各种数据文件的操作
  • 原文地址:https://www.cnblogs.com/blazer/p/4977217.html
Copyright © 2011-2022 走看看