基础数据仓库环境搭建(三)Zookeeper的安装与配置和操作
Zookeeper概述
Zookeeper 是一個開源的分布式的,為分布式應用提供協調服務的 Apache 項目。它包含一個簡單的原語集,分布式應用程序可以基于它實現同步服務,配置維護和命名服務等
工作機制
領導者(leader),負責進行投票的發起和決議,更新系統狀態
學習者(learner),包括跟隨者(follower)和觀察者(observer),follower用于接受客戶端請求并給客戶端返回結果,在選主過程中參與投票 Observer可以接受客戶端連接,將寫請求轉發給leader,但observer不參加投票過 程,只同步leader的狀態,observer的目的是為了擴展系統,提高讀取速度
客戶端(client),請求發起方
zookeeper的應用場景
統一命名服務、統一的配置管理、統一集群管理、服務器節點動態上下線、軟負載均衡等
Zookeeper的下載與安裝
我是在我的三臺結點上方都安裝了Zookeeper
鏈接:https://pan.baidu.com/s/1h9EPReCFmNtH9lRsi4NGRg提取碼:8520
配置安裝
[root@node01 Zookeeper]# tar -zxvf apache-zookeeper-3.5.5-bin.tar.gz
文件夾重命名
[root@node01 Zookeeper]#
編輯一下conf下的zoo.sample.cfg
[root@node01 Zookeeper]#
[root@node01 zookeeper-3.5.5]#
cd conf[root@node01 conf]#
mv zoo_sample.cfg zoo.cfg[root@node01 conf]#
vim 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=/opt/apps/zookeeper-3.5.7/data # 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 #######################cluster########################## server.1=node04:2888:3888 server.2=node02:2888:3888 server.3=node03:2888:3888創建data文件夾,在文件夾下新建文件寫入id號
[root@node01 Zookeeper]#
mkdir data cd data/ vim myid
寫入id數字即可
修改環境變量
[root@node01 Zookeeper]# vi /etc/profile
#Zookeeper配置
export ZOOKEEPER_HOME=/opt/apps/zookeeper-3.5.7 export PATH=$PATH:$ZOOKEEPER_HOME/bin使環境變量生效
[root@node01 Zookeeper]#
簡單操作
啟動zookeeper服務
[root@node01 Zookeeper]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/SoftWare/Zookeeper/zookeeper-3.5.5/bin/…/conf/zoo.cfg
Starting zookeeper … STARTED
查看進程
[root@node01 Zookeeper]# jps
1777 ResourceManager
9987 QuorumPeerMain
1413 NameNode
10006 Jps
1614 SecondaryNameNode
#查看服務狀態
[root@node01 Zookeeper]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/SoftWare/Zookeeper/zookeeper-3.5.5/bin/…/conf/zoo.cfg
Mode: standalone
啟動客戶端
[root@node01 Zookeeper]# zkCli.sh
#退出客戶端
[zk: localhost:2181(CONNECTED) 1] quit
停止zookeeper服務器端
[root@node01 Zookeeper]# zkServer.sh stop
總結
以上是生活随笔為你收集整理的基础数据仓库环境搭建(三)Zookeeper的安装与配置和操作的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux突然连不上网,ping不通百度
- 下一篇: 使Element默认字体为中文