如何将主机添加到 ambari-server 集群中?

Posted

技术标签:

【中文标题】如何将主机添加到 ambari-server 集群中?【英文标题】:How to add host into the ambari-server cluster? 【发布时间】:2018-10-29 18:30:51 【问题描述】:

我正在尝试使用以下 curl 命令添加主机。

curl --user admin:passwd -i -H "X-Requested-By: ambari" -X POST http://182.29.6.3:8080/api/v1/clusters/prod/hosts/ip-182-29-6-3.us-east-2.ec2.internal

但是,我收到了不好的要求

HTTP/1.1 400 错误请求 X-Frame-Options: DENY X-XSS-Protection: 1; 模式=阻止设置 Cookie: AMBARISESSIONID=d52ibb6a8b6q1tmqm2l21q85e;Path=/;HttpOnly 过期: 1970 年 1 月 1 日星期四 00:00:00 GMT 用户:admin 内容类型:text/plain 内容长度:179 服务器:码头(8.1.19.v20160209)

"status" : 400, "message" : "尝试将未知主机添加到 簇。这些主机尚未在服务器上注册: ip-182-29-6-3.us-east-2.ec2.internal"

【问题讨论】:

【参考方案1】:

此命令帮助您通过ambari REST API 将主机添加到hdp 集群,添加YARN 节点管理器服务,在节点上部署配置和启动服务。

#!/bin/bash
# variables
HOSTNAME=$(curl http://169.254.169.254/latest/meta-data/hostname)
hostname $HOSTNAME
USERNAME='username'
PASSWORD='password'
CLUSTER_NAME='mycluster'
AMBARI_HOST='ip-172-166-11-52.ap-south-1.compute.internal'
AMBARI_PORT='8080'

#start ambari agent if its not running on the host to be registered and wait for 30 seconds for the agent to become up and running
/etc/init.d/ambari-agent start
sleep 30

# add a host to the cluster
curl --user $USERNAME:$PASSWORD -i -H 'X-Requested-By: ambari' -X POST http://$AMBARI_HOST:$AMBARI_PORT/api/v1/clusters/$CLUSTER_NAME/hosts/$HOSTNAME
sleep 30

#add node manager service to the node
curl --user $USERNAME:$PASSWORD -i -H 'X-Requested-By: ambari' -X POST http://$AMBARI_HOST:$AMBARI_PORT/api/v1/clusters/$CLUSTER_NAME/hosts/$HOSTNAME/host_components/NODEMANAGER
sleep 30

#install node manager packages and deploy configs it is not already present in the node
curl -u $USERNAME:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '"RequestInfo":"context":"Install","Body":"HostRoles":"state":"INSTALLED"' http://$AMBARI_HOST:$AMBARI_PORT/api/v1/clusters/$CLUSTER_NAME/hosts/$HOSTNAME/host_components/NODEMANAGER
sleep 30

# start node manager service
curl -u $USERNAME:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '"HostRoles": "state": "STARTED"' http://$AMBARI_HOST:$AMBARI_PORT/api/v1/clusters/$CLUSTER_NAME/hosts/$HOSTNAME/host_components/NODEMANAGER

【讨论】:

以上是关于如何将主机添加到 ambari-server 集群中?的主要内容,如果未能解决你的问题,请参考以下文章

Amabari搭建Hadoop集群

如何修改集群的公网信息(包括 VIP)

Ambari 2.4 安装教程,另附配置 haodoop lzo

我们如何使用 Chef 连接基于集群的软件?

调试 ambari-server 总结

repmgr+pg12集群,挂掉的主机如何手动加入集群