不多说,直接上干货!

为什么要在Win下来安装Zookeeper呢?

    其实玩过大数据的人很清楚,在Linux下我更不说了。在win下,如Disconf 、Dubbo等应用。

    所以,它的应用是非常广的。

 

  ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、域名服务、分布式同步、组服务等。

  ZooKeeper的目标就是封装好复杂易出错的关键服务,将简单易用的接口和性能高效、功能稳定的系统提供给用户。

  ZooKeeper包含一个简单的原语集,提供Java和C的接口。

  ZooKeeper代码版本中,提供了分布式独享锁、选举、队列的接口,代码在zookeeper-3.4.8\src\recipes。其中分布锁和队列有Java和C两个版本,选举只有Java版本。

  zookeeper下载地址:

  1. http://archive.apache.org/dist/zookeeper/zookeeper-3.4.8/

  (可自行在官网下载自己需要的版本)

  我这里以zookeeper-3.4.8为例。

  我的是解压到指定目录下  D:\SoftWare\zookeeper-3.4.8

  本博文,只关心其bin目录和conf目录。

  

   修改D:\SoftWare\zookeeper-3.4.8\conf下的:zoo_sample.cfg文件名,改为:zoo.cfg

  以下是默认的内容

  

  1. # The number of milliseconds of each tick

  2. tickTime=

  3. # The number of ticks that the initial

  4. # synchronization phase can take

  5. initLimit=

  6. # The number of ticks that can pass between

  7. # sending a request and getting an acknowledgement

  8. syncLimit=

  9. # the directory where the snapshot is stored.

  10. # do not use /tmp for storage, /tmp here is just

  11. # example sakes.

  12. dataDir=/tmp/zookeeper

  13. # the port at which the clients will connect

  14. clientPort=

  15. # the maximum number of client connections.

  16. # increase this if you need to handle more clients

  17. #maxClientCnxns=

  18. #

  19. # Be sure to read the maintenance section of the

  20. # administrator guide before turning on autopurge.

  21. #

  22. # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance

  23. #

  24. # The number of snapshots to retain in dataDir

  25. #autopurge.snapRetainCount=

  26. # Purge task interval in hours

  27. # Set to "" to disable auto purge feature

  28. #autopurge.purgeInterval=

  主要修改配置中的 dataDir ,根据自己实际修改即可,如下

  比如我这里是

  1. dataDir=D:\SoftWare\zookeeper-3.4.8\data

  所以,我的为

  1. # The number of milliseconds of each tick

  2. tickTime=

  3. # The number of ticks that the initial

  4. # synchronization phase can take

  5. initLimit=

  6. # The number of ticks that can pass between

  7. # sending a request and getting an acknowledgement

  8. syncLimit=

  9. # the directory where the snapshot is stored.
  10. # do not use /tmp for storage, /tmp here is just

  11. # example sakes.

  12. dataDir=D:\SoftWare\zookeeper-3.4.\data

  13. # the port at which the clients will connect

  14. clientPort=

  15. # the maximum number of client connections.

  16. # increase this if you need to handle more clients

  17. #maxClientCnxns=

  18. #

  19. # Be sure to read the maintenance section of the

  20. # administrator guide before turning on autopurge.

  21. #

  22. # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance

  23. #

  24. # The number of snapshots to retain in dataDir

  25. #autopurge.snapRetainCount=

  26. # Purge task interval in hours

  27. # Set to "" to disable auto purge feature

  28. #autopurge.purgeInterval=

  进入cmd下进bin目录,执行 zkserver.cmd 即可启动

    至此,完成!

下载的Zookeeper是.cmd的批处理命令运行的,默认没有提供以windows服务的方式运行的方案!!!

    为此,本文下载prunsrv 来作为zookeeper的服务管理。

    将zookeeper做成 windows 服务,避免每次关闭后,再启动还需要使用cmd。

下载prunsrv

  下载地址:http://archive.apache.org/dist/commons/daemon/binaries/windows/  ,找到commons-daemon-1.0.15-bin-windows

解压后复制以下文件

  注意:64位系统的机器用amd64/prunsrv.exe 
  (1)复制 commons-daemon-1.0.15-bin-windows/amd64/prunsrv.exe 至 zookeeper-3.4.8\bin目录下
      这是做服务的执行程序

  (2)复制 commons-daemon-1.0.15-bin-windows/prunmgr.exe 至 zookeeper-3.4.8\bin目录下
      监控服务配置及运行的程序

 为Zookeeper配置环境变量

  添加ZOOKEEPER_SERVICE, ZOOKEEPER_HOME两个环境变量

   ZOOKEEPER_SERVICE:服务名称(不要有中文),我这里取的是,命名为zookeeper_service

   ZOOKEEPER_HOME:设置到zookeeper-3.4.8目录下

  

  新建 zkServerStop.cmd 文件

  在zookeeper-3.4.8\bin目录下添加一个 zkServerStop.cmd 文件.

  (注:cmd文件或者下面的bat文件,我们都可以先创建一个文本文件,然后把下面的内容copy进去,然后修改文本文件的后缀名即可)

   内容如下:  

  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

 

   新建一个批处理安装文件install.bat

  (注: install.bat 文件也需要放在zookeeper-3.4.8\bin 目录下才可以)

  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= ^

  10. --LogPath=%ZOOKEEPER_HOME% --LogPrefix=zookeeper-wrapper ^

  11. --PidFile=zookeeper.pid --LogLevel=Info --StdOutput=auto --StdError=auto
  1. 最后在cmd中以管理员身份运行install.bat
    (注:其实我想说在zookeeper-3.4.8\bin目录下,双击install.bat文件就可以了,然后进入服务管理,就可以看到相应的服务了,不过这时候还没启动,右击启动即可。)


  1.  查看: 开始→运行(Windows+R快捷键也能调出运行) 输入:services.msc确定

  1.  

      如果你想彻底删除这个服务,则

  1.   开始”——“运行”——“regedit”)然后依次打开HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services

