标签:
1.下载的Zookeeper是.cmd的批处理命令运行的,默认没有提供以windows服务的方式运行的方案
下载地址:http://zookeeper.apache.org/
2.下载prunsrv
下载地址:http://archive.apache.org/dist/commons/daemon/binaries/windows/
3.解压后复制文件
64位机器用amd64/prunsrv.exe
a. 复制 commons-daemon-1.0.15-bin-windows/amd64/prunsrv.exe 至 zookeeper-3.4.8\bin目录下
这是做服务的执行程序
b. 复制 commons-daemon-1.0.15-bin-windows/prunmgr.exe 至 zookeeper-3.4.8\bin目录下
监控服务配置及运行的程序
4.配置环境变量
添加ZOOKEEPER_SERVICE, ZOOKEEPER_HOME两个环境变量
ZOOKEEPER_SERVICE:服务名称(不要有中文)
ZOOKEEPER_HOME:设置到zookeeper-3.4.8目录下
5.在zookeeper-3.4.8\bin目录下添加一个 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
6.新建一个批处理安装文件:install.bat
内容如下:
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
最后在cmd中以管理员身份运行install.bat就OK了。
标签:
原文地址:http://www.cnblogs.com/mrluo735/p/5345879.html