Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Cluster Database ID

Highlighted

Cluster Database ID

New Contributor

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.

 

 

5 REPLIES 5
Highlighted

Re: Cluster Database ID

Super Guru

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:

 

host:port/api/v11/clusters

 

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.

 

Regards,

 

Ben

Re: Cluster Database ID

Contributor

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.

Highlighted

Re: Cluster Database ID

New Contributor

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.

Highlighted

Re: Cluster Database ID

Super Guru

Hello,

 

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.

 

Ben

Highlighted

Re: Cluster Database ID

New Contributor
Hi Ben,

We don't want to get this in order to reference the cluster but in order to uniquely name our services across different clusters.

We would like to be able to reliably assign an index to service names within our clusters in a manner similar to the way in which Cloudera Manager does, it seems to use the database ID for each cluster to append to services names.

If it is not possible to obtain the cluster ID from the API then that is fine and we will have to persist with our workaround for now but being able to obtain the cluster ID would solve the issue of service naming in a much more consistent and robust way.

I hope this explains our use case sufficiently, if there are other ways of naming services so service names remain unique across clusters in a predictable fashion please let us know.

Regards,

Andy
Don't have an account?
Coming from Hortonworks? Activate your account here