(2) windows下zookeeper伪集群搭建
2017-08-31 22:00
375 查看
一 下载zookeeper
http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.9/
二 单机安装配置
1. 解压到指定目录
eg:
D:\java\zookeeper
如图:
2. 配置zoo.cfg文件
将D:\java\zookeeper\zookeeper-3.4.9\conf下的zoo_sample.cfg复制一份,重命名为zoo.cfg。
zoo.cfg配置内容:
注意: 配置文件中的data、logs文件目录在服务启动时自动创建,也可以手动创建,
同时文件路径我们可以自由定义,不局限于放置在某个目录。
3. 启动服务
cmd命令窗口,进入bin目录: D:\java\zookeeper\zookeeper-3.4.9\bin>
zkServer.cmd命令启动服务: D:\java\zookeeper\zookeeper-3.4.9\bin>zkServer.cmd
查看启动进程: jps命令执行,可以看到QuorumPeerMain进程,说明服务启动成功
图:
4. 客户端连接
D:\java\zookeeper\zookeeper-3.4.9\bin>zkCli.cmd -server 127.0.0.1:2181
图:
三 伪集群安装配置
为什么要搭建伪集群,因为当你只有一台pc电脑,又想用集群环境时,可以通过伪集群建立集群服务。
这里以建立3个zookeeper服务集群为例。
1. 在zookeeper-3.4.9同级目录新建data1、data2、data3和logs1、logs2、logs3,这些文件目录可以自定义在任何目录。
2. 将zoo.cfg复制3份,分别命名为zoo1.cfg、zoo2.cfg、zoo3.cfg,如图
zoo1.cfg配置:
zoo2.cfg配置:
zoo3.cfg配置:
3. 在D:\java\zookeeper\zookeeper-3.4.9\bin下的zkServer.cmd复制3份,如图
分别加上: set ZOOCFG=..\conf\zoo1.cfg,如果有多个,依次类推
zkServer-1.cmd内容:
zkServer-2.cmd内容:
zkServer-3.cmd内容:
data1下的myid文件内容: 1
data2下的myid文件内容: 2
data3下的myid文件内容: 3
注意:
(1) 内容就是这么简单,不要想复杂了
(2) 如果你新建的myid文件有后缀,
比如: myid.text、myid.txt等等,请把后缀去掉,就是一个myid文件,否则启动服务时不认你的myid.text等。
5. 分别启动3个服务
zkServer-1启动,当启动服务时报错,连接拒绝等等,这是正常的,
因为你在启动第一个服务时,第二,三个都没有启动,所以连接不上,
当你启动到第三个服务时,就不会报错了。
zkServer-2启动:
zkServer-3启动:
如果都启动成功,说明单机伪集群搭建成功。
http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.9/
二 单机安装配置
1. 解压到指定目录
eg:
D:\java\zookeeper
如图:
2. 配置zoo.cfg文件
将D:\java\zookeeper\zookeeper-3.4.9\conf下的zoo_sample.cfg复制一份,重命名为zoo.cfg。
zoo.cfg配置内容:
# 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 anacknowledgement syncLimit=5 # the directory where the snapshot isstored. //镜像数据位置 dataDir=D:\\java\\zookeeper\\zookeeper-3.4.9\\data #日志位置 dataLogDir=D:\\java\\zookeeper\\zookeeper-3.4.9\\logs # the port at which the clients willconnect 客户端连接的端口 clientPort=2181
注意: 配置文件中的data、logs文件目录在服务启动时自动创建,也可以手动创建,
同时文件路径我们可以自由定义,不局限于放置在某个目录。
3. 启动服务
cmd命令窗口,进入bin目录: D:\java\zookeeper\zookeeper-3.4.9\bin>
zkServer.cmd命令启动服务: D:\java\zookeeper\zookeeper-3.4.9\bin>zkServer.cmd
查看启动进程: jps命令执行,可以看到QuorumPeerMain进程,说明服务启动成功
图:
4. 客户端连接
D:\java\zookeeper\zookeeper-3.4.9\bin>zkCli.cmd -server 127.0.0.1:2181
图:
三 伪集群安装配置
为什么要搭建伪集群,因为当你只有一台pc电脑,又想用集群环境时,可以通过伪集群建立集群服务。
这里以建立3个zookeeper服务集群为例。
1. 在zookeeper-3.4.9同级目录新建data1、data2、data3和logs1、logs2、logs3,这些文件目录可以自定义在任何目录。
2. 将zoo.cfg复制3份,分别命名为zoo1.cfg、zoo2.cfg、zoo3.cfg,如图
zoo1.cfg配置:
# 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 anacknowledgement syncLimit=5 # the directory where the snapshot isstored. //镜像数据位置 dataDir=D:\\java\\zookeeper\\data1 #日志位置 dataLogDir=D:\\java\\zookeeper\\logs1 # the port at which the clients willconnect 客户端连接的端口 clientPort=2181 server.1=127.0.0.1:2887:3887 server.2=127.0.0.1:2888:3888 server.3=127.0.0.1:2889:3889
zoo2.cfg配置:
# 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 anacknowledgement syncLimit=5 # the directory where the snapshot isstored. //镜像数据位置 dataDir=D:\\java\\zookeeper\\data2 #日志位置 dataLogDir=D:\\java\\zookeeper\\logs2 # the port at which the clients willconnect 客户端连接的端口 clientPort=2182 server.1=127.0.0.1:2887:3887 server.2=127.0.0.1:2888:3888 server.3=127.0.0.1:2889:3889
zoo3.cfg配置:
# 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 anacknowledgement syncLimit=5 # the directory where the snapshot isstored. //镜像数据位置 dataDir=D:\\java\\zookeeper\\data3 #日志位置 dataLogDir=D:\\java\\zookeeper\\logs3 # the port at which the clients willconnect 客户端连接的端口 clientPort=2183 server.1=127.0.0.1:2887:3887 server.2=127.0.0.1:2888:3888 server.3=127.0.0.1:2889:3889
3. 在D:\java\zookeeper\zookeeper-3.4.9\bin下的zkServer.cmd复制3份,如图
分别加上: set ZOOCFG=..\conf\zoo1.cfg,如果有多个,依次类推
zkServer-1.cmd内容:
@echo off REM Licensed to the Apache Software Foundation (ASF) under one or more REM contributor license agreements. See the NOTICE file distributed with REM this work for additional information regarding copyright ownership. REM The ASF licenses this file to You under the Apache License, Version 2.0 REM (the "License"); you may not use this file except in compliance with REM the License. You may obtain a copy of the License at REM REM http://www.apache.org/licenses/LICENSE-2.0 REM REM Unless required by applicable law or agreed to in writing, software REM distributed under the License is distributed on an "AS IS" BASIS, REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. REM See the License for the specific language governing permissions and REM limitations under the License. setlocal call "%~dp0zkEnv.cmd" set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain set ZOOCFG=..\conf\zoo1.cfg echo on call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %* endlocal
zkServer-2.cmd内容:
@echo off REM Licensed to the Apache Software Foundation (ASF) under one or more REM contributor license agreements. See the NOTICE file distributed with REM this work for additional information regarding copyright ownership. REM The ASF licenses this file to You under the Apache License, Version 2.0 REM (the "License"); you may not use this file except in compliance with REM the License. You may obtain a copy of the License at REM REM http://www.apache.org/licenses/LICENSE-2.0 REM REM Unless required by applicable law or agreed to in writing, software REM distributed under the License is distributed on an "AS IS" BASIS, REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. REM See the License for the specific language governing permissions and REM limitations under the License. setlocal call "%~dp0zkEnv.cmd" set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain set ZOOCFG=..\conf\zoo2.cfg echo on call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %* endlocal
zkServer-3.cmd内容:
@echo off REM Licensed to the Apache Software Foundation (ASF) under one or more REM contributor license agreements. See the NOTICE file distributed with REM this work for additional information regarding copyright ownership. REM The ASF licenses this file to You under the Apache License, Version 2.0 REM (the "License"); you may not use this file except in compliance with REM the License. You may obtain a copy of the License at REM REM http://www.apache.org/licenses/LICENSE-2.0 REM REM Unless required by applicable law or agreed to in writing, software REM distributed under the License is distributed on an "AS IS" BASIS, REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. REM See the License for the specific language governing permissions and REM limitations under the License. setlocal call "%~dp0zkEnv.cmd" set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain set ZOOCFG=..\conf\zoo3.cfg echo on call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %* endlocal4. 在data1、data2、data3新建myid文件
data1下的myid文件内容: 1
data2下的myid文件内容: 2
data3下的myid文件内容: 3
注意:
(1) 内容就是这么简单,不要想复杂了
(2) 如果你新建的myid文件有后缀,
比如: myid.text、myid.txt等等,请把后缀去掉,就是一个myid文件,否则启动服务时不认你的myid.text等。
5. 分别启动3个服务
zkServer-1启动,当启动服务时报错,连接拒绝等等,这是正常的,
因为你在启动第一个服务时,第二,三个都没有启动,所以连接不上,
当你启动到第三个服务时,就不会报错了。
zkServer-2启动:
zkServer-3启动:
如果都启动成功,说明单机伪集群搭建成功。
相关文章推荐
- STORM_0004_windows下zookeeper的伪集群的搭建
- windows下solrcloud+tomcat+zookeeper伪集群环境搭建
- windows下zookeeper伪集群搭建
- zookeeper集群搭建 windows
- ZooKeeper实战-Windows集群环境搭建
- windows下zookeeper伪集群搭建
- windows上单个zookeeper搭建伪集群
- windows下zookeeper伪集群搭建
- windows下zookeeper伪集群搭建
- Zookeeper在windows搭建伪集群
- zookeeper集群搭建 windows
- zookeeper集群搭建(windows环境下)
- zookeeper初探二 windows环境搭建伪集群
- Windows下zookeeper的伪集群搭建
- windows环境下搭建zookeeper伪集群
- ZooKeeper实战【Windows集群环境搭建】
- zookeeper集群搭建(windows环境下)
- windows上搭建伪zookeeper集群方法二
- windows下tomcat+solr+ZooKeeper集群搭建
- zookeeper集群搭建(windows环境下)