*** DRAFT - Being Edited ***
Services managed by Ambari are defined in its stacks folder.
To define your own services and stacks to be managed by Ambari, follow the steps below to define your own services or stacks
A stack is a distribution of a set of services. Multiple versions of a stack can be defined, each with its own set of services. Stacks in Ambari are defined in ambari-server/src/main/resources/stacks folder, which can be found at /var/lib/ambari-server/resources/stacks folder after install.
Services managed by a stack can be defined either in ambari-server/src/main/resources/common-services or ambari-server/src/main/resources/stacks folders. These folders after install can be found at /var/lib/ambari-server/resources/common-services or /var/lib/ambari-server/resources/stacks folders respectively.
Question: When do I define service in common-services vs. stacks folders?
One would define services in the common-services folder if there is possibility of the service being used in multiple stacks. For example, almost all stacks would need the HDFS service - so instead of redefining HDFS in each stack, the one defined in common-services is referenced from multiple stack-versions. Likewise, if a service is going to be contained in only one stack and never going to be shared, it can be defined in the stacks folder. Basically services defined in stacks folder are by used containment, whereas the ones defined in common-services are used by reference.
Define Service
Shown below is how to define a service in common-services folder. The same approach can be taken when defining services in the stacks folder, which will be discussed in the Define Stack section.
Services should provide the main metainfo.xml file which provides important metadata about the service.
Apart from that, other files can be provided to give more information about the service. More details about these files are provided below.
metainfo.xml
In the metainfo.xml file, one can first define the service and its components.
Complete reference can be found in the Writing metainfo.xml page.
A good reference implementation is the HDFS metainfo.xml.
Question: Is it possible to define multiple services in the same metainfo.xml?
Yes. Though it is possible, it is discouraged to define multiple services in the same service folder.
YARN and MapReduce2 are services that are defined together in the YARN folder. Its metainfo.xml defines both services.
Scripts
With the components defined, we need to provide scripts which can handle the various stages of the service and component's lifecycle.
The scripts necessary to manage service and components are specified in the metainfo.xml (HDFS)
These scripts should be provided in the <service-id>/<service-version>/package/scripts folder.
Folder | Purpose |
---|---|
package/scripts | Contains scripts invoked by Ambari. These scripts are loaded into the execution path with the correct environment |
package/files | Contains files used by above scripts. Generally these are other scripts (bash, python, etc.) invoked as a separate process. Example: checkWebUI.py (HDFS) |
package/templates | Template files used by above scripts to generate files on managed hosts. These are generally configuration files required by the service to operate. |