1. 程式人生 > >Zookeeper與HBase的安裝

Zookeeper與HBase的安裝

jar ota ted fault .class com 1.8 機器 aud

  一、Zookeeper的安裝

  1.http://www-us.apache.org/dist/zookeeper/stable/下載Zookeeper安裝包,並將zookeeper-3.4.12.tar.gz復制到/home/jun下並解壓

[jun@master ~]$ cd zookeeper-3.4.12/
[jun@master zookeeper-3.4.12]$ ls -l
total 1604
drwxr-xr-x.  2 jun jun     149 Mar 27 12:32 bin
-rw-rw-r--.  1 jun jun   87945 Mar 27 12:32 build.xml
drwxr
-xr-x. 2 jun jun 77 Mar 27 12:32 conf drwxr-xr-x. 10 jun jun 130 Mar 27 12:32 contrib drwxr-xr-x. 2 jun jun 4096 Mar 27 12:37 dist-maven drwxr-xr-x. 6 jun jun 4096 Mar 27 12:32 docs -rw-rw-r--. 1 jun jun 1709 Mar 27 12:32 ivysettings.xml -rw-rw-r--. 1 jun jun 8197 Mar 27 12:32 ivy.xml drwxr
-xr-x. 4 jun jun 4096 Mar 27 12:32 lib -rw-rw-r--. 1 jun jun 11938 Mar 27 12:32 LICENSE.txt -rw-rw-r--. 1 jun jun 3132 Mar 27 12:32 NOTICE.txt -rw-rw-r--. 1 jun jun 1585 Mar 27 12:32 README.md -rw-rw-r--. 1 jun jun 1770 Mar 27 12:32 README_packaging.txt drwxr-xr-x. 5 jun jun 47
Mar 27 12:32 recipes drwxr-xr-x. 8 jun jun 211 Mar 27 12:32 src -rw-rw-r--. 1 jun jun 1483366 Mar 27 12:32 zookeeper-3.4.12.jar -rw-rw-r--. 1 jun jun 819 Mar 27 12:36 zookeeper-3.4.12.jar.asc -rw-rw-r--. 1 jun jun 33 Mar 27 12:32 zookeeper-3.4.12.jar.md5 -rw-rw-r--. 1 jun jun 41 Mar 27 12:32 zookeeper-3.4.12.jar.sha1

  2.使用gedit編輯zoo.cfg配置文件

[jun@master zookeeper-3.4.12]$ cp /home/jun/zookeeper-3.4.12/conf/zoo_sample.cfg  /home/jun/zookeeper-3.4.12/conf/zoo.cfg
[jun@master zookeeper-3.4.12]$ gedit /home/jun/zookeeper-3.4.12/conf/zoo.cfg 

  將下面的配置增加到最後面,配置的意思是“服務器編號、服務器地址、LF通信端口(Leader與Follower)、選舉端口”

server.1=master:2888:3888
server.2=slave0:2888:3888
server.3=slave1:2888:3888

  3.創建節點標誌文件  

  由於在zoo.cfg當中配置了三臺服務器,每一臺服務器本地也需要一個myid文件,裏面包含服務器的ID號,需要在三臺機器上都創建myid文件。以master為例:

  首先遞歸創建目錄(-p)

[jun@master zookeeper-3.4.12]$ mkdir -p /tmp/zookeeper
[jun@master zookeeper-3.4.12]$ gedit /tmp/zookeeper/myid

  然後新建myid文件並輸入對應的id號,只輸入一個1即可。

[jun@master zookeeper-3.4.12]$ cat /tmp/zookeeper/myid 
1

  另外兩臺機器同理。

  4.將Zookeeper安裝文件從master復制到slave上(-r的意思是拷貝所有的文件和文件夾)

[jun@master zookeeper-3.4.12]$ scp -r /home/jun/zookeeper-3.4.12/   slave0:~
[jun@master zookeeper-3.4.12]$ scp -r /home/jun/zookeeper-3.4.12/   slave1:~

  5.Zookeeper集群的啟動

  (1)需要在三個節點上分別執行啟動操作

[jun@master zookeeper-3.4.12]$ /home/jun/zookeeper-3.4.12/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/jun/zookeeper-3.4.12/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

[jun@slave0 ~]$ /home/jun/zookeeper-3.4.12/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/jun/zookeeper-3.4.12/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

[jun@slave1 ~]$ /home/jun/zookeeper-3.4.12/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/jun/zookeeper-3.4.12/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

  (2)至少啟動兩臺服務器後,集群才會開始選舉leader節點,可以在三臺服務器上分別查看集群的狀態,可以看到slave0節點是leader節點。

[jun@master ~]$ /home/jun/zookeeper-3.4.12/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/jun/zookeeper-3.4.12/bin/../conf/zoo.cfg
Mode: follower

