Adding service to HDP using REST API

Create hosts components

The services have to have hosts components – defining on which nodes in the cluster the service is going to run.
In this case, Pig is installed on both instances: NameNode and DataNode

Example how to create a hosts component on a $MASTER_DNS:

curl -u admin:admin -H "X-Requested-By:ambari" -i -X POST -d '{"host_components" : [{"HostRoles":{"component_name":"PIG"}}] }' 'http://'$AMBARI_SERVER':8080/api/v1/clusters/'$CLUSTER_NAME'/hosts?Hosts/host_name='$MASTER_DNS''

Result

The state is now INIT.

add hosts component output.png

This step is repeated on all nodes of the cluster where this component should be installed.

Install the service

curl -u admin:admin -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Install PIG via REST API"}, "ServiceInfo": {"state" : "INSTALLED"}}' 'http://'$AMBARI_SERVER':8080/api/v1/clusters/'$CLUSTER_NAME'/services/PIG'

The output is the following:

install service output

In Ambari, the install process can be observed:

install service ambari

And final status – service Pig is installed on 2 clients and the 3 mandatory config files are available.final state ambari configs

final state ambari summary

Smoke test

The service is now ready to use. If it would be done through Ambari, it would be tested. One way to do a manual test of the service is to run the test from the menu Service Actions on the right.
To run a Pig Smoke Test, Tez and Slider have to be installed as well.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s