dubbo + zookeeper 环境搭建

一、zookeeper windows部署

1、下载安装

到官网下载解压版后解压至F:\server\zookeeper-3.4.8,剩下为文件配置工作;

2、本地伪集群

1) 在F:\server\zookeeper-3.4.8\conf 创建 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=F:\\server\\zookeeper-3.4.8\\data\\1

#日志位置

dataLogDir=F:\\server\\zookeeper-3.4.8\\log\\1

# the port at which the clients willconnect  客户端连接的端口

clientPort=2181

# server.id=host:port:port 
#  在服务器的 data (dataDir 参数所指定的目录)目录下创建一个文件名为 myid 的文件,
#  这个文件中仅含有一行的内容,指定的是自身的 id 值。
#  比如,服务器"1"应该在 myid 文件中写入"1"。这个 id 值必须是 ensemble 中唯一的,且大小在 1 到 255 之间。
#  这一行配置中,第一个端口( port )是从( follower )机器连接到主( leader )机器的端口,
#  第二个端口是用来进行 leader 选举的端口。
server.1=localhost:2887:3887
server.2=localhost:2888:3888
server.3=localhost:2889:3889

2) 创建目录:F:\server\zookeeper-3.4.8\data\1 ,并在该目录下创建"myid"文件,内容为"1";
3) 创建目录:F:\server\zookeeper-3.4.8\log\1 ;

4) 创建文件 F:\server\zookeeper-3.4.8\bin\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

5) 重复上述步骤依次创建 zoo2.cfg, zoo3.cfg 及相应的目录、文件;

6) 依次运行 zkServer-1.cmd 、 zkServer-2.cmd 、zkServer-3.cmd 即可,前面启动的端口报错问题可以忽略,全部启动完毕后自动恢复正常。

二、dubbo 代码示例参考

http://blog.csdn.net/wxwzy738/article/details/16330383

 

posted @ 2016-03-21 09:25  李小加  阅读(437)  评论(0编辑  收藏  举报