[jun@slave0 ~]$ /home/jun/zookeeper-3.4.12/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/jun/zookeeper-3.4.12/bin/../conf/zoo.cfg
Mode: leader

[jun@slave1 ~]$ /home/jun/zookeeper-3.4.12/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/jun/zookeeper-3.4.12/bin/../conf/zoo.cfg
Mode: follower

  (3)Zookeeper客戶端交互式操作

  

[jun@master ~]$ /home/jun/zookeeper-3.4.12/bin/zkCli.sh -server master:2181
Connecting to master:2181
2018-07-23 11:40:29,091 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.12-e5259e437540f349646870ea94dc2658c4e44b3b, built on 03/27/2018 03:55 GMT
2018-07-23 11:40:29,093 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=master
2018-07-23 11:40:29,093 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.8.0_171
2018-07-23 11:40:29,095 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2018-07-23 11:40:29,095 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/usr/java/jdk1.8.0_171/jre
2018-07-23 11:40:29,096 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/home/jun/zookeeper-3.4.12/bin/../build/classes:/home/jun/zookeeper-3.4.12/bin/../build/lib/*.jar:/home/jun/zookeeper-3.4.12/bin/../lib/slf4j-log4j12-1.7.25.jar:/home/jun/zookeeper-3.4.12/bin/../lib/slf4j-api-1.7.25.jar:/home/jun/zookeeper-3.4.12/bin/../lib/netty-3.10.6.Final.jar:/home/jun/zookeeper-3.4.12/bin/../lib/log4j-1.2.17.jar:/home/jun/zookeeper-3.4.12/bin/../lib/jline-0.9.94.jar:/home/jun/zookeeper-3.4.12/bin/../lib/audience-annotations-0.5.0.jar:/home/jun/zookeeper-3.4.12/bin/../zookeeper-3.4.12.jar:/home/jun/zookeeper-3.4.12/bin/../src/java/lib/*.jar:/home/jun/zookeeper-3.4.12/bin/../conf:
2018-07-23 11:40:29,096 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2018-07-23 11:40:29,096 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2018-07-23 11:40:29,096 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>
2018-07-23 11:40:29,096 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
2018-07-23 11:40:29,096 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2018-07-23 11:40:29,096 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.10.0-862.el7.x86_64
2018-07-23 11:40:29,096 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=jun
2018-07-23 11:40:29,096 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/home/jun
2018-07-23 11:40:29,096 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/home/jun
2018-07-23 11:40:29,097 [myid:] - INFO  [main:ZooKeeper@441] - Initiating client connection, connectString=master:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@799f7e29
Welcome to ZooKeeper!
2018-07-23 11:40:29,117 [myid:] - INFO  [main-SendThread(master:2181):ClientCnxn$SendThread@1028] - Opening socket connection to server master/192.168.1.100:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2018-07-23 11:40:29,186 [myid:] - INFO  [main-SendThread(master:2181):ClientCnxn$SendThread@878] - Socket connection established to master/192.168.1.100:2181, initiating session
2018-07-23 11:40:29,200 [myid:] - INFO  [main-SendThread(master:2181):ClientCnxn$SendThread@1302] - Session establishment complete on server master/192.168.1.100:2181, sessionid = 0x10000b7db500001, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: master:2181(CONNECTED) 0] helo
ZooKeeper -server host:port cmd args
    stat path [watch]
    set path data [version]
    ls path [watch]
    delquota [-n|-b] path
    ls2 path [watch]
    setAcl path acl
    setquota -n|-b val path
    history 
    redo cmdno
    printwatches on|off
    delete path [version]
    sync path
    listquota path
    rmr path
    get path [watch]
    create [-s] [-e] path data acl
    addauth scheme auth
    quit 
    getAcl path
    close 
    connect host:port
[zk: master:2181(CONNECTED) 1] help
ZooKeeper -server host:port cmd args
    stat path [watch]
    set path data [version]
    ls path [watch]
    delquota [-n|-b] path
    ls2 path [watch]
    setAcl path acl
    setquota -n|-b val path
    history 
    redo cmdno
    printwatches on|off
    delete path [version]
    sync path
    listquota path
    rmr path
    get path [watch]
    create [-s] [-e] path data acl
    addauth scheme auth
    quit 
    getAcl path
    close 
    connect host:port
[zk: master:2181(CONNECTED) 2] quit
Quitting...
2018-07-23 11:40:55,461 [myid:] - INFO  [main:ZooKeeper@687] - Session: 0x10000b7db500001 closed
2018-07-23 11:40:55,462 [myid:] - INFO  [main-EventThread:ClientCnxn$EventThread@521] - EventThread shut down for session: 0x10000b7db500001

Zookeeper與HBase的安裝