Home >Database >Mysql Tutorial >zookeeper学习(1)—-安装篇

zookeeper学习(1)—-安装篇

WBOY
WBOYOriginal
2016-06-07 16:30:421284browse

单机安装 cd /home/user/zookeepertest下载:wget "http://mirror.bjtu.edu.cn/apache/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz"解压缩tar zxvf zookeeper-3.4.5.tar.gz修改配置文件cd zookeeper-3.4.5/confcp zoo-sample.cfg zoo.cfg修改zoo.cfgd

单机安装

cd /home/user/zookeepertest下载:wget "http://mirror.bjtu.edu.cn/apache/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz"解压缩tar zxvf zookeeper-3.4.5.tar.gz修改配置文件cd zookeeper-3.4.5/confcp zoo-sample.cfg zoo.cfg修改zoo.cfgdataDir=/home/user/zookeepertest/data1启动cd ../bin/zkServer.sh start这时候在/home/user/zookeepertest/data1下会生成一个zookeeper_server.pid文件。bin/zkServer.sh stop停止服务。

单机伪分布式安装

cd /home/user/zookeepertest
下载:
wget “http://mirror.bjtu.edu.cn/apache/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz”
解压缩
tar zxvf zookeeper-3.4.5.tar.gz
复制多份
cp zookeeper-3.4.5 zk1
cp zookeeper-3.4.5 zk2
cp zookeeper-3.4.5 zk3
创建data目录
mkdir /home/user/zookeepertest/data{1..3}
创建log目录
mkdir /home/user/zookeepertest/logs/log{1..3}
创建myid文件
echo 1 > /home/user/zookeepertest/data1/myid
echo 2 > /home/user/zookeepertest/data2/myid
echo 3 > /home/user/zookeepertest/data3/myid

修改配置文件(zk1为例)
cd zk1/conf
cp zoo-sample.cfg zoo.cfg
修改zoo.cfg

dataDir=/home/user/zookeepertest/data1dataLogDir=/home/user/zookeepertest/logs/log1clientPort=4481server.1=127.0.0.1:5000:6000server.2=127.0.0.1:5001:6001server.3=127.0.0.1:5002:6002注意:server.X 这个数字就是对应 data/myid中的数字。你在3个server的myid文件中分别写入了1,2,3,那么每个server中的zoo.cfg都配server.1,server.2,server.3就OK了。因为在同一台机器上,后面连着的2个端口3个server都不要一样,否则端口冲突。其中第一个端口用来集群成员的信息交换,第二个端口是在leader挂掉时专门用来进行选举leader所用。

对应修改zk2,zk3配置。

创建启动脚本

创建脚本/home/user/zookeepertest/zk.sh#!/bin/bashfor o in 1 2 3docd /home/user/zookeepertest/zk$o/bin/zkServer.sh $1done?启动./zk.sh start停止./zk.sh stop
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn