Support Questions

Find answers, ask questions, and share your expertise

how to install service by API or by other auto way

avatar

in my Ambari cluster we have some services that not installed yet

as graphite service as described here ( in the picture )

what are the API commands that required in order to identify which service is/are available to install

and the API that install the service

43557-capture1.png

Michael-Bronson
1 ACCEPTED SOLUTION

avatar
Super Guru

@Michael Bronson,

I thought it was only an install. If you want to add a service and install the service, there are series of steps which you need to do.

This doc will help you. Currently I do not have configuration for knox which is required in Step 3.

https://cwiki.apache.org/confluence/display/AMBARI/Adding+a+New+Service+to+an+Existing+Cluster

View solution in original post

10 REPLIES 10

avatar
Super Guru

@Michael Bronson,

You can use this API to get all the available services.

http://{ambari-server}:{port}/api/v1/clusters/{clustername}/stack_versions/{stack-version-no}/reposi...

Hit the above API and parse "RepositoryVersions -> services" array

To check list of installed services you can use

http://{ambari-server}:{port}/api/v1/clusters/{clustername}/services.

Check the diff between two to find out the services which are not installed

To install the service use

curl -u <username>:<password> -i -X PUT -d '{"ServiceInfo": {"state" : "INSTALLED"}}'  http://<ambari-server-host>:{port}/api/v1/clusters/<cluster-name>/services/<service-name>;

Thanks,

Aditya

avatar

hi aditye regarding the - http://{ambari-server}:{port}/api/v1/clusters/{clustername}/services. , can you show me please the full approach ( full syntax )

Michael-Bronson

avatar
Super Guru

get list of available services : curl -k -u {username}:{password} -H "X-Requested-By:ambari" -i -X GET http://{ambari-server}:{port}/api/v1/clusters/{clustername}/stack_versions/{stack-version-no}/reposi...

Get list of installed services: curl -k -u {username}:{password} -H "X-Requested-By:ambari" -i -X GET http://{ambari-server}:{port}/api/v1/clusters/{clustername}/services

To get the {stack-version-no} you can hit below API and see the available stack versions

curl -k -u {username}:{password} -H "X-Requested-By:ambari" -i -X GET http://{ambari-server}:{port}/api/v1/clusters/{clustername}/stack_versions/

Similarly to get {repository-version-no}, get {stack-version-no} from above call and hit below url

curl -k -u {username}:{password} -H "X-Requested-By:ambari" -i -X GET http://{ambari-server}:{port}/api/v1/clusters/{clustername}/stack_versions/{stack-version-no}/

replace the placeholders with your values

avatar

hi aditye , can you give me real example for the first API

second how to get these values ?

stack_versions

{stack-version-no}

repository_versions

{repository-version-no}

Michael-Bronson

avatar
Super Guru

@Michael Bronson,

To get the {stack-version-no} , hit below API

curl -k -u {username}:{password} -H "X-Requested-By:ambari" -i -X GET http://{ambari-server}:{port}/api/v1/clusters/{clustername}/stack_versions/

ex: curl -k -u admin:admin -H "X-Requested-By:ambari" -i -X GET http://172.31.192.200:8080/api/v1/clusters/cl1/stack_versions

{
  "href" : "http://172.31.192.200:8080/api/v1/clusters/cl1/stack_versions",
  "items" : [
    {
      "href" : "http://172.31.192.200:8080/api/v1/clusters/cl1/stack_versions/1",  --> stack version no
      "ClusterStackVersions" : {
        "cluster_name" : "cl1",
        "id" : 1,
        "repository_version" : 1,
        "stack" : "HDP",
        "version" : "2.6"
      }
    }
  ]
}
<br>

To get {repository-version-no} , hit below API

curl -k -u {username}:{password} -H "X-Requested-By:ambari" -i -X GET http://{ambari-server}:{port}/api/v1/clusters/{clustername}/stack_versions/{stack-version-no}

ex: curl -k -u admin:admin -H "X-Requested-By:ambari" -i -X GET http://172.31.192.200:8080/api/v1/clusters/cl1/stack_versions/1

{
  "href" : "http://x.x.x.x:8080/api/v1/clusters/cl1/stack_versions/1/",
  "ClusterStackVersions" : {
    "cluster_name" : "cl1",
    "id" : 1,
    "repository_version" : 1,
    "stack" : "HDP",
    "state" : "CURRENT",
    "version" : "2.6",
    "host_states" : {
      "CURRENT" : [
        "hbase-migration-repro-4.novalocal",
        "hbase-migration-repro-1.novalocal",
        "hbase-migration-repro-3.novalocal",
        "hbase-migration-repro-2.novalocal"
      ],
      "INIT" : [ ],
      "INSTALLED" : [ ],
      "INSTALLING" : [ ],
      "INSTALL_FAILED" : [ ],
      "NOT_REQUIRED" : [ ],
      "OUT_OF_SYNC" : [ ]
    }
  },
  "repository_versions" : [
    {
      "href" : "http://x.x.x.x:8080/api/v1/clusters/hbasetest/stack_versions/1/repository_versions/51", --- > repository version no
      "RepositoryVersions" : {
        "id" : 51,
        "stack_name" : "HDP",
        "stack_version" : "2.6"
      }
    }
  ]
}
<br>

Then you can hit the final API

curl -k -u {username}:{password} -H "X-Requested-By:ambari" -i -X GET http://{ambari-server}:{port}/api/v1/clusters/{clustername}/stack_versions/{stack-version-no}/reposi...

avatar

hi aditya , everything was great until I intend to install the service

for this example we try to install the service - Knox

I try this:

curl -u xxxx:xxxx -i -X PUT -d '{"ServiceInfo": {"state" : "INSTALLED"}}' http://182.243.5.12 :8080/api/v1/clusters/HDP101/services/Knox

HTTP/1.1 400 Bad Request X-Frame-Options: DENY X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff Cache-Control: no-store Pragma: no-cache Set-Cookie: AMBARISESSIONID=13q980rkix8lh1ewku7n3xlhfh;Path=/;HttpOnly Expires: Thu, 01 Jan 1970 00:00:00 GMT User: admin Content-Type: text/plain Content-Length: 107 Server: Jetty(8.1.19.v20160209)

Michael-Bronson

avatar

43571-capture.png

here is how I check the service name

curl -k -u xxxxx:xxxx -H "X-Requested-By:ambari" -i -X GET http://182.243.5.12
:8080/api/v1/clusters/HDP101/stack_versions/1/repository_versions/1 | grep display_name | grep -i knox

% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 11316 100 11316 0 0 603k 0 --:--:-- --:--:-- --:--:-- 613k "display_name" : "Knox",

Michael-Bronson

avatar
Super Guru

@Michael Bronson,

I thought it was only an install. If you want to add a service and install the service, there are series of steps which you need to do.

This doc will help you. Currently I do not have configuration for knox which is required in Step 3.

https://cwiki.apache.org/confluence/display/AMBARI/Adding+a+New+Service+to+an+Existing+Cluster

avatar

hi Aditya , just to be clear the status for now is that , from ambari GUI when I go to actions --> add service , then I see the Knox service but it is uncheck in the checkbox ! , so what are the steps from here ? , do we need in this case to do ( add service and install service ? )

Michael-Bronson