您好,登录后才能下订单哦!
这篇文章主要讲解了“hadoop中zookeeper环境的搭建方法”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“hadoop中zookeeper环境的搭建方法”吧!
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环境的搭建方法这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。