Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 03-02-2016 03:18 PM
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?
Created 03-02-2016 03:31 PM
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 ~]#
Created 03-02-2016 03:31 PM
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 ~]#
Created 03-02-2016 04:47 PM
Great thanks!
Created 03-02-2016 04:05 PM
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.
Created 03-02-2016 04:48 PM
Thank you @vpoornalingam! Two options, both of which are more effort than @vsharma's options though.
Created 03-02-2016 06:08 PM
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.