Support Questions
Find answers, ask questions, and share your expertise

How to check if Ambari setup was already done?

Explorer

When automating the setup of Ambari, is there an easy way of checking if "ambari-server setup" was already done, in order to skip this step in a script?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to check if Ambari setup was already done?

Contributor

Ambari stores the configuration information in /etc/ambari-server/conf/ambari.properties file on Ambari server host. You could check something like below for the jdbc user and database name before invoking "ambari-server setup":

cat /etc/ambari-server/conf/ambari.properties  | grep jdbc.user.name
server.jdbc.user.name=<ambari_database_user_name>


cat /etc/ambari-server/conf/ambari.properties  | grep jdbc.database
server.jdbc.database=mysql
server.jdbc.database_name=<database_name>

If the entries exist and match with your environment, the setup was already done

On a fresh Ambari install where "ambari-server setup" is not yet done, this is what you would get:

[root@c6409 ~]# cat /etc/ambari-server/conf/ambari.properties  | grep jdbc.user.name
[root@c6409 ~]# echo $?
1
[root@c6409 ~]#

View solution in original post

5 REPLIES 5

Re: How to check if Ambari setup was already done?

Contributor

Ambari stores the configuration information in /etc/ambari-server/conf/ambari.properties file on Ambari server host. You could check something like below for the jdbc user and database name before invoking "ambari-server setup":

cat /etc/ambari-server/conf/ambari.properties  | grep jdbc.user.name
server.jdbc.user.name=<ambari_database_user_name>


cat /etc/ambari-server/conf/ambari.properties  | grep jdbc.database
server.jdbc.database=mysql
server.jdbc.database_name=<database_name>

If the entries exist and match with your environment, the setup was already done

On a fresh Ambari install where "ambari-server setup" is not yet done, this is what you would get:

[root@c6409 ~]# cat /etc/ambari-server/conf/ambari.properties  | grep jdbc.user.name
[root@c6409 ~]# echo $?
1
[root@c6409 ~]#

View solution in original post

Re: How to check if Ambari setup was already done?

Explorer

Great thanks!

Re: How to check if Ambari setup was already done?

@Stefan Kupstaitis-Dunkler

You could query the Ambari db for table "clusters" for eg.

mysql> select * from clusters;
+------------+-------------+--------------+--------------+--------------------+---------------+-----------------------+------------------+
| cluster_id | resource_id | cluster_info | cluster_name | provisioning_state | security_type | desired_cluster_state | desired_stack_id |
+------------+-------------+--------------+--------------+--------------------+---------------+-----------------------+------------------+
|          2 |           4 |              | Test       | INSTALLED          | NONE          |                       |                3 |
+------------+-------------+--------------+--------------+--------------------+---------------+-----------------------+------------------+
1 row in set (0.01 sec)

Or using curl get http://<ambari-server>:8080/api/v1/clusters/C1/ and process.

Re: How to check if Ambari setup was already done?

Explorer

Thank you @vpoornalingam! Two options, both of which are more effort than @vsharma's options though.

Re: How to check if Ambari setup was already done?

Mentor

This approach actually also checks whether HDP is provisioned whereas the first approach only says Ambari setup stepnis done. Of course from your question, its clear you only need that.