linux 一分钟搭建zookeeper linux 单机版(亲测可用)
切换到一个你想软件安装的地方,然后把下面的脚本保存为一个shell脚本文件,比如名为 zk_install.sh
wget https://dlcdn.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz --no-check-certificate
tar -zxf apache-zookeeper-3.7.1-bin.tar.gz
mv apache-zookeeper-3.7.1-bin zookeeper3.7
cd zookeeper3.7/
pwd | xargs -i echo 'export ZOOKEEPER_HOME='{}'' >> /etc/profile
echo 'export PATH=$PATH:$ZOOKEEPER_HOME/bin' >> /etc/profile
source /etc/profile
mkdir data
mkdir logs
touch data/myid
echo '1' > data/myid
touch conf/zoo.cfg
echo 'tickTime=2000' >> conf/zoo.cfg
echo 'initLimit=10' >> conf/zoo.cfg
echo 'syncLimit=5' >> conf/zoo.cfg
pwd | xargs -i echo 'dataDir='{}'/data' >> conf/zoo.cfg
pwd | xargs -i echo 'dataLogDir='{}'/logs' >> conf/zoo.cfg
echo 'clientPort=2181' >> conf/zoo.cfg
sh bin/zkServer.sh start
sh bin/zkServer.sh status
然后用sudo sh zk_install.sh 运行即可
以上的脚本自行检测通过