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.
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:
In Ambari, the install process can be observed:
And final status – service Pig is installed on 2 clients and the 3 mandatory config files are available.
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.