Zookeeper3.4.9分布式集群安裝


一、依賴文件安裝

    1.1 JDK

         參見博文:http://www.cnblogs.com/liugh/p/6623530.html

二、文件准備

     2.1 文件名稱

         zookeeper-3.4.9.tar.gz

     2.2 下載地址

        http://apache.fayea.com/zookeeper/

    

三、工具准備

    3.1 Xshell

      一個強大的安全終端模擬軟件,它支持SSH1, SSH2, 以及Microsoft Windows 平台的TELNET 協議。

      Xshell 通過互聯網到遠程主機的安全連接以及它創新性的設計和特色幫助用戶在復雜的網絡環境中享受他們的工作。

    3.2 Xftp

     一個基於 MS windows 平台的功能強大的SFTPFTP 文件傳輸軟件。

    使用了 Xftp 以后,MS windows 用戶能安全地在UNIX/Linux 和 Windows PC 之間傳輸文件。

四、部署圖

五、Zookeeper安裝

    以下操作,均使用root用戶

   5.1 通過Xftp將下載下來的Zookeeper安裝文件上傳到Leader及兩個Follower的/usr目錄下

   5.2 通過Xshell連接到虛擬機,在Leader及兩個Follower上,執行如下命令,解壓文件:

        # tar zxvf zookeeper-3.4.9.tar.gz 

   5.3 在Leader上,使用Vi編輯器,設置環境變量

        # vi /etc/profile

        在文件最后,添加如下內容:       

#Zookeeper Env

export ZOOKEEPER_HOME=/usr/zookeeper-3.4.9
export PATH=$PATH:$ZOOKEEPER_HOME/bin

   5.4 退出vi編輯器,使環境變量設置立即生效

       # source /etc/profile

       通過scp命令,將/etc/profile拷貝到兩個Follower節點:

       #scp /etc/profile root@DEV-SH-MAP-02:/etc

       #scp /etc/profile root@DEV-SH-MAP-03:/etc

       分別在兩個Follower節點上執行# source /etc/profile使其立即生效

六、Zookeeper配置

    以下操作均在Leader節點,配置完后,使用scp命令,將配置文件拷貝到兩個Follower節點即可。

   6.1 zoo.cfg配置文件

    切換到/usr/zookeeper-3.4.9/conf/目錄下

    將zoo_sample.cfg重命名為zoo.cfg

    #mv 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=/usr/zookeeper-3.4.9/data
dataLogDir=/usr/zookeeper-3.4.9/logs
# 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

server.1=DEV-SH-MAP-01:2888:3888
server.2=DEV-SH-MAP-02:2888:3888
server.3=DEV-SH-MAP-03:2888:3888

     其中:

       1)server.1 中的“1”可以是其他的數字或字符, 用來標識服務器,這個標識要寫到前面設置的目錄文件夾下的myid文件里

       2)2888為Leader服務端口,3888為選舉時所用的端口

   拷貝配置文件到兩個Follower節點:

   在Leader節點,執行如下命令:   

   # scp zoo.cfg root@DEV-SH-MAP-02:/usr/zookeeper-3.4.9/conf/

   # scp zoo.cfg root@DEV-SH-MAP-03:/usr/zookeeper-3.4.9/conf/

 6.2 myid文件

     切換到/usr/zookeeper-3.4.9/data目錄下

     執行命令:echo "1" > myid

     注:如果是在Follower上執行,需要執行命令:

     echo "2" > myid

     或

     echo "3" > myid

     這里的2和3就是前面配置文件中設置的數字

七、Zookeeper使用

   7.1 啟動Zookeeper集群

       分別在Leader及兩個Follower上執行命令:

       zkServer.sh start

  7.2 查看Zookeeper狀態

      執行如下命令:

      zkServer.sh status

 7.3 停止Zookeeper

      zkServer.sh stop

 7.4 重啟Zookeeper

      zkServer.sh restart


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM