Window部署zookeeper
Posted StoryBoy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Window部署zookeeper相关的知识,希望对你有一定的参考价值。
准备:
下载zookeeper
下载jdk
安装配置
设置JAVA_HOME环境变量(配置好后,==注销电脑生效==):
以管理员身份运行:
wmic environment create name="JAVA_HOME",username="<system>",VariableValue="C:\Program Files\Java\jdk1.8.0_131"
配置
2.1 conf目录下 copy zoo_sample.cfg zoo.cfg 并修改配置
其他可默认,主要修改一下配置即可dataDir=G:\\Software\Architect\zookeeper-3.5.3-beta\data
2.2 集群配置initLimit=5
syncLimit=2
server.1=192.168.211.1:2888:3888
server.2=192.168.211.2:2888:3888测试
双击启动bin目录(G:\Software\Architect\zookeeper-3.5.3-beta\bin)的zkServer.cmd 查看端口是否正常:
netstat -aon | findstr 2181
监控zookeeper软件
zk ui部署
编译zkui:(懒人可直接下载编译好的资源zkui-2.0)
cd /d G:\Software\Architect\zkui-master
mvn clean install
将config.cfg拷贝到jar同目录下,并修改配置
cd /d G:\Software\Architect\zkui-master\target
copy ..\config.cfg .\
#Server Port
serverPort=9090
#Comma seperated list of all the zookeeper servers
zkServer=10.0.0.7:2181
#可调节连接zookeeper的超时时间
#zkSessionTimeout=20
启动zkui
java -jar zkui-2.0-SNAPSHOT-jar-with-dependencies.jar
制作成批处理zkuiStart.cmd
cd /d %~dp0
java -jar zkui-2.0-SNAPSHOT-jar-with-dependencies.jar
username: admin, pwd: manager
zookeeper未启动时,会报错误如下:
KeeperErrorCode = ConnectionLoss for /
将zookeeper做成windows服务
下载prunsrv
以管理员身份运行批处理(设置ZOOKEEPERSERVICE,ZOOKEEPERHOME环境变量):
wmic environment create name="ZOOKEEPER_SERVICE",username="<system>",VariableValue="zookeeperService"
wmic environment create name='ZOOKEEPER_HOME',username="<system>",VariableValue="G:\Software\Architect\zookeeper-3.5.3-beta"
拷贝文件
64位机器用amd64/prunsrv.exe
a. 复制 commons-daemon-1.0.15-bin-windows/amd64/prunsrv.exe 至 zookeeper\bin目录下
这是做服务的执行程序
b. 复制 commons-daemon-1.0.15-bin-windows/prunmgr.exe 至 zookeeper\bin目录下
install.bat安装脚本(放于zookeeper bin目录下):
prunsrv.exe "//IS//%ZOOKEEPER_SERVICE%" ^
--DisplayName="Zookeeper (%ZOOKEEPER_SERVICE%)" ^
--Description="Zookeeper (%ZOOKEEPER_SERVICE%)" ^
--Startup=auto --StartMode=exe ^
--StartPath=%ZOOKEEPER_HOME% ^
--StartImage=%ZOOKEEPER_HOME%\bin\zkServer.cmd ^
--StopPath=%ZOOKEEPER_HOME%\ ^
--StopImage=%ZOOKEEPER_HOME%\bin\zkServerStop.cmd ^
--StopMode=exe --StopTimeout=5 ^
--LogPath=%ZOOKEEPER_HOME% --LogPrefix=zookeeper-wrapper ^
--PidFile=zookeeper.pid --LogLevel=Info --StdOutput=auto --StdError=auto
zkServerStop.cmd停止服务:
@echo off
setlocal
TASKLIST /svc | findstr /c:"%ZOOKEEPER_SERVICE%" > %ZOOKEEPER_HOME%\zookeeper_svc.pid
FOR /F "tokens=2 delims= " %%G IN (%ZOOKEEPER_HOME%\zookeeper_svc.pid) DO (
@set zkPID=%%G
)
taskkill /PID %zkPID% /T /F
del %ZOOKEEPER_HOME%/zookeeper_svc.pid
endlocal
==特别的JAVAHOME一定要设置为系统变量,否则会报JAVAHOME未设置==
参考资料:
zk ui部署
安装成windows服务
以上是关于Window部署zookeeper的主要内容,如果未能解决你的问题,请参考以下文章
add application window with unknown token XXX Unable to add window;is your activity is running?(代码片段
add application window with unknown token XXX Unable to add window;is your activity is running?(代码片段