1.docker部署ambari
① centos7自身沒有yum工具
apt-get install yum -y
② 安裝git
yum -y install git
③ 拉取遠程倉庫
git clone https://gitee.com/which-ly/docker-ambari-2.7.3.git
④ 開始安裝
cd docker-ambari-2.7.3
cd ambari-base-local
wget -O local.repo http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0/ambari.repo
cd ..
cd ambari-server-local
wget -O local.repo http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0/ambari.repo
cd ..
#製作鏡像
./scripts/build-image.sh
#本地啓動
./scripts/create-local.sh
⑤ 查看容器
#查看正在運行的容器
docker ps
# 獲得web ip
docker inspect -f '{
{range .NetworkSettings.Networks}}{
{.IPAddress}}{
{end}}' amb-server
#訪問ambari界面
http://ambari-server(IP):8080
# 查看其它節點的ip
docker inspect 容器id | grep -i ip
2.配置ssh免密登錄
我這裏的三個容器的ip分別是
- 172.17.0.2(amb-server)
- 172.17.0.3(amb1)
- 172.17.0.4(amb2)
① 修改主機名
# 分別進入每個容器修改hostname
sudo hostnamectl set-hostname node1
- 172.17.0.2(amb-server) -> node3
- 172.17.0.3(amb1) -> node1
- 172.17.0.4(amb2) -> node2
② 修改hosts文件,可以直接ping名字
#分別進入每個容器
docker exec -it amb-server /bin/bash
vi /etc/hosts
172.17.0.2 node3
172.17.0.3 node1
172.17.0.4 node2
#同時要註釋掉:
#172.17.0.3 amb1.service.consul amb1
#172.17.0.4 amb2.service.consul amb2
③ 生成密鑰
首先分別在這3個節點執行指令:ssh-keygen ,然後一直按回車鍵直到結束。此時你可以發現在 /root/.ssh/ 文件夾下生成了id_rsa(私鑰) 、 id_rsa.pub (公鑰),這是生成的祕鑰對
④公鑰分享
同步公鑰到所有節點需要輸入root的密碼,3個節點都設置root密碼爲 ambari123
sudo passwd
把自己的公鑰發送給其它節點,包括自己。指令如下:
ssh-copy-id node1
ssh-copy-id node2
ssh-copy-id node3
⑤ 配置ambari基礎repo(已經配置好,直接進入3)
從如下地址找到hdp3.1.4的yum repo地址
http://public-repo-1.hortonworks.com/HDP/hdp_urlinfo.json
hdp-3.1.4的yum repo地址:
http://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.1.4.0/HDP-3.1.4.0-315.xml
打開可以看到hdp, hdp-gpl, hdp-utils的repo
3.輔助repo配置
#進入每個容器,執行如下操作
cd /etc/yum.repos.d/
cp backup_repo/CentOS-Base.repo .
4.創建集羣
- 點擊:LAUNCH INSTALL WIZARD
- 取名:idc
- 選擇HDP3.1
- 下一步需要輸入ambari-server所在機器的私鑰,這樣ambari-server才能把組件部署到其他節點
docker exec -it amb-server /bin/bash
cd /root/.ssh
id_rsa
- 只能添加node1, node2
- 接下來按照項目需求進行安裝服務