Zookeeper安裝使用--單機模式
1.version package準備
zookeeper-3.4.5.tar.gz
2.mkdir zookeeper folder.tar the package
mkdir zookeeper tar xvf zookeeper-3.4.5.tar.gz
[root@localhost zookeeper]# pwd /root/zookeeper [root@localhost zookeeper]# ll total 16024 drwxr-xr-x. 12 501 games 4096 Jan 30 07:30 zookeeper-3.4.5 -rw-r--r--. 1 root root 16402010Apr 29 2018 zookeeper-3.4.5.tar.gz [root@localhost zookeeper]#
3.將zookeeper-3.4.10/conf目錄下的zoo_sample.cfg文件拷貝一份,命名為zoo.cfg.然後修改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=/root/zookeeper/zookeeper-3.4.5/data dataLogsDir=/root/zookeeper/zookeeper-3.4.5/logs # the port at which the clients will connect clientPort=2181 # # 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 # server.1=192.168.106.133:2888:3888 # 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
4.配置myid文件
path:dataDir=/root/zookeeper/zookeeper-3.4.5/data 創建myid文件(編輯myid文件,並在對應的IP的機器上輸入對應的編號。如在zookeeper上,myid 文件內容就是1。如果只在單點上進行安裝配置,那麽只有一個server.1)
5.修改.bash_profile,增加zookeeper配置:path =etc/profile,編輯完成使profile文件夾生效:source etc/profile
# zookeeper env export ZOOKEEPER_HOME=/root/zookeeper/zookeeper-3.4.5 export PATH=$ZOOKEEPER_HOME/bin:$PATH
6.關閉防火墻
systemctl stop firewalld.service
7.測試Zookeeper
切換至/root/zookeeper/zookeeper-3.4.5/bin目錄中執行
./zkServer.sh start #查看進程 jps 其中,QuorumPeerMain是zookeeper進程,啟動正常。 #查看狀態 ./zkServer.sh status #服務器輸出信息 tail -500f zookeeper.out #停止zookeeper進程 ./zkServer.sh stop
8.設置zookeeper服務開機啟動
# 切換至/etc/rc.d/init.d/目錄下 cd /etc/rc.d/init.d [root@localhost init.d]# pwd -rwxr-xr-x. 1 root root 565 Jan 30 07:36 zookeeper /etc/rc.d/init.d # 創建zookeeper文件 touch zookeeper #更新權限 chmod +x zookeeper #編輯文件,在zookeeper裏面輸入如下內容
# chkconfig: 2345 10 90
# description: zookeeper
#processname:zookeeper
export JAVA_HOME=/root/jdk/jdk1.8.0_171
export PATH=$JAVA_HOME/bin:$PATH
case $1 in
start)su root /root/zookeeper/zookeeper-3.4.5/bin/zkServer.sh start;;
stop)su root /root/zookeeper/zookeeper-3.4.5/bin/zkServer.sh stop;;
status)su root /root/zookeeper/zookeeper-3.4.5/bin/zkServer.sh status;;
restart)su root /root/zookeeper/zookeeper-3.4.5/bin/zkServer.sh restart;;
*) echo "require start|stop|status|restart" ;;
esac
chkconfig --list驗證zookeeper是否添加開機啟動
[root@localhost init.d]# chkconfig --list netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off zookeeper 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@localhost init.d]#
Zookeeper安裝使用--單機模式