與docker搭建hadoop不同的是,本次採用Dockerfile的方式構建鏡像,而後啓動鏡像,造成多主機多容器的方式啓動Hadoop集羣。html
1.在各個宿主機上搭建網橋weavegit
curl -L git.io/weave -o /usr/local/bin/weavegithub
weave launchdocker
2.各個宿主機經過weave網橋連接centos
192.168.130.166主機上操做:curl
weave connect 192.168.130.167oop
weave connect 192.168.130.168ui
192.168.130.167主機上操做:url
weave connect 192.168.130.166spa
weave connect 192.168.130.168
192.168.130.168主機上操做:
weave connect 192.168.130.166
weave connect 192.168.130.167
3.各個宿主機上建立子網段,使得同一網段的hadoop容器節點能互相通訊:
docker network create hadoop
4.建立目錄hadoop-cluster-docker,並在該目錄下,寫入hadoop的配置相關:
相關數據上傳到git中,詳情:https://github.com/mayunzhen/hadoop2.8.5-cluster-docker
5.拉取git項目:
git clone https://github.com/mayunzhen/hadoop2.8.5-cluster-docker.git
cd hadoop2.8.5-cluster-docker
./build-image.sh
6.啓動集羣:
隨意哪一個宿主機上隨意啓動(tips:weave固定的IP必須在同一個網段中,以便同一網段的容器能通訊):
docker run -itd -h hadoop-master --name hadoop-master --net=hadoop -v /etc/localtime:/etc/localtime:ro -p 50070:50070 -p 8088:8088 -p 9000:9000 iammayunzhen/hadoop:2.8.5
weave attach 192.168.1.10/24 hadoop-master
docker run -itd -h hadoop-slave1 --name hadoop-slave1 --net=hadoop -v /etc/localtime:/etc/localtime:ro centos_hdp:2.8.5
weave attach 192.168.1.11/24 hadoop-slave1
docker run -itd -h hadoop-slave2 --name hadoop-slave2 --net=hadoop -v /etc/localtime:/etc/localtime:ro centos_hdp:2.8.5
weave attach 192.168.1.12/24 hadoop-slave2
7.查看集羣狀態
。。。