zookeeper3.5.5 centos7 徹底分佈式 搭建隨記

zookeeper3.5.5 centos7 徹底分佈式 搭建隨記

這裏是當初在三個ECS節點上搭建hadoop+zookeeper+hbase+solr的主要步驟,文章內容未通過潤色,請參考的同窗搭配其餘博客一同使用,並記得根據實際狀況調整相關參數html

 

0.prepare

準備奇數臺已經配置好jdk的節點 (奇數臺避免選舉leader時腦裂)centos

防火牆、ECS安全組安全

 

1. 指定位置解壓

 

2.配置環境變量

2. vi /etc/profile
export ZK_HOME=/opt/zookeeper/zookeeper-3.5.5 
export PATH=.:${JAVA_HOME}/bin:${SCALA_HOME}/bin:${SPARK_HOME}/bin:${ZK_HOME}/bin:$PATH

source /etc/profile

 

3. zoo.cfg

vi /.../zookeeper-3.5.5/conf/zoo.cfg

dataDir=/opt/zookeeper/data
dataLogDir=/opt/zookeeper/dataLog
server.1=Gwj:2888:3888
server.2=Ssj:2888:3888
server.3=Pyf:2888:3888

(主機名, 心跳端口、數據端口)

 

4. 建立dataDir和dataLogDir myid

按照上面的路徑(可自定義路徑和文件名)建立對應文件夾
並進入建立的data文件夾建立myid,各個節點myid要不同ssh

 

5. 啓動 關閉 檢驗

bin目錄下(zookeeper分佈式時要在每一個節點都進行啓動curl

zkServer.sh start/stop/status

 

正常啓動節點進程

ZooKeeper

	QuorumPeerMain

 

遇到的問題:

question1

1. Cannot open channel to 3 at election address Pyf/xxx.xxx.xxx.xxx:3888
	在zoo.cfg中將本機用節點 用  0.0.0.0  IP代替主機名
	測試後未解決
	
	檢查防火牆
		查看防火牆狀態---systemctl status firewalld
		關閉防火牆---systemctl status firewalld
		開機禁用---systemctl disable firewalld
		
		集羣須要修改成dead狀態
			firewalld.service - firewalld - dynamic firewall daemon
			Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
			Active: inactive (dead)
			Docs: man:firewalld(1)
		已是dead狀態,進行下一步排查
		
		
	centos集羣時間同步
		查看當前時區---timedatectl
		發現一個節點的時間不對,使用timedatectl set-timezone "Asia/Shanghai"修正時間
		
		從新啓動zookeeper,發現該問題解決
		更多有關centos時間的操做詳見https://www.cnblogs.com/zhi-leaf/p/6282301.html

 

question2

2. 從機啓動日誌connect timed out
	
	查詢本機公網ip---curl icanhazip.com
	查看內網ip---(在第一行顯示)ifconfig -a
	
	註釋掉 127.0.0.1 的配置
	
	事物日誌與快照日誌的查看方法
	(忘記貼了)
	
	sshd端口測試,例:
	ssh -v -p 2888 root@Gwj
	添加監聽端口(問題解決後我的感受應該是由於端口沒有打通,因此ssh沒有自動對2888進行監聽,之後發現問題時能夠)
	firewall-cmd --query-port=2888/tcp
	firewall-cmd --add-port=2888/tcp --permanent(no)
	firewall-cmd --reload
	firewall-cmd --reload*(yes)
相關文章
相關標籤/搜索