使用Zookeeper

 参考文章

Zookeeper windows 安装和使用张善友

Zookeeper以Windows服务安装运行

安装遇到问题

  1. 本地jdk版本10.0.2 Zookeeper版本3.5.5 ,无法启动Zookeeper服务器,zookeeper启动错误 ClassNotFoundException: QuorumPeerMain
    重新下载Zookeeper3.4.14 启动成功

 

Windows 环境将Zookeeper部署成服务

需要使用prunsrv 工具将其部署成服务

(注: Prunsrv is a service application for running applications as services. It can convert any application (not just Java applications) to run as a service)

    1. 下载prunsrv
    2. 解压复制文件
      64位机器用amd64/prunsrv.exe 
      a. 复制 commons-daemon-1.2.0-bin-windows/amd64/prunsrv.exe 至 zookeeper-3.4.14\bin目录下
      这是做服务的执行程序 
      b. 复制 commons-daemon-1.2.0-bin-windows/prunmgr.exe 至 zookeeper-3.4.14\bin目录下
      监控服务配置及运行的程序 
    3. 配置环境变量

      添加ZOOKEEPER_SERVICE, ZOOKEEPER_HOME两个环境变量

      ZOOKEEPER_SERVICE:服务名称(不要有中文)

      ZOOKEEPER_HOME:设置到zookeeper-3.4.14目录下

    4. 配置好Zookeeper  配置文件zoo.cfg
    5. 在zookeeper-3.4.14\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
      7.cmd中以管理员身份运行install.bat , 到这就安装好啦!!

       

 

posted @ 2019-07-17 22:39  vvf  阅读(118)  评论(0编辑  收藏  举报