I’ve seen this asked before, and wanted to share my experiences with transferring services between hosts with Ambari (this worked for me with 1.6.1, I migrated a bunch of services using this method):
Basic steps:
1. Shut down the service in Ambari
2. Disable the service:
curl –insecure -u “${AMBARI_USER}:${AMBARI_PW}” -H “X-Requested-By: ambari” -i -X PUT -d ‘{“RequestInfo”:{“context”:”Disable Component”},”Body”:{“HostRoles”:{“state”:”DISABLED”}}}’ ${AMBARI_PROTO}://localhost:${AMBARI_PORT}/api/v1/clusters/${CLUSTER_NAME}/hosts/${OLD_HOST}/host_components/NAGIOS_SERVER
3. Now you can use relocate_host_components.py to migrate (run on ambari server, this also assumes https, adjust your command line if it’s not https):
/var/lib/ambari-server/resources/scripts/relocate_host_components.py -s localhost -u ${AMBARI_USER} -p $AMBARI_PORT -r https -c $CLUSTER_NAME -w “${AMBARI_PW}” -e $OLD_HOST -m NAGIOS_SERVER -n $NEW_HOST -d
—
Separately, relocate_host_components (in ambari 1.6.1) doesn’t support https — to fix add in hte following below http_request in that file:
def https_request(self, req):
uri = req.get_full_url()
user = USERNAME
pw = PASSWORD
raw = “%s:%s” % (user, pw)
auth = ‘Basic %s’ % base64.b64encode(raw).strip()
req.add_unredirected_header(‘Authorization’, auth)
return req