1. 程式人生 > >安裝和配置Storm環境第一步 安裝zookeeper環境 (一)

安裝和配置Storm環境第一步 安裝zookeeper環境 (一)

同步 自己 個數 get 5-0 安裝和配置 錯誤 resolve num

1.安裝配置Zookeeper

2.Storm的核心配置文件 $STORM_HOME/conf/storm.yaml

3.註意:如果要搭建Storm的HA(高可用性),nimbus即可.

4.把配置好的安裝包復制到其他節點上。

-- 自己搭建zookeeper集群

主節點:centos-00

從節點:centos-01,centos-02

(*)tar -zxvf zookeeper-xxx.tar.gz .

(*)設置環境變量 vi ~/.bash_profile

ZOOKEEPER_HOME=/usr/local/apps/zookeeper-3.4.6
export ZOOKEEPER_HOME

PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH

(*)編輯zookeeper配置文件/conf ---> zoo_sample.cfg

cp zoo_sample.cfg zoo.cfg -- 拷貝一份示例

dataDir=/tmp/zookeeper -- zookeeper保存數據的目錄 tmp目錄linux重啟時,數據會清除,需要修改 --> /usr/local/apps/zookeeper-3.5.2-alpha/tmp/

//zookeeper主機配置

zookeeper通信端口:選舉端口

server.1=192.168.2.20:2888:3888

server.2=192.168.2.21:2888:3888

server.3=192.168.2.22:2888:3888

在 /usr/local/apps/zookeeper-3.5.2-alpha/tmp 創建文件myid ,填寫server後的數字1,或2,或3代表zookeeper主機名

//復制zookeeper應用到第二第三臺主機

scp -r zookeeper-3.5.2-alpha/ [email protected]:/usr/local/apps

scp -r zookeeper-3.5.2-alpha/ [email protected]:/usr/local/apps

//三臺主機的環境變量刷新生效

source ~/.bash_profile

//修改另兩臺主機的myid的數字為2,3

//啟動zookeeper 並驗證

zkServer.sh start -- 三臺機器啟動

zkServer.sh status -- 查看運行狀態

第一臺主機是follower ,第二臺主機是leader,第三臺主機是follower

tips:zookeeper-3.5.2-alpha 版本3.5有點問題。啟動集群出錯,3.4無問題。記錄一下錯誤,後續再解決。

ZooKeeper 3.5.0 分布式配置好後,執行./zkServer.sh start 命令啟動,報如下錯誤:

2015-07-02 21:06:01,671 [myid:] - INFO [main:[email protected]] - Reading configuration from: /usr/zookeeper/bin/../conf/zoo.cfg
2015-07-02 21:06:01,682 [myid:] - ERROR [main:[email protected]] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Address unresolved: Master.Hadoop:3888 
    at org.apache.zookeeper.server.quorum.QuorumPeer$QuorumServer.<init>(QuorumPeer.java:205)
    at org.apache.zookeeper.server.quorum.flexible.QuorumMaj.<init>(QuorumMaj.java:89)
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.createQuorumVerifier(QuorumPeerConfig.java:401)
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseDynamicConfig(QuorumPeerConfig.java:425)
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:291)
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:126)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:110)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:79)
Invalid config, exiting abnormally

zookeeper特點 : 往一個節點寫入一個數據,其他節點會自動同步。

//先登錄到zookeeper主機的客戶端上

zkCli.sh

ls / 查看根節點的信息 [zookeeper] 只有一個節點

get / 獲取信息

zk: localhost:2181(CONNECTED) 0] get /

cZxid = 0x0
ctime = Wed Dec 31 16:00:00 PST 1969
mZxid = 0x0
mtime = Wed Dec 31 16:00:00 PST 1969
pZxid = 0x0
cversion = -1
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 1
[zk: localhost:2181(CONNECTED) 1] ls /
[zookeeper]

create /mydata hellworld 往第一個節點創建節點mydata,寫入數據helloworld

ls / 出現了[zookeeper, mydata]

[zk: localhost:2181(CONNECTED) 4]  ls /
[zookeeper, mydata]

get /mydata

zk: localhost:2181(CONNECTED) 6] get /mydata
helloworld
cZxid = 0x100000004
ctime = Tue Jul 18 14:37:22 PDT 2017
mZxid = 0x100000004
mtime = Tue Jul 18 14:37:22 PDT 2017
pZxid = 0x100000004
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 10
numChildren = 0

安裝和配置Storm環境第一步 安裝zookeeper環境 (一)