As of Ambari 1.5.0, the "Add Service" capability is available in the Ambari Web UI (Services > Actions menu in the Services area). Below describes the method to add a Service via the REST API.
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.
NOTE: Make sure to append, -H "X-Requested-By:ambari" as a part of your curl calls for Ambari versions 1.4.1 and up.
Step 1 - Add a Service to the cluster
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:
Number of Instances
1 or many
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.
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 the cluster
The configurations as of Ambari 1.3.0 are attached to the cluster and overridable at service, service component and host component levels.
Step 5 - Create host components
This essentially means creating the host to service component mapping or assigning Roles to hosts in your cluster.
Step 6 - Install & Start the service
Make sure the service components are created and the configurations attached by making a GET call.
Install the service.
Start the service.