一、首先打開WinSCP,登錄遠程服務器
二、打開Xshell,連接遠程服務器,使用Linux命令對遠程服務器進行操作。
三、使用Xshell命令框將遠程服務器路徑定位到zookeeper文件夾下
四、下載zookeeper-3.4.10,並解壓,復制三份放在/root/home/softwares/zookeeper路徑下。分別命名為zookeeper-3.4.10_1,ookeeper-3.4.10_2,ookeeper-3.4.10_3。
五、cd zookeeper-3.4.10_1/conf/命令,定位到conf路徑下,創建文件zoo.cfg
六、分別在zookeeper-3.4.10_1,zookeeper-3.4.10_3,zookeeper-3.4.10_3下創建data文件夾,並在data文件夾下創建logs文件夾
七、分別修改三個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=/home/softwares/zookeeper/zookeeper-3.4.10_1/data dataLogDir=/home/softwares/zookeeper/zookeeper-3.4.10_1/data/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=0.0.0.0:2888:3888 server.2=180.76.234.29:4888:5888 server.3=180.76.234.29:6888:788
1)由於是偽集群模式,所以三個clientPort端口號必須不一致,若在三台服務器上可以一樣。
2)server.X=A:B:C 其中
X:是一個數字,表示這是第幾號server
A: 是該server所在的IP地址
B: 配置該server和集群中的leader交換信息所使用的的端口
C: 配置選舉leader時所使用的端口,由於配置的是偽集群,所以各個server的B,C參數必須不同
八、分別在/zookeeper-3.4.10_1/data,/zookeeper-3.4.10_2/data,/zookeeper-3.4.10_3/data路徑下創建myid,並分別在文件里寫入1,2,3。
九、分別進入/zookeeper-3.4.10_1/bin,/zookeeper-3.4.10_2/bin,/zookeeper-3.4.10_3/bin目錄,輸入命令:./zkServer.sh start 啟動服務器。使用./zkServer.sh status命令查看三台服務器的運行狀態。使用./zkServer.sh stop 命令停止服務器運行。
十、使用偽集群模式必須關閉防火牆。若沒有關閉防火牆,會出現沒有路由連接到主機的錯誤。
rpm -qa 查看防火牆是否安裝
yum install iptables 如果防火牆沒有安裝,使用該命令安裝防火牆(必須聯網)
service iptable status 查看防火牆狀態
service iptable start 開啟防火牆
service iptable status 關閉防火牆