You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Steps to add a new service to an existing cluster (the service is already part of the stack)

The stack definition can be found under server resources. On an installed and running Ambari server the location would be /var/lib/ambari-server/resources/stacks.

Step 1 - Add a Service to the cluster

API Call

curl -u <username>:<password> -i -X POST -d '{"ServiceInfo":{"service_name":"<service-name>"}}' http://<ambari-server-host>:8080/api/v1/clusters/<cluster-name>/services


Step 2 - Add Components to the service

Service components are defined in the metainfo.xml file found in the service definition under HDP stack. E.g.: ambari-server/resources/stacks/HDP/0.1/services/HBASE/metainfo.xml

Service Component types:

Type

Number of Instances

Example

MASTER

1 or many

HBASE (multi-master)

SLAVE

many

TASKTRACKER

CLIENT

many

HDFS CLIENT

API Call

curl -u <username>:<password> -i -X POST http://<ambari-server-host>:8080/api/v1/clusters/<cluster-name>/services/<service-name>/components/<component-name>

Example:

curl -u <username>:<password> -i -X POST http://<ambari-server-host>:8080/api/v1/clusters/c1/services/MAPREDUCE/components/JOBTRACKER


Step 3 - Create configuration

Configurations in Ambari are distinguished using type and tag properties. Once a configuration is created it can be applied to a service, specifying the type and tag for the configuration.
The tag can be treated as a version number with a versioning scheme like, "version" + unix timestamp, indicating that the latest tag is also the latest configuration.

API Call

curl -u <username>:<password> -i -X POST -d '{"type": "<config-type>", "tag": "<config-tag>", "properties" : { "key1" : "value1", "key2" : "value2", "key3" : "value3" }}' http://<ambari-server-host>:8080/api/v1/clusters/<cluster-name>/configurations

Example:

curl -i -X POST -d '{"type": "core-site", "tag": "version1363902625", "properties" : { "fs.default.name" : "localhost:8020"}}' http://<cluster-name>:8080/api/v1/clusters/c1/configurations

Note:
This is not an incremental add to properties and every configuration once created is immutable.
New lines and spaces are tolerated. This is specially important when copying existing configuration that is pretty printed JSON string.


Step 4 - Apply configuration to service

API call

curl -u <username>:<password> -i -X PUT -d '{"config": {"<config-type>": "<config-tag>" }}' http://<ambari-server-host>:8080/api/v1/clusters/<cluster-name>/services/<service-name>

Example:

curl -u admin:admin -i -X PUT -d '{"config": {"core-site": "version1363902625" }}' http://<cluster-name>:8080/api/v1/clusters/c1/services/MAPREDUCE


Step 5 - Create host components

This essentially means creating the host to service component mapping or assigning Roles to hosts in your cluster.

API Call

curl -u <username>:<password> -i -X POST -d '{"host_components" : <ac:link><ri:page ri:space-key="{"HostRoles"" ri:content-title="{"component_name":"<component-name>"}}" /></ac:link> }' http://<ambari-server-host>:8080/api/v1/clusters/<cluster-name>/hosts?Hosts/host_name=<host-names>

Note: This is the same hostname used during registration of the host. Multiple hosts can be assigned the same Role using this API


Step 6 - Install & Start the service

Make sure the service components are created and the configurations attached by making a GET call.

http://<ambari-server-host>:8080/api/v1/clusters/<cluster-name>/services/<service-name>

Install the service.

API Call

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

Start the service.

API Call

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

  • No labels