Community Articles
Find and share helpful community-sourced technical articles
Labels (1)
Expert Contributor

Story: From the documentation I was able to add a service to existing stack definition in Ambari.

Issue: But I was either not able to stop the service or delete the service just in case.

How did I solve the problem?

  • 1.Create and Add Stack:

cd /var/lib/ambari-server/resources/stacks/HDP/2.4/services

  • 2.Create a directory that contains the service definition for SAMPLESRV

mkdir /var/lib/ambari-server/resources/stacks/HDP/2.4/services/SAMPLESRV

cd /var/lib/ambari-server/resources/stacks/HDP/2.4/services/SAMPLESRV

  • 3.Create a metainfo.xml as show in the link above.

  • 4.With this we have a service name as SAMPLESRV and it contains SAMPLESRV_MASTER, SAMPLESRV_SLAVE and SAMPLESRV_CLIENT

  • 5.Next we need to create the command scripts

mkdir –p /var/lib/ambari-server/resources/stacks/HDP/2.4/services/SAMPLESRV/package/scriptscd /var/lib/ambari-server/resources/stacks/HDP/2.4/services/SAMPLESRV/package/scripts

  • 6.Browse the scripts directory and create the .py command, and under : /var/lib/ambari-server/resources/stacks/HDP/2.4/services/SAMPLESRV/package/scripts and



here was the issue: in the documentation it doesn’t mention about the that needs to be created. Since we have not installed a real service, there is no PID file created by it. Therefore, we are going to artificially create the PID, remove the PID and check the process status of the dummy pid.

  • 7.Then restart ambari: ambari-server restart and add the service to the stack as shown the document. Just don't want to duplicate the process with steps here.




Hope this helps....



I did the similar stuff and it works fine when starting\stopping service.

But for restart it fails. Looks like it runs status check after stop and status check fails because pid file is already deleted:

Traceback (most recent call last):
  File "/var/lib/ambari-agent/cache/stacks/HDP/2.5/services/CATALOGER/package/scripts/", line 28, in <module>
  File "/usr/lib/python2.6/site-packages/resource_management/libraries/script/", line 280, in execute
  File "/usr/lib/python2.6/site-packages/resource_management/libraries/script/", line 709, in restart
  File "/var/lib/ambari-agent/cache/stacks/HDP/2.5/services/CATALOGER/package/scripts/", line 25, in status
    Execute ( format("cat {pid_file}") );
  File "/usr/lib/python2.6/site-packages/resource_management/core/", line 155, in __init__
  File "/usr/lib/python2.6/site-packages/resource_management/core/", line 160, in run
    self.run_action(resource, action)
  File "/usr/lib/python2.6/site-packages/resource_management/core/", line 124, in run_action
  File "/usr/lib/python2.6/site-packages/resource_management/core/providers/", line 273, in action_run
    tries=self.resource.tries, try_sleep=self.resource.try_sleep)
  File "/usr/lib/python2.6/site-packages/resource_management/core/", line 71, in inner
    result = function(command, **kwargs)
  File "/usr/lib/python2.6/site-packages/resource_management/core/", line 93, in checked_call
    tries=tries, try_sleep=try_sleep)
  File "/usr/lib/python2.6/site-packages/resource_management/core/", line 141, in _call_wrapper
    result = _call(command, **kwargs_copy)
  File "/usr/lib/python2.6/site-packages/resource_management/core/", line 294, in _call
    raise Fail(err_msg)
resource_management.core.exceptions.Fail: Execution of 'cat /opt/app/' returned 1. cat: /opt/app/ No such file or directory

Don't have an account?
Version history
Revision #:
2 of 2
Last update:
‎08-17-2019 11:34 AM
Updated by:
Top Kudoed Authors