重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

hadoop中zookeeper环境的搭建方法

这篇文章主要讲解了“hadoop中zookeeper环境的搭建方法”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“hadoop中zookeeper环境的搭建方法”吧!

我们提供的服务有:网站建设、成都网站设计、微信公众号开发、网站优化、网站认证、丽江ssl等。为千余家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的丽江网站制作公司

server0ip:192.168.88.155(hadoop01)

server1ip:192.168.88.164(hadoop02)

server2ip:192.168.88.165(hadoop03)

解压到app目录下

[root@hadoop02 Desktop]# tar -zxvf zookeeper-3.4.5.tar.gz -C app/

[root@hadoop02 Desktop]# cd app

[root@hadoop02 app]# cd zookeeper-3.4.5

[root@hadoop02 zookeeper-3.4.5]# cd conf

[root@hadoop02 conf]# mv zoo_sample.cfg zoo.cfg

vi zoo.cfg

dataDir=/root/Desktop/app/zookeeper-3.4.5/data

添加

server.1=hadoop01:2888:3888
server.2=hadoop02:2888:3888
server.3=hadoop03:2888:3888

[root@hadoop02 conf]# cd ..
[root@hadoop02 zookeeper-3.4.5]# mkdir data

[root@hadoop02 zookeeper-3.4.5]# cd data

[root@hadoop02 data]# echo 1 >myid
[root@hadoop02 data]# cat myid
1

[root@hadoop02 data]# cd ..
[root@hadoop02 zookeeper-3.4.5]# cd ..
[root@hadoop02 app]# ls
zookeeper-3.4.5

[root@hadoop02 app]# scp -r zookeeper-3.4.5/ hadoop02:/root/Desktop/app

进入hadoop02的主机

[root@localhost ~]# cd /root/Desktop/app

[root@localhost app]# cd zookeeper-3.4.5
[root@localhost zookeeper-3.4.5]# ls
bin          dist-maven       NOTICE.txt            zookeeper-3.4.5.jar.asc
build.xml    docs             README_packaging.txt  zookeeper-3.4.5.jar.md5
CHANGES.txt  ivysettings.xml  README.txt            zookeeper-3.4.5.jar.sha1
conf         ivy.xml          recipes
contrib      lib              src
data         LICENSE.txt      zookeeper-3.4.5.jar

[root@localhost zookeeper-3.4.5]# cd data
[root@localhost data]# ls
myid
[root@localhost data]# echo 2 >myid
[root@localhost data]# cat myid
2

进入hadoop03的server

[root@localhost app]# cd zookeeper-3.4.5
[root@localhost zookeeper-3.4.5]# ls
bin          docs                  README.txt
build.xml    ivysettings.xml       recipes
CHANGES.txt  ivy.xml               src
conf         lib                   zookeeper-3.4.5.jar
contrib      LICENSE.txt           zookeeper-3.4.5.jar.asc
data         NOTICE.txt            zookeeper-3.4.5.jar.md5
dist-maven   README_packaging.txt  zookeeper-3.4.5.jar.sha1

[root@localhost data]# ls
myid
[root@localhost data]# echo 3 >myid
[root@localhost data]# cat myid
3

启动集群

[root@hadoop02 conf]# cd ..

[root@hadoop02 zookeeper-3.4.5]# cd bin

[root@hadoop02 bin]# ./zkServer.sh start
JMX enabled by default
Using config: /root/Desktop/app/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@hadoop02 bin]# jps
5386 NodeManager
20801 Jps
4912 DataNode
5288 ResourceManager
17430 QuorumPeerMain
5126 SecondaryNameNode

同理启动hadoop02

[root@localhost zookeeper-3.4.5]# cd bin
[root@localhost bin]# ls
README.txt    zkCli.cmd  zkEnv.cmd  zkServer.cmd
zkCleanup.sh  zkCli.sh   zkEnv.sh   zkServer.sh
[root@localhost bin]# ./zkServer.sh start
JMX enabled by default
Using config: /root/Desktop/app/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost bin]# jps
9635 QuorumPeerMain
5538 SecondaryNameNode
5722 ResourceManager
9649 Jps
5195 NameNode
5820 NodeManager
5322 DataNode

启动hadoop03

root@localhost zookeeper-3.4.5]# cd bin
[root@localhost bin]# ls
README.txt    zkCli.cmd  zkEnv.cmd  zkServer.cmd
zkCleanup.sh  zkCli.sh   zkEnv.sh   zkServer.sh
[root@localhost bin]# ./zkServer.sh start
JMX enabled by default
Using config: /root/Desktop/app/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost bin]# jps
9275 Jps
5520 SecondaryNameNode
5691 ResourceManager
5789 NodeManager
9251 QuorumPeerMain
5310 DataNode

hadoop01

[root@hadoop02 bin]# ./zkServer.sh status
JMX enabled by default
Using config: /root/Desktop/app/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: follower
hadoop02

[root@localhost bin]# ./zkServer.sh status
JMX enabled by default
Using config: /root/Desktop/app/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: leader

hadoop03

root@localhost bin]#  ./zkServer.sh status
JMX enabled by default
Using config: /root/Desktop/app/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: follower
若出现Error contacting service. It is probably not running. error

一般是zookeeper-3.4.5 集群启动不成功, 在确保每台zookeeper-3.4.5启动后若还是出现问题

[root@hadoop01 ~]# find / -name zookeeper.out
/root/Desktop/app/zookeeper-3.4.5/bin/zookeeper.out

找出日志的位置查看

 tail -50 /root/Desktop/app/zookeeper-3.4.5/bin/zookeeper.out

   连接客户端

[root@hadoop02 bin]# sh zkCli.sh

[zk: localhost:2181(CONNECTED) 0] help帮助

[zk: localhost:2181(CONNECTED) 1] ls /
[zookeeper]
[zk: localhost:2181(CONNECTED) 2] create /hadoop 78
Created /hadoop

[zk: localhost:2181(CONNECTED) 4] get /hadoop
78

[zk: localhost:2181(CONNECTED) 7] set /hadoop xxxx

[zk: localhost:2181(CONNECTED) 5] create /hadoop/test mon:hadooop;tue:hdfs;
Created /hadoop/test
[zk: localhost:2181(CONNECTED) 6] get /hadoop/test
mon:hadooop;tue:hdfs;

连接hadoop03

[zk: localhost:2181(CONNECTED) 0] get /hadoop
78
kill -9  jps的线程

感谢各位的阅读,以上就是“hadoop中zookeeper环境的搭建方法”的内容了,经过本文的学习后,相信大家对hadoop中zookeeper环境的搭建方法这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联,小编将为大家推送更多相关知识点的文章,欢迎关注!


分享标题:hadoop中zookeeper环境的搭建方法
文章源于:http://cqcxhl.cn/article/gggieg.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP