美文网首页
linux安装zookeeper

linux安装zookeeper

作者: 一个傻乎乎的少年 | 来源:发表于2019-03-29 20:56 被阅读0次

    小明的个人博客

    1:下载zookeeper源码包

    2:解压源码包,更换名称为zookeeper(这里名称随意),大致内容如下

    [root@10-10-127-163 tar]# tar -zxvf zookeeper-3.4.10.tar.gz  解压文件
    [root@10-10-127-163 tar]# mv zookeeper-3.4.10 /usr/local/bin/app/  移动文件到app目录
    [root@10-10-127-163 app]# mv zookeeper-3.4.10/ zookeeper 更换文件夹名称
    [root@10-10-127-163 zookeeper]# ll  文件夹内容
    总用量 1572
    drwxr-xr-x  2 1001 1001     141 3月  23 2017 bin
    -rw-rw-r--  1 1001 1001   84725 3月  23 2017 build.xml
    drwxr-xr-x  2 1001 1001      74 3月  23 2017 conf
    drwxr-xr-x 10 1001 1001     122 3月  23 2017 contrib
    drwxr-xr-x  2 1001 1001    4096 3月  23 2017 dist-maven
    drwxr-xr-x  6 1001 1001    4096 3月  23 2017 docs
    -rw-rw-r--  1 1001 1001    1709 3月  23 2017 ivysettings.xml
    -rw-rw-r--  1 1001 1001    5691 3月  23 2017 ivy.xml
    drwxr-xr-x  4 1001 1001    4096 3月  23 2017 lib
    -rw-rw-r--  1 1001 1001   11938 3月  23 2017 LICENSE.txt
    -rw-rw-r--  1 1001 1001    3132 3月  23 2017 NOTICE.txt
    -rw-rw-r--  1 1001 1001    1770 3月  23 2017 README_packaging.txt
    -rw-rw-r--  1 1001 1001    1585 3月  23 2017 README.txt
    drwxr-xr-x  5 1001 1001      44 3月  23 2017 recipes
    drwxr-xr-x  8 1001 1001    4096 3月  23 2017 src
    -rw-rw-r--  1 1001 1001 1456729 3月  23 2017 zookeeper-3.4.10.jar
    -rw-rw-r--  1 1001 1001     819 3月  23 2017 zookeeper-3.4.10.jar.asc
    -rw-rw-r--  1 1001 1001      33 3月  23 2017 zookeeper-3.4.10.jar.md5
    -rw-rw-r--  1 1001 1001      41 3月  23 2017 zookeeper-3.4.10.jar.sha1
    

    3:编辑配置文件

    切换到zookeeper目录下的conf目录下,重新复制一份zoo_sample.cfg文件并命名为zoo.cfg
    1 :配置dataDir ZK启动目录
    2: 配置dataLogDir 日志目录

    [root@10-10-127-163 zookeeper]# cd conf/
    [root@10-10-127-163 conf]# cp zoo_sample.cfg zoo.cfg  重新命名为zoo.cfg
    [root@10-10-127-163 conf]# vim 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 # 这里自定义配置
    dataLogDir=/tmp/zookeeper/log #自定义配置 存放日志文件
    # 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.
    #
    # 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
    

    4:配置环境变量

    [root@10-10-127-163 conf]# vim /etc/profile  添加下面2句
    export ZOOKEEPER=/usr/local/bin/app/zookeeper
    export PATH=$ZOOKEEPER/bin:$PATH
    [root@10-10-127-163 conf]# source /etc/profile  刷新配置文件
    

    5:启动zookeeper 任务目录下执行以下命令

    [root@10-10-127-163 zookeeper]# zkServer.sh start  启动zookeeper
    ZooKeeper JMX enabled by default
    Using config: /usr/local/bin/app/zookeeper/bin/../conf/zoo.cfg
    Starting zookeeper ... STARTED
    [root@10-10-127-163 zookeeper]#  zkServer.sh status  查看运行状态
    ZooKeeper JMX enabled by default
    Using config: /usr/local/bin/app/zookeeper/bin/../conf/zoo.cfg
    Mode: standalone  #显示standalone则说明启动成功
    [root@10-10-127-163 zookeeper]# 
    

    5:连接zookeeper

    [root@10-10-127-163 zookeeper]# zkCli.sh
    Connecting to localhost:2181
    2019-03-29 20:55:53,667 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT
    2019-03-29 20:55:53,671 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=localhost
    2019-03-29 20:55:53,671 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.8.0_131
    2019-03-29 20:55:53,673 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
    2019-03-29 20:55:53,673 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/usr/java/jdk1.8.0_131/jre
    2019-03-29 20:55:53,673 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/usr/local/bin/app/zookeeper/bin/../build/classes:/usr/local/bin/app/zookeeper/bin/../build/lib/*.jar:/usr/local/bin/app/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/bin/app/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/bin/app/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/usr/local/bin/app/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/local/bin/app/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/local/bin/app/zookeeper/bin/../zookeeper-3.4.10.jar:/usr/local/bin/app/zookeeper/bin/../src/java/lib/*.jar:/usr/local/bin/app/zookeeper/bin/../conf:
    2019-03-29 20:55:53,674 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
    2019-03-29 20:55:53,674 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
    2019-03-29 20:55:53,674 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>
    2019-03-29 20:55:53,674 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
    2019-03-29 20:55:53,674 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
    2019-03-29 20:55:53,674 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.10.0-862.9.1.el7.x86_64
    2019-03-29 20:55:53,674 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=root
    2019-03-29 20:55:53,674 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/root
    2019-03-29 20:55:53,674 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/tmp/zookeeper
    2019-03-29 20:55:53,676 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@277050dc
    Welcome to ZooKeeper!
    2019-03-29 20:55:53,703 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
    JLine support is enabled
    2019-03-29 20:55:53,781 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@876] - Socket connection established to localhost/127.0.0.1:2181, initiating session
    2019-03-29 20:55:53,811 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x169c98377480000, negotiated timeout = 30000
    [zk: localhost:2181(CONNECTED) 0] 
    WATCHER::
    
    WatchedEvent state:SyncConnected type:None path:null
    

    到此,zookeeper基本部署完成

    小明的个人博客

    相关文章

      网友评论

          本文标题:linux安装zookeeper

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