I'm running some Ansible scripts to configure a Cloudera Cluster.
I have come across an issue whilst creating services in multiple clusters which I would like to resolve by fetching the cluster database ID from the Cloudera Manager so that I can use this in the service name postfix in the same way that manual GUI installations do.
I have tried to find this ID in the config output of all levels of the cluster, Manager, manager service, cluster, service, role and have been unable to get to it.
The only time it has been returned from the manager was during an error response whlist trying to add a service to a cluster with a name that already existed for that service in a different cluster, whilst I could force this error and parse the exception message, this is far from an ideal solution.
Please could someone let me know if this piece of cluster configuration data is available via the CM API and if so which call should I use to retrieve it.
If it is not possible to get the ID from any CM API source how future proof would the solution proposed be, i.e. forcing the error and parsing the error message to get the cluster DB id?
Any help in this would be greatly appreciated.
I am not sure exactly what you mean by Cluster Database ID, but if you are looking for the cluster name, the following CM API returns it:
The API version depends on what version of CM you are using. Run host:port/api/version to return the max API level supported by your CM version.
If you cannot get it from CM API, can you run sql query to query your CM db directly? mysql ie:
# mysql -u root -e "select CLUSTER_ID from scm.CLUSTERS;"
| CLUSTER_ID |
| 1 |
not sure if this is the database ID you mentioned thought. But I belive you should be able to find what you need under scm database.
Thanks for the help folkes,
It is the unique database ID that I would like to get but I'd like to get it from the CM api without accessing the db as this would require me to distribute the db credentials which is just not possible given my security constraints.
I have a work around currently which is to take the id from an enumerated list of clusters returned by the cm api, but this is not ideal and presumes that a cluster will never be removed.
Any further help greatly appreciated.
As far as I know, we don't expose the database id via the API. Why isn't "name" sufficient to reference the cluster? I'm trying to understand the use case to see if there is a different approach that could work for you.