Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

ambari api to do a rolling restart of hbase region servers

ambari api to do a rolling restart of hbase region servers

Hi,

Can someone point me a reference to the usage of ambari rest api to do a rolling restart of hbase region servers.

3 REPLIES 3
Highlighted

Re: ambari api to do a rolling restart of hbase region servers

New Contributor

Re: ambari api to do a rolling restart of hbase region servers

Super Mentor

@ARUN

Example: If the Region Servers are installed on "erie1.example.com", "erie2.example.com", "erie3.example.com" and "erie4.example.com" then you can try using the following Ambari API call to achieve the Region Server Rolling Restarts as following:

curl -u admin:admin -H "X-Requested-By: ambari" -X POST  '[{"RequestSchedule":{"batch":[{"requests":[{"order_id":1,"type":"POST","uri":"/api/v1/clusters/ErieCluster/requests","RequestBodyInfo":{"RequestInfo":{"context":"_PARSE_.ROLLING-RESTART.HBASE_REGIONSERVER.1.4","command":"RESTART"},"Requests/resource_filters":[{"service_name":"HBASE","component_name":"HBASE_REGIONSERVER","hosts":"erie1.example.com"}]}},{"order_id":2,"type":"POST","uri":"/api/v1/clusters/ErieCluster/requests","RequestBodyInfo":{"RequestInfo":{"context":"_PARSE_.ROLLING-RESTART.HBASE_REGIONSERVER.2.4","command":"RESTART"},"Requests/resource_filters":[{"service_name":"HBASE","component_name":"HBASE_REGIONSERVER","hosts":"erie2.example.com"}]}},{"order_id":3,"type":"POST","uri":"/api/v1/clusters/ErieCluster/requests","RequestBodyInfo":{"RequestInfo":{"context":"_PARSE_.ROLLING-RESTART.HBASE_REGIONSERVER.3.4","command":"RESTART"},"Requests/resource_filters":[{"service_name":"HBASE","component_name":"HBASE_REGIONSERVER","hosts":"erie3.example.com"}]}},{"order_id":4,"type":"POST","uri":"/api/v1/clusters/ErieCluster/requests","RequestBodyInfo":{"RequestInfo":{"context":"_PARSE_.ROLLING-RESTART.HBASE_REGIONSERVER.4.4","command":"RESTART"},"Requests/resource_filters":[{"service_name":"HBASE","component_name":"HBASE_REGIONSERVER","hosts":"erie4.example.com"}]}}]},{"batch_settings":{"batch_separation_in_seconds":120,"task_failure_tolerance":1}}]}}]'   http://erie1.example.com:8080/api/v1/clusters/ErieCluster/request_schedules

Here you can alter the following attributes based on your choice:

"batch_separation_in_seconds": 120,
 "task_failure_tolerance": 1

Following are the URL properties that might be different in your case:

erie1.example.com:8080 => Ambari Server Host & port
ErieCluster => Cluster Name

For your reference i am re-posting the JSON data in pretty format that will help you understand the POST data structure well.

[
  {
    "RequestSchedule": {
      "batch": [
        {
          "requests": [
            {
              "order_id": 1,
              "type": "POST",
              "uri": "/api/v1/clusters/ErieCluster/requests",
              "RequestBodyInfo": {
                "RequestInfo": {
                  "context": "_PARSE_.ROLLING-RESTART.HBASE_REGIONSERVER.1.4",
                  "command": "RESTART"
                },
                "Requests/resource_filters": [
                  {
                    "service_name": "HBASE",
                    "component_name": "HBASE_REGIONSERVER",
                    "hosts": "erie1.example.com"
                  }
                ]
              }
            },
            {
              "order_id": 2,
              "type": "POST",
              "uri": "/api/v1/clusters/ErieCluster/requests",
              "RequestBodyInfo": {
                "RequestInfo": {
                  "context": "_PARSE_.ROLLING-RESTART.HBASE_REGIONSERVER.2.4",
                  "command": "RESTART"
                },
                "Requests/resource_filters": [
                  {
                    "service_name": "HBASE",
                    "component_name": "HBASE_REGIONSERVER",
                    "hosts": "erie2.example.com"
                  }
                ]
              }
            },
            {
              "order_id": 3,
              "type": "POST",
              "uri": "/api/v1/clusters/ErieCluster/requests",
              "RequestBodyInfo": {
                "RequestInfo": {
                  "context": "_PARSE_.ROLLING-RESTART.HBASE_REGIONSERVER.3.4",
                  "command": "RESTART"
                },
                "Requests/resource_filters": [
                  {
                    "service_name": "HBASE",
                    "component_name": "HBASE_REGIONSERVER",
                    "hosts": "erie3.example.com"
                  }
                ]
              }
            },
            {
              "order_id": 4,
              "type": "POST",
              "uri": "/api/v1/clusters/ErieCluster/requests",
              "RequestBodyInfo": {
                "RequestInfo": {
                  "context": "_PARSE_.ROLLING-RESTART.HBASE_REGIONSERVER.4.4",
                  "command": "RESTART"
                },
                "Requests/resource_filters": [
                  {
                    "service_name": "HBASE",
                    "component_name": "HBASE_REGIONSERVER",
                    "hosts": "erie4.example.com"
                  }
                ]
              }
            }
          ]
        },
        {
          "batch_settings": {
            "batch_separation_in_seconds": 120,
            "task_failure_tolerance": 1
          }
        }
      ]
    }
  }
]

.

Re: ambari api to do a rolling restart of hbase region servers

New Contributor

Hi,

The script runs fine after adding '-d' (curl -u admin:admin -H "X-Requested-By: ambari" -X POST -d).

Regards,

Sanjay Parmar