zookeeper集群
jdk
下载
配置
export JAVA_HOME=/usr/local/java/安装目录
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
编辑 bash_profile
vim .bash_profile
复制上面代码写入bash_profile,将【安装目录】替换为【jdk目录】看实际安装情况而定
zookeeper
下载
wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
安装
-
解压 tar -zxvf zookeeper-3.4.10.tar.gz
mkdir /apps && mv zookeeper-3.4.10 /apps/zookeeper
mkdir /apps/zookeeper/data
配置
-
复制配置文件 cd zookeeper/
cp conf/zoo_sample.cfg ./conf/zoo.cfg
修改配置文件参数
vim zoo.cfg
dataDir=/apps/zookeeper/data
clientPort=8000
server.1=10.211.55.30:8002:8001
server.2=10.211.55.31:8002:8001
server.3=10.211.55.32:8002:8001
sed -i "s/^dataDir=\/tmp\/zookeeper/dataDir=\/apps\/zookeeper\/data/g" /apps/zookeeper/conf/zoo.cfg && sed -i "s/^clientPort=2181/clientPort=8000/g" /apps/zookeeper/conf/zoo.cfg
echo -e "server.1=10.211.55.30:8002:8001 \nserver.2=10.211.55.31:8002:8001 \nserver.3=10.211.55.32:8002:8001" >> /apps/zookeeper/conf/zoo.cfg
-
集群服务器编号
10.211.55.30 echo "1" > /apps/zookeeper/data/myid
10.211.55.31 echo "2" > /apps/zookeeper/data/myid
10.211.55.32 echo "3" > /apps/zookeeper/data/myid
启动
cd /apps/zookeeper
./bin/zkServer.sh start
检查
./bin/zkServer.sh status
停止
./bin/zkServer.sh stop
|