1、windows环境下zookeeper安装
下载地址:http://zookeeper.apache.org/releases.html
下载之后解压,主要目录如下,我的版本是zookeeper-3.3.6
复制并修改 conf 文件夹下的 simple_zoo.cfg 为 zoo.cfg ,主要修改配置中的 dataDir ,根据自己实际修改即可,如下
# 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. dataDir=G:\zookeeper\data # the port at which the clients will connect clientPort=2181
最后命令行进入到 bin 目录执行 zkserver.cmd 即可启动
2、将zookeeper做成 windows 服务,避免每次关闭启动还需要使用cmd
首先下载 prunsrv
下载地址:http://archive.apache.org/dist/commons/daemon/binaries/windows/
解压后复制文件
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目录下
监控服务配置及运行的程序
配置环境变量
添加ZOOKEEPER_SERVICE, ZOOKEEPER_HOME两个环境变量
ZOOKEEPER_SERVICE:服务名称(不要有中文)
ZOOKEEPER_HOME:设置到zookeeper-3.4.8目录下
在zookeeper-3.4.8\bin目录下添加一个 zkServerStop.cmd 文件.(注:cmd文件或者下面的bat文件,我们都可以先创建一个文本文件,然后把下面的内容copy进去,然后修改文本文件的后缀名即可)
内容如下:
@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
新建一个批处理安装文件:install.bat。(注:install.bat文件也需要放在zookeeper-3.4.8\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
最后在cmd中以管理员身份运行install.bat就OK了,之后在service服务中可以看到zookeeper的服务,手动启动即可
3、搭建dubbo-admin监控环境,监控消费者情况
下载dubbo :https://github.com/alibaba/dubbo