1,首先准备三台节点,(有钱的可以买云服务器,华为的相对便宜一些,没钱的找个配置好一些的电脑,装个Vmvare 虚拟机器主机就Ok了,具体方法,度娘,这是基本的功力,哈哈哈哈)
2, 安装好jdk,
本位的jdk 版本如下:
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
本文的版本是3.4.10
本文的目录大致如下:
[root@master /opt/bigdata/component/zookeeper]# pwd
/opt/bigdata/component/zookeeper
[root@master /opt/bigdata/component/zookeeper]#
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/opt/bigdata/component/zookeeper/data
clientPort=2181
#把相应的ip 改成自己的ip , 数据目录改成自己的目录即可
server.1=172.16.0.47:2888:3888
server.2=172.16.0.155:2888:3888
server.3=172.16.0.192:2888:3888
if [ "x${ZOO_LOG_DIR}" = "x" ]
then
ZOO_LOG_DIR="/opt/bigdata/logs/zookeeper/logs"
fi
[root@master /opt/bigdata/component]# cat //opt/env_bigdata.sh
export ZOOKEEPER_HOME=/opt/bigdata/component/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin
[root@master /opt/bigdata/component]#
scp -r zookeeper workerI:`pwd`
scp -r zookeeper workerII:`pwd`
[root@master /opt/bigdata/component]# pwd
/opt/bigdata/component
[root@master /opt/bigdata/component/zookeeper/data]# echo 1 > myid
[root@master /opt/bigdata/component/zookeeper/data]# pwd
/opt/bigdata/component/zookeeper/data
[root@workerI /opt/bigdata/component/zookeeper/data]# echo 2 > myid
[root@workerI /opt/bigdata/component/zookeeper/data]#
[root@workerII /opt/bigdata/component/zookeeper/data]# echo 3 > myid
[root@workerII /opt/bigdata/component/zookeeper/data]# cat myid
3
在三个节点上面分别执行如下脚本即可:
[root@workerII /opt/bigdata/component/zookeeper]# sh bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/bigdata/component/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
查看其状态:
[root@workerII /opt/bigdata/component/zookeeper]# sh bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/bigdata/component/zookeeper/bin/../conf/zoo.cfg
Mode: follower
[root@workerI /opt/bigdata/component/zookeeper]# sh bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/bigdata/component/zookeeper/bin/../conf/zoo.cfg
Mode: leader
[root@master /opt/bigdata/component/zookeeper]# sh bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/bigdata/component/zookeeper/bin/../conf/zoo.cfg
Mode: follower
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。