原文地址:https://www.cnblogs.com/zlslch/p/8561791.html

Windows里正确安装Zookeeper以服务运行的更多相关文章

  1. Windows里如何正确安装Zookeeper以服务运行(博主推荐)(图文详解)

    不多说,直接上干货! 为什么要在Win下来安装Zookeeper呢? 其实玩过大数据的人很清楚,在Linux下我更不说了.在win下,如Disconf .Dubbo等应用. 所以,它的应用是非常广的. ...

  2. Windows里如何正确安装Redis以服务运行(博主推荐)(图文详解)

    不多说,直接上干货! 注意 : Redis官方并没有提供Redis的windows安装包,但在github上, 有相关的下载地址.       一.Redis的下载地址 相关的下载地址,如下:     ...

  3. 无法定位 Local Database Runtime 安装。请验证 SQL Server Express 是否正确安装以及本地数据库运行时功能是否已启用。

    错误描述: 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误.未找到或无法访问服务器.请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接. (provide ...

  4. Lua在Windows下的安装、配置、运行

    Lua在Windows下的安装.配置.运行 本文链接:https://blog.csdn.net/ChinarCSDN/article/details/78667262 展开 # Windows下安装 ...

  5. windows环境下安装 zookeeper

    我们下载下来的zookeeper的安装包是.tar.gz格式的,但是还是可以在windows下运行. 下载地址 http://mirrors.hust.edu.cn/apache/zookeeper/ ...

  6. Windows环境下安装配置Mosquitto服务及入门操作介绍

    关键字:在windows安装mosquitto,在mosquitto中配置日志,在mosquitto中配置用户账号密码 关于Mosquitto配置的资料网上还是有几篇的,但是看来看去,基本上都是基于L ...

  7. windows环境下安装ZooKeeper

    $.说明 ZooKeeper: ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件. 它是一个为分布式 ...

  8. windows下离线安装mysql8.0服务(支持多个安装,端口不同就可以)

      1.官网下载 mysql文件.官网下载链接:https://dev.mysql.com/downloads/mysql/ 选择mysql下载的系统版本. 此处可以下载MSI安装包,图简单的朋友可以 ...

  9. Windows下Go安装&环境配置&编译运行

    Go下载安装 官方Go下载站点:https://golang.google.cn/ 也可以选择:https://studygolang.com/dl 配置环境变量 常用环境变量 GOROOT GORO ...

随机推荐

  1. Oracle里schema理解

    在Oracle中,一个用户就是一个Schema,表都是建立在Schema中的,也可以理解为每个用户拥有不同的表.一个用户想访问另外一个用户,也就是另外一个schema的表的时候,可以用 usernam ...

  2. android 九宫格(16宫格)控件

    public class NineRectView extends ViewGroup { private Context ctx; private int wSize,hSize,row,colum ...

  3. 在linux環境下安裝jprofiler_linux_8_0_2.sh

    1.安装jprofiler_linux_8_0_2.sh chmod+x jprofiler_linux_8_0_2.sh ./jprofiler_linux_8_0_2.sh –c 安装过程略..差 ...

  4. MapReduce编程之倒排索引

    任务要求: //输入文件格式 18661629496 110 13107702446 110 1234567 120 2345678 120 987654 110 2897839274 1866162 ...

  5. 2016.02.23,英语,《Vocabulary Builder》Unit 01

    Bell:来源于拉丁语,含义为war.fight,其中Bellona [bә'lәunә]是罗马女战神的名字,她的丈夫是战神Mars.antebellum: [ˌænti'beləm] adj. 战前 ...

  6. Android获取系统时间的多种方法

    Android中获取系统时间有多种方法,可分为Java中Calendar类获取,java.util.date类实现,还有android中Time实现. 现总结如下: 方法一: ? 1 2 3 4 5 ...

  7. Oracle DBA优化数据库性能心得

    如今的优化己经向优化等待(waits)转型了,实际中性能优化最根本的出现点也都集中在IO,这是影响性能最主要的方面,由系统中的等待去发现Oracle库中的不足.操作系统某些资源利用的不合理是一个比较好 ...

  8. Rep Invariant and Abstraction Function

    * According to the Reading 13 of MIT 6.005 course In order to finish Lab 2, in which the ps 2 gives ...

  9. javascript一个重要知识点:事件。

    javascript是事件驱动的,那什么是事件?事件就是在javascript中被侦测到DOM元素行为,就称之为javascript事件. 2.事件的三个阶段 事件的三个阶段分别为: 1.捕获阶段 2 ...

  10. submile 安装,汉化,插件

    /*删除以前配置文件*/ 删除以前版本sublime后,在删除以前版本的配置信息:直接在C盘 查询里面输入 Roming  然后查找里面的 sublime 文件夹,把他给删除掉 ----------- ...