zoukankan      html  css  js  c++  java
  • Linux环境下安装zookeeper

    1. 下载安装文件zookeeper-3.4.6.tar.gz
     
    2. 还是copy到虚拟机的centos系统桌面
     
    3. 新建/usr/loca/zookeeper文件夹
    [root@localhost ~]# mkdir -pv /usr/local/zookeeper
     
    4.拷贝文件到指定文件夹
    [root@localhost ~]# cd /root/Desktop/
    [root@localhost ~]# cp ./zookeeper-3.4.6.tar.gz /usr/local/zookeeper
     
    5. 解压
    [root@localhost ~]# tar -zxvf jdk-8u121-linux-x64.tar.gz
     
    6. 配置环境变量
    [root@localhost ~]#cd /etc/
    [root@localhost ~]#cp ./profile ./profile.bak -- 把文件备份一下
    [root@localhost ~]#vi /etc/profile -- 编辑此配置文件
    在文件末尾添加此段内容: -- 开始和--中间的一段.(注意,尽量保持环境变量名全大写,下划线隔开. 保持规范)
    -- 开始
    export ZOOKEEPER_INSTALL=/usr/local/zookeeper/zookeeper-3.4.6/
    export PATH=$PATH:$ZOOKEEPER_INSTALL/bin
    -- 结束
     
    7. 配置文件修改
    [root@localhost zookeeper-3.4.6]# cd /usr/local/zookeeper/zookeeper-3.4.6/conf/ -- 进入文件所在路径
    [root@localhost conf]# cp zoo_sample.cfg zoo.cfg -- 将zoo.sample.cfg拷贝出一份zoo.cfg出来. 文件名强制
     
    8. 文件内容如下:
    [root@localhost conf]# vi zoo.cfg -- 按i进入编辑模式. 修改完成之后, esc退出编辑模式, 大写字母Z双击即可保存.
    # 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 -- 如果是多机器的话,在clientPort处添加服务器的ip
    # 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
     
    修改完之后 通过 > # cat zoo.cfg 查看.
     
     
    9. 开启服务,关闭服务, 查看
    [root@localhost bin]# cd /usr/local/zookeeper/zookeeper.3.4.6/bin/
    [root@localhost bin]# ./zkServer.sh stop -- 停止服务
    JMX enabled by default
    Using config: /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
    Stopping zookeeper ... STOPPED
     
    [root@localhost bin]# ./zkServer.sh start -- 开启服务
    JMX enabled by default
    Using config: /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
    Starting zookeeper ... STARTED
     
    [root@localhost bin]# ./zkServer.sh status -- 查看状态
    JMX enabled by default
    Using config: /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
    Mode: standalone
    [root@localhost bin]#
     
    [root@localhost bin]# ./zkCli.sh -- 客户端启动, 可以查看启动状态和日志
    Connecting to localhost:2181
    2017-03-08 06:15:26,918 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
    2017-03-08 06:15:26,923 [myid:] - INFO [main:Environment@100] - Client environment:host.name=localhost
    2017-03-08 06:15:26,923 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_121
    2017-03-08 06:15:26,925 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
    2017-03-08 06:15:26,926 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/local/java/jdk1.8.0_121/jre
    2017-03-08 06:15:26,926 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:
    2017-03-08 06:15:26,926 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
    2017-03-08 06:15:26,926 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
    2017-03-08 06:15:26,926 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA>
    2017-03-08 06:15:26,930 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux
    2017-03-08 06:15:26,930 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
    2017-03-08 06:15:26,930 [myid:] - INFO [main:Environment@100] - Client environment:os.version=2.6.32-431.el6.x86_64
    2017-03-08 06:15:26,931 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root
    2017-03-08 06:15:26,931 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root
    2017-03-08 06:15:26,931 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/usr/local/zookeeper/zookeeper-3.4.6/bin
    2017-03-08 06:15:26,940 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@277050dc
    Welcome to ZooKeeper!
    2017-03-08 06:15:27,039 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@975] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
    JLine support is enabled
    2017-03-08 06:15:27,290 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@852] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
    [zk: localhost:2181(CONNECTING) 0] 2017-03-08 06:15:27,445 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1235] - Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x15aae45f1330000, negotiated timeout = 30000
     
    WATCHER::
     
    WatchedEvent state:SyncConnected type:None path:null
     
    root@localhost bin]# ps -ef | grep zookeeper -- 查看zookeeper的服务进程. 看样子还是挺嗨的.
    root 9779 9774 0 05:26 pts/0 00:00:09 /usr/local/java/jdk1.8.0_121/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib: org.apache.zookeeper.ZooKeeperMain
    root 10188 10183 0 06:14 pts/0 00:00:00 /usr/local/java/jdk1.8.0_121/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib: org.apache.zookeeper.ZooKeeperMain
    root 10230 1 0 06:15 pts/1 00:00:01 /usr/local/java/jdk1.8.0_121/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
    root 10282 10277 0 06:15 pts/0 00:00:01 /usr/local/java/jdk1.8.0_121/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib: org.apache.zookeeper.ZooKeeperMain
    root 10314 8885 0 06:18 pts/0 00:00:00 grep zookeeper
    [root@localhost bin]#
     
    10 到此, zookeeper的单机版安装完成.
  • 相关阅读:
    SpringBoot学习之配置Redis
    安全测试12使用nmap工具识别系统指纹信息
    安全测试11nmap扫描开放的端口
    安全测试17渗透攻击Mysql数据库服务
    安全测试18渗透攻击Tomcat服务
    安全测试16漏洞扫描工具Nikto详细使用教程
    实用且靠谱的18个免费引流推广方法
    安全测试15Maltego详细使用教程
    安全测试14ARP侦查工具Netdiscover
    统计本机tcp连接情况分离排查问题
  • 原文地址:https://www.cnblogs.com/jimmy-muyuan/p/8748006.html
Copyright © 2011-2022 走看看