dubbo 笔记四 Zookeeper配置

Zookeeper单机配置

< dubbo:registry address = "zookeeper://10.20.153.10:2181" />
Or:
 
< dubbo:registry protocol = "zookeeper" address = "10.20.153.10:2181" />

Zookeeper集群配置:

<dubbo:registryaddress="zookeeper://10.20.153.10:2181?backup=10.20.153.11:2181,10.20.153.12:2181"/>

or:

<dubbo:registryprotocol="zookeeper"address="10.20.153.10:2181,10.20.153.11:2181,10.20.153.12:2181"/>

同一Zookeeper,分成多组注册中心:

< dubbo:registry id = "chinaRegistry" protocol = "zookeeper" address = "10.20.153.10:2181" group = "china" />
< dubbo:registry id = "intlRegistry" protocol = "zookeeper" address = "10.20.153.10:2181" group = "intl" />
 
 

Zookeeper注册中心安装:

安装:

wget http://www.apache.org/dist//zookeeper/zookeeper-3.3.3/zookeeper-3.3.3.tar.gz

tar zxvf zookeeper-3.3.3.tar.gz

cd zookeeper-3.3.3

cp conf/zoo_sample.cfg conf/zoo.cfg

配置:

vi conf/zoo.cfg

如果不需要集群,zoo.cfg的内容如下:(其中data目录需改成你真实输出目录)

tickTime=2000

initLimit=10

syncLimit=5

dataDir=/home/dubbo/zookeeper-3.3.3/data

clientPort=2181

如果需要集群,zoo.cfg的内容如下:(其中data目录和server地址需改成你真实部署机器的信息)

tickTime=2000

initLimit=10
syncLimit=5
dataDir=/home/dubbo/zookeeper-3.3.3/data
clientPort=2181
server.1=10.20.153.10:2555:3555
server.2=10.20.153.11:2555:3555
 
并在data目录下放置myid文件:(上面zoo.cfg中的dataDir)
mkdir data
 
vi myid
 
myid指明自己的id,对应上面zoo.cfg中server.后的数字,第一台的内容为1,第二台的内容为2,内容如下:
1
 
启动:
./bin/zkServer.sh start
停止:
./bin/zkServer.sh stop
 
 

猜你喜欢

转载自feiteyizu.iteye.com/blog/2242381