1. 程式人生 > >ZooKeeper安裝執行

ZooKeeper安裝執行

ZooKeeper是Hadoop的正式子專案,它是一個針對大型分散式系統的可靠協調系統,提供的功能包括:配置維護、名字服務、分散式同步、組服務等。ZooKeeper的目標就是封裝好複雜易出錯的關鍵服務,將簡單易用的介面和效能高效、功能穩定的系統提供給使用者。

Zookeeper是Google的Chubby一個開源的實現.是高有效和可靠的協同工作系統.Zookeeper能夠用來leader選舉,配置資訊維護等.在一個分散式的環境中,我們需要一個Master例項或儲存一些配置資訊,確保檔案寫入的一致性等.Zookeeper能夠保證如下3點:

  • Watches are ordered with respect to other events, other watches, and
    asynchronous replies. The ZooKeeper client libraries ensures that
    everything is dispatched in order.
  • A client will see a watch event for a znode it is watching before seeing the new data that corresponds to that znode.
  • The order of watch events from ZooKeeper corresponds to the order of the updates as seen by the ZooKeeper service.

在Zookeeper中,znode是一個跟Unix檔案系統路徑相似的節點,可以往這個節點儲存或獲取資料.如果在建立znode時Flag設定 為EPHEMERAL,那麼當這個建立這個znode的節點和Zookeeper失去連線後,這個znode將不再存在在Zookeeper 裡.Zookeeper使用Watcher察覺事件資訊,當客戶端接收到事件資訊,比如連線超時,節點資料改變,子節點改變,可以呼叫相應的行為來處理數 據.Zookeeper的Wiki頁面展示瞭如何使用Zookeeper來處理事件通知,佇列,優先佇列,鎖,共享鎖,可撤銷的共享鎖,兩階段提交.

 首先下載最新版 zookeeper-3.4.5.tar.gz

 然後解壓

 tar zxvf zookeeper-3.4.5.tar.gz

 然後進入conf目錄修改zoo_sample.cfg為zoo.cfg

然後vi 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
# the port at which the clients will connect
clientPort=2181
#
# 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

編輯儲存後進入bin目錄執行

 ./zkServer.sh start

[[email protected] bin]# ./zkCli.sh
Connecting to localhost:2181
2013-01-16 14:36:22,484 [myid:] - INFO  [main:[email protected]] - Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT
2013-01-16 14:36:22,488 [myid:] - INFO  [main:[email protected]] - Client environment:host.name=localhost.localdomain
2013-01-16 14:36:22,489 [myid:] - INFO  [main:[email protected]] - Client environment:java.version=1.6.0_29
2013-01-16 14:36:22,489 [myid:] - INFO  [main:[email protected]] - Client environment:java.vendor=Sun Microsystems Inc.
2013-01-16 14:36:22,490 [myid:] - INFO  [main:[email protected]] - Client environment:java.home=/usr/java/jdk1.6.0_29/jre
2013-01-16 14:36:22,490 [myid:] - INFO  [main:[email protected]] - Client environment:java.class.path=/usr/local/zookeeper-3.4.5/bin/../build/classes:/usr/local/zookeeper-3.4.5/bin/../build/lib/*.jar:/usr/local/zookeeper-3.4.5/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper-3.4.5/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper-3.4.5/bin/../lib/netty-3.2.2.Final.jar:/usr/local/zookeeper-3.4.5/bin/../lib/log4j-1.2.15.jar:/usr/local/zookeeper-3.4.5/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper-3.4.5/bin/../zookeeper-3.4.5.jar:/usr/local/zookeeper-3.4.5/bin/../src/java/lib/*.jar:/usr/local/zookeeper-3.4.5/bin/../conf:./:/usr/java/jdk1.6.0_29/lib:/usr/java/jdk1.6.0_29/jre/lib
2013-01-16 14:36:22,491 [myid:] - INFO  [main:[email protected]] - Client environment:java.library.path=/usr/java/jdk1.6.0_29/jre/lib/i386/client:/usr/java/jdk1.6.0_29/jre/lib/i386:/usr/java/jdk1.6.0_29/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
2013-01-16 14:36:22,491 [myid:] - INFO  [main:[email protected]] - Client environment:java.io.tmpdir=/tmp
2013-01-16 14:36:22,491 [myid:] - INFO  [main:[email protected]] - Client environment:java.compiler=<NA>
2013-01-16 14:36:22,492 [myid:] - INFO  [main:[email protected]] - Client environment:os.name=Linux
2013-01-16 14:36:22,492 [myid:] - INFO  [main:[email protected]] - Client environment:os.arch=i386
2013-01-16 14:36:22,493 [myid:] - INFO  [main:[email protected]] - Client environment:os.version=2.6.18-308.24.1.el5
2013-01-16 14:36:22,493 [myid:] - INFO  [main:[email protected]] - Client environment:user.name=root
2013-01-16 14:36:22,493 [myid:] - INFO  [main:[email protected]] - Client environment:user.home=/root
2013-01-16 14:36:22,494 [myid:] - INFO  [main:[email protected]] - Client environment:user.dir=/usr/local/zookeeper-3.4.5/bin
2013-01-16 14:36:22,496 [myid:] - INFO  [main:[email protected]] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 [email protected]
Welcome to ZooKeeper!
2013-01-16 14:36:22,592 [myid:] - INFO  [main-SendThread(localhost.localdomain:2181):[email protected]] - Opening socket connection to server localhost.localdomain/127.0.0.1:2181. Will not attempt to authenticate using SASL (無法定位登入配置)
2013-01-16 14:36:22,601 [myid:] - INFO  [main-SendThread(localhost.localdomain:2181):[email protected]] - Socket connection established to localhost.localdomain/127.0.0.1:2181, initiating session
JLine support is enabled
2013-01-16 14:36:22,693 [myid:] - INFO  [main-SendThread(localhost.localdomain:2181):[email protected]] - Session establishment complete on server localhost.localdomain/127.0.0.1:2181, sessionid = 0x13c3c5224cc0000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] help
ZooKeeper -server host:port cmd args
        connect host:port
        get path [watch]
        ls path [watch]
        set path data [version]
        rmr path
        delquota [-n|-b] path
        quit 
        printwatches on|off
        create [-s] [-e] path data acl
        stat path [watch]
        close 
        ls2 path [watch]
        history 
        listquota path
        setAcl path acl
        getAcl path
        sync path
        redo cmdno
        addauth scheme auth
        delete path [version]
        setquota -n|-b val path
[zk: localhost:2181(CONNECTED) 1] create /my_data "data.ch.com"
Created /my_data
[zk: localhost:2181(CONNECTED) 2] get /my_data
"data.ch.com"
cZxid = 0x2
ctime = Wed Jan 16 14:38:20 CST 2013
mZxid = 0x2
mtime = Wed Jan 16 14:38:20 CST 2013
pZxid = 0x2
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 13
numChildren = 0
[zk: localhost:2181(CONNECTED) 3] set /my_date "123456.com"
Node does not exist: /my_date
[zk: localhost:2181(CONNECTED) 4] set /my_data "123456.com"
cZxid = 0x2
ctime = Wed Jan 16 14:38:20 CST 2013
mZxid = 0x4
mtime = Wed Jan 16 14:38:58 CST 2013
pZxid = 0x2
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 12
numChildren = 0
[zk: localhost:2181(CONNECTED) 5] get /my_data
"123456.com"
cZxid = 0x2
ctime = Wed Jan 16 14:38:20 CST 2013
mZxid = 0x4
mtime = Wed Jan 16 14:38:58 CST 2013
pZxid = 0x2
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 12
numChildren = 0
[zk: localhost:2181(CONNECTED) 6] create /mytemp "你好嗎"
Created /mytemp
[zk: localhost:2181(CONNECTED) 7] get /myt
Node does not exist: /myt
[zk: localhost:2181(CONNECTED) 8] get /mytemp
"你好嗎"
cZxid = 0x5
ctime = Wed Jan 16 14:40:44 CST 2013
mZxid = 0x5
mtime = Wed Jan 16 14:40:44 CST 2013
pZxid = 0x5
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 11
numChildren = 0
[zk: localhost:2181(CONNECTED) 9] get /mytemp
"你好嗎"
cZxid = 0x5
ctime = Wed Jan 16 14:40:44 CST 2013
mZxid = 0x5
mtime = Wed Jan 16 14:40:44 CST 2013
pZxid = 0x5
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 11
numChildren = 0
[zk: localhost:2181(CONNECTED) 10] get /my_data
"123456.com"
cZxid = 0x2
ctime = Wed Jan 16 14:38:20 CST 2013
mZxid = 0x4
mtime = Wed Jan 16 14:38:58 CST 2013
pZxid = 0x2
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 12
numChildren = 0
[zk: localhost:2181(CONNECTED) 11] ls
ZooKeeper -server host:port cmd args
        connect host:port
        get path [watch]
        ls path [watch]
        set path data [version]
        rmr path
        delquota [-n|-b] path
        quit 
        printwatches on|off
        create [-s] [-e] path data acl
        stat path [watch]
        close 
        ls2 path [watch]
        history 
        listquota path
        setAcl path acl
        getAcl path
        sync path
        redo cmdno
        addauth scheme auth
        delete path [version]
        setquota -n|-b val path
[zk: localhost:2181(CONNECTED) 12] 

相關推薦

dubbo 之 zookeeper安裝執行

zookeeper的安裝很簡單,下載地址:https://www.apache.org/dyn/closer.cgi/zookeeper/,http://mirror.bit.edu.cn/apache/zookeeper/ 本人使用的是3.4.13版本,使用步驟: 1.下載完後,然後解

ZooKeeper安裝執行

ZooKeeper是Hadoop的正式子專案,它是一個針對大型分散式系統的可靠協調系統,提供的功能包括:配置維護、名字服務、分散式同步、組服務等。ZooKeeper的目標就是封裝好複雜易出錯的關鍵服務,將簡單易用的介面和效能高效、功能穩定的系統提供給使用者。Zookeeper

ZooKeeper安裝執行

star chapter this ons apt java mark itl init 首先從官網下載ZooKeeper壓縮包,然後解壓下載得到的ZooKeeper壓縮包,發現有“bin,conf,lib”等文件夾。“bin文件夾”中存放有執行腳本。“

Zookeeper安裝執行

 zookeeper的安裝分為三種模式:單機模式、叢集模式和偽叢集模式。 單機模式     首先,從Apache官網下載一個Zookeeper穩定版本,本次教程採用的是zookeeper-3.4.9版本。

Zookeeper以Windows服務安裝執行

1.下載的Zookeeper是.cmd的批處理命令執行的,預設沒有提供以windows服務的方式執行的方案   下載地址:http://zookeeper.apache.org/ 2.下載prunsrv  3.解壓後複製檔案    64位機器用amd64/prunsrv.exe   a. 複製 commo

zookeeper安裝以及配置和註意事項

zk1,安裝 wget tar zxvf zookeeper-3.4.9.tar.gz cd zookeeper-3.4.9/conf cp zoo_sample.cfg zoo.cfg 修改zoo.cfg配置文件 如下tickTime=2000 initLimit=10 syncLi

zookeeper安裝及部署

img ise size nap alt alias 沒有 color nts 閱讀目錄 一. 單機安裝、配置 二. 集群安裝、配置 安裝及部署 回到頂部 一. 單機安裝、配置 1、下載zookeeper二進制安裝包 下載 curl -L -O http:/

zookeeper安裝筆記

etc cli 數值 zookeeper 關閉 其他 自己 裏的 port 安裝zookeeper,將zookeeper上傳到三個服務器,保存在/usr/local/zookeeper目錄下,解壓tar包  tar -xzvf zookeeper-3.4.6.tar.gz 

Zookeeper安裝

狀態 mkdir zookeeper 修改配置 .sh bash 配置 查看 etc (1)解壓 tar -zxvf zookeeper-3.4.5.tar.gz(2)重命名 mv zookeeper-3.4.5 zookeeper(重命名文件夾 zookeeper-3.4

ZooKeeper安裝部署

sa0x01 簡介Zookeeper是一個很好的集群管理工具,被大量用於分布式計算。如Hadoop以及Storm系統中。Apache ZooKeeper是一個為分布式應用所設計開源協調服務,其設計目是為了減輕分布式應用程序所承擔的協調任務。可以為用戶提供同步、配置管理、分組和命名服務。0x02 環境說明在三臺

Zookeeper 安裝及集群配置註意點

打印 文件 https .com ubun blog 如果 啟動失敗 ron Zookeeper在ubuntu下安裝及集群搭建,關於集群搭建,網上很多文章 可以參考:https://www.ibm.com/developerworks/cn/opensource/os-cn

Linux鞏固記錄(6) Hbase環境準備-zookeeper安裝

this 分析 時間同步 all zone direct .org def ech Hbase是運行在hadoop之上,所以請參考第3篇文章搭建好一個master,兩個slave的hadoop環境,我采用的版本為hadoop2.7.4 不了解Hbase的同學可以參考下這篇文

Zookeeper詳解(二):Zookeeper安裝

zookeeper安裝安裝環境:CentOS 7 內存1GBJDK版本:1.8.0_112為JDK配置如下環境變量:編輯/etc/profile.d/jdk.sh#!/bin/bash JAVA_HOME=/usr/local/jdk1.8.0_112 export PATH=$JAVA_HOME/bi

linux中zookeeper安裝

系統 關閉防火墻 entos cal centos6.4 發的 .gz mil 1.7 安裝環境: Linux:centos6.4 Jdk:1.7以上版本 Zookeeper是java開發的可以運行在windows、linux環境。需要先安裝jdk。 安裝步驟: 第一步

QXDM安裝執行失敗(意外退出代碼:-1073741515)問題

執行 gpo 文件丟失 cred 動態 clas mage ima c++ 下了個QXDM,安裝版本是QXDM.WIN.04.00.182.Installer 常規的安裝,然後彈出意外退出提示: 此時嘗試進入已創建的QXDM目錄,運行DownloadFile.e

zookeeper安裝教程

求和 地址 客戶 dfs 文件結構 過多 .sh 1=1 文件 Zookeeper基礎知識、體系結構、數據模型 ? zookeeper是一個類似hdfs的樹形文件結構, zookeeper可以用來保證數據在(zk)集群之間的數據的事務性一致 ? zookeeper有wa

zookeeper安裝及環境變量設置

RM div enabled args setacl sim 啟動 .cn fault 下載 首先去官網下載(自行選擇版本):http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.11/然後執行tar -zxvf解壓

CentOS7 安裝執行 VmwareCore

powershell core vmware centos7 過去2年開始微軟一直在沸沸揚揚地宣傳PowerShell core,可以允許Windows的管理員在Linux/OSX 平臺執行Powershell的管理命令。很多第三方的廠商也紛紛推出了自己的管理模塊。不過對比起Windows下面的P

zookeeper安裝文檔

創建 log border 參考 idt 端口 datadir bin tps 1.下載Zookeeper安裝包 https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.10/ 2.zookee

zookeeper安裝教程(zookeeper3.4.5為例)

time 註意 doc tle lba class onf 好的 .org zookeeper有單機、偽集群、集群三種部署方式,可根據自己對可靠性的需求選擇合適的部署方式。下邊對這三種部署方式逐一進行講解。 一、單機安裝 1.1 下載 進入要下載的版本的目錄,選擇.ta