Ambari-create a cluster in one step

Source: Internet
Author: User


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
    • Http post request http: // <ambari-Server>: 8080/API/V1/clusters/<cluster-Name>/hosts/<Master/Slave host>
    • Actual commandCurl-u admin: Admin-I-X Post-h "X-requested-by: ambari" http://nj01-hadoop-rd03.nj01.baidu.com: 8080/API/V1/clusters/abacicluster/hosts/nj01-hadoop-rd03.nj01.baidu.com
    • Where <ambari-Server> = nj01-hadoop-rd03.nj01.baidu.com <cluster-Name> =Abacicluster<Master/Slave host> =Nj01-hadoop-rd03.nj01.baidu.com
    • Note: If a cluster has multiple hosts, multiple commands are called.

  • Add services to the created Cluster (add HDFS service as an example)
    • Add HDFS Service
      • Http post http: // <ambari-Server>: 8080/API/V1/clusters/<cluster-Name>/services

      • Request body 

        {
        "Serviceinfo ":{
        "SERVICE_NAME": "HDFS"
        }
        }

      • Actual command

        Curl-u admin: Admin-I-X Post-d '{"serviceinfo": {"SERVICE_NAME": "HDFS"}'-h "X-requested-: ambari "http://nj01-hadoop-rd03.nj01.com: 8080/API/V1/clusters/abacicluster/services
      • Where <ambari-Server> = nj01-hadoop-rd03.nj01.com <cluster-Name> = abacicluster <service-Name> =HDFS

    • 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
      • Http put requestHttp: // <ambari-Server>: 8080/API/V1/clusters/<cluster-Name>
      • Request body

        {
        "Clusters ":{
        "Desired_configs ":{
        "Type": "hadoop-user-info.properties ",
        "Tag": "1"
        }
        }
        }

      • Actual command

        Curl-u admin: Admin-I-x put-d '{"clusters": {"desired_configs": {"type": "hadoop-user-info.properties", "tag ": "1" }}'-h "X-requested-by: ambari" http: // <ambari-Server>: 8080/API/V1/clusters/abacicluster


    • 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
      • Http put requestHttp: // <ambari-Server>: 8080/API/V1/clusters/<cluster-Name>/services/<service-Name>
      • Request body

        {
        "Serviceinfo ":{
        "State": "installed"
        }
        }


      • Actual command:

        Curl-u admin: Admin-I-x put-d '{"serviceinfo": {"state": "installed"}'-h "X-requested-: ambari "http: // <ambari-Server>/API/V1/clusters/abacicluster/services/zookeeper


    • Service enabled
      • Http put requestHttp: // <ambari-Server>: 8080/API/V1/clusters/<cluster-Name>/services/<service-Name>
      • Request body

        {
        "Serviceinfo ":{
        "State": "started"

        }

        }

      • Actual command:

        Curl-u admin: Admin-I-x put-d '{"serviceinfo": {"state": "started"}'-h "X-requested-: ambari "http: // <ambari-Server>: 8080/API/V1/clusters/abacicluster/services/zookeeper

    • 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.