XXXXX
C/C++
XXXXX
C#/.net
XXXXX
js
java
java
开发导航 开发导航 www.endv.cn
天云

Windows 创建 Redis 和 zookeeper 系统服务

Redis

启动 Redis

start cmd /k "cd/d c:\Redis-x64-3.2.100\&&echo start Redis &&redis-server.exe redis.windows.conf"

将 Redis 其注册为windows的服务: 

redis-server --service-install redis.windows-service.conf --loglevel verbose

下载zookeeper服务插件(zip包)

http://archive.apache.org/dist/commons/daemon/binaries/windows/

本站下载 https://files.cnblogs.com/files/endv/prunsrv.7z

2.把prunsrv.exe、prunmgr.exe复制到zookeeper的bin路径下

修改zookeeper下面的文件/zookeeper/conf/zoo_sample.cfg下面的文件,改名为zoo.cfg,因为zookeeper默认使用的文件名是zoo.cfg 

修改zoo.cfg文件的日志路径且路径必须存在

#dataDir=/tmp/zookeeper
dataDir=C:\apache-zookeeper-3.5.5

创建系统环境变量

 zookeeper 的路径

ZOOKEEPER_HOME = C:\apache-zookeeper-3.5.5

ZOOKEEPER_SERVICE = 你 server 的名称

创建并在cmd中以管理员启动install.bat文件

 1 prunsrv.exe "//IS//%ZOOKEEPER_SERVICE%" ^
 2         --DisplayName="Zookeeper (%ZOOKEEPER_SERVICE%)" ^
 3         --Description="Zookeeper (%ZOOKEEPER_SERVICE%)" ^
 4         --Startup=auto --StartMode=exe ^
 5         --StartPath=%ZOOKEEPER_HOME% ^
 6         --StartImage=%ZOOKEEPER_HOME%\bin\zkServer.cmd ^
 7         --StopPath=%ZOOKEEPER_HOME%\ ^
 8         --StopImage=%ZOOKEEPER_HOME%\bin\zkServerStop.cmd ^
 9         --StopMode=exe --StopTimeout=5 ^
10         --LogPath=%ZOOKEEPER_HOME% --LogPrefix=zookeeper-wrapper ^
11         --PidFile=zookeeper.pid --LogLevel=Info --StdOutput=auto --StdError=auto
install.bat
stop
1 @echo off
2 setlocal
3 TASKLIST /svc | findstr /c:"%ZOOKEEPER_SERVICE%" > %ZOOKEEPER_HOME%\zookeeper_svc.pid
4 FOR /F "tokens=2 delims= " %%G IN (%ZOOKEEPER_HOME%\zookeeper_svc.pid) DO (
5     @set zkPID=%%G
6 )
7 taskkill /PID %zkPID% /T /F
8 del %ZOOKEEPER_HOME%/zookeeper_svc.pid
9 endlocal
zkServerStop.cmd

delete
sc delete zookeeper-3.5.5

 

posted @ 2019-07-25 16:14  Endv  阅读(361)  评论(0编辑  收藏  举报