Ambari-Overview of single-step creation
- One-step cluster creation calls the restapi of ambari-server once to install and enable each service in the cluster and set the host information of each component of the service. This improves the flexibility of cluster operations. Because blueprint is available after ambari 1.5, the support for non-HDP versions may be insufficient, therefore, the restapi that calls ambari-server is called to create a cluster in one step.
- Note: Before calling restapi to add a service, make sure that the service is already in the stack.
Ambari-specific steps for creating a single step (take creating an HDP version as an example)
- Call the cluster creation API
- The request body includes the stack version.
- Post http: // <ambari-Server>: 8080/API/V1/clusters/<cluster-Name>
- Request body:{"Clusters ":{"Version": "BAIDU-1.0"}}
- Actual commandCurl-u admin: Admin-I-X Post-d '{"clusters": {"version": "BAIDU-1.0"}'-h "X-requested-: ambari "http: // <ambari-Server>/API/V1/clusters/<cluster-Name>
- Add a host to a created Cluster
- Add services to the created Cluster (add HDFS service as an example)
- Add HDFS Service
- Add service components (including namenode datanode)
- HTTP POSTHttp: // <ambari-Server>: 8080/API/V1/clusters/<cluster-Name>/services/<service-Name>/components/<component-Name>
- Actual command
Curl-u admin: Admin-I-X Post-h "X-requested-by: ambari" http://nj01-hadoop-rd03.nj01.com: 8080/API/V1/clusters/abacicluster/services/HDFS/components/namenodeCurl-u admin: Admin-I-X Post-h "X-requested-by: ambari" http://nj01-hadoop-rd03.nj01.com: 8080/API/V1/clusters/abacicluster/services/HDFS/components/datanode
- Where <ambari-Server> = nj01-hadoop-rd03.nj01.com <cluster-Name> = abacicluster <service-Name> = HDFS <component-Name> = namenode/datanode
- Note: The number of times restapi calls is determined by the type of components of the service.
- Add HDFS configurations
- HTTP POSTHttp: // <ambari-Server>: 8080/API/V1/clusters/<cluster-Name>/deployments
- Request body in hadoop-user-info.properties.xmlExample
{
"Type": "hadoop-user-info.properties ",
"Tag": "1 ",
"Properties ":{
"Root_ugi": "root, Baidu ",
"User_ugi": "public, slave ",
"Content": "# format: username = password, group1, group2, Group3 root = Baidu, root public = slave, slave"
}
}
- The preceding key-value is stored in command-JSON.
- Actual command:
Curl-u admin: Admin-I-X Post-d '{"type": "hadoop-user-info.properties", "tag": "1", "properties": {"root_ugi ": "root, Baidu", "user_ugi": "public, slave", "content": "# format: username = password, group1, group2, Group3 root = Baidu, root public = slave, slave "} '-h" X-requested-by: ambari "http: // <ambari-Server>: 8080/API/V1/clusters/abacicluster/deployments
- Note: There are many configuration items and you may need to call this restapi multiple times.
- The key/value in the configuration information is written to the command-JSON
- Configure the corresponding host for each component (03 is namenode 02 06 is datanode)
- Http post requestHttp: // <ambari-Server>: 8080/API/V1/clusters/<cluster-Name>/hosts? Hosts/host_name =
- Request body
{
"Host_components ":[
{
"Hostroles ":{
"Component_name": "namenode"
}
}
]
}
- Actual commandCurl-u admin: Admin-I-X Post-d '{"host_components": [{"hostroles": {"component_name ": "namenode" }}]} '-h "X-requested-by: ambari" http: // <ambari-Server>: 8080/API/V1/clusters/abacicluster/hosts? Hosts/host_name = nj01-hadoop-rd03.nj01.comCurl-u admin: Admin-I-X Post-d '{"host_components": [{"hostroles": {"component_name ": "datanode" }}]} '-h "X-requested-by: ambari" http: // <ambari-Server>: 8080/API/V1/clusters/abacicluster/hosts? Hosts/host_name = nj01-hadoop-rd02.nj01.comCurl-u admin: Admin-I-X Post-d '{"host_components": [{"hostroles": {"component_name ": "datanode" }}]} '-h "X-requested-by: ambari" http: // <ambari-Server>: 8080/API/V1/clusters/abacicluster/hosts? Hosts/host_name = nj01-hadoop-rd06.nj01.com
- After all services are deployed, install, enable, and disable cluster services.
- Service Installation
- Service enabled
- Service closed
- The command for disabling a service is exactly the same as that for installing a service. When the service status in the cluster is started, the installation command for ambari-API is called, the ambari system will close a running service process through the stop function in the Python script.
The article has been changed. For more information about ambari, contact us.
Ambari-create a cluster in one step