request body 如下:(集群组件只含有部分 不全 包括HDFS的nn dn ZK的server)
{
"host_groups" : [
{
"name" : "master",
"configurations" : [
],
"components" : [
{
"name" : "NAMENODE"
},
{
"name" : "ZOOKEEPER_SERVER"
}
{
"blueprint" : "<blueprint-name>",
"host_groups" :[
{
"name" : "master",
"hosts" : [
{
"fqdn" : "<master-host>"
}
]
},
{
"name" : "slaves",
"hosts" : [
{
"fqdn" : "<slave-host>"
},
{
"fqdn" : "<slave-host>"
}
]
}
]
}
具体命令如下
curl -u admin:admin -i -X POST -d '{"blueprint":"<blueprint-name>","host_groups":[{"name":"master","hosts":[{"fqdn":"<master-host>"}]},{"name":"slaves","hosts":[{"fqdn":"<slave-host>"},{"fqdn":"<slave-host>"}]}]}' -H "X-Requested-By:ambari" http://<ambari-server host>:8080/api/v1/clusters/<cluster-name>
这样就创建了集群名为<cluster-name>的集群了,调用后自动按照role_command_order.json中设置的顺序进行组件的安装、开启,创建成功后会返回如下状态:
202 - Accepted
{
"href" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/MyCluster/requests/1",
"Requests" : {
"id" : 1,
"status" : "InProgress"
}