Support Questions

Find answers, ask questions, and share your expertise

How to check if Ambari setup was already done?

avatar
Contributor

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

avatar
Rising Star

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

avatar
Rising Star

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 ~]#

avatar
Contributor

Great thanks!

avatar

@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.

avatar
Contributor

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

avatar
Master 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.