Monthly Archives: September 2015

request Ambari database

Some of you may want to see what’s in Ambari database.
By default, data is stored in Postgres, and for those which are not familiar with, here are the basics : you shall connect with user ambari to DB ambari, default password is bigdata.

[vagrant@gw ~]$ # find password
[vagrant@gw ~]$ sudo cat /etc/ambari-server/conf/password.dat
bigdata

[vagrant@gw ~]$ # connect to ambari DB
[vagrant@gw ~]$ psql -U ambari ambari
Password for user ambari: bigdata
psql (8.4.20)
Type "help" for help.

ambari=> -- show all tables
ambari=> \d
List of relations
Schema | Name | Type | Owner
--------+-------------------------------+-------+----------
ambari | adminpermission | table | postgres
ambari | adminprincipal | table | postgres
ambari | adminprincipaltype | table | postgres
ambari | adminprivilege | table | postgres
--More--

ambari=> -- describe table hosts
ambari=> \d hosts
Table "ambari.hosts"
Column | Type | Modifiers
------------------------+--------------------------+-----------
host_name | character varying(255) | not null
cpu_count | integer | not null
ph_cpu_count | integer |
cpu_info | character varying(255) | not null
discovery_status | character varying(2000) | not null
host_attributes | character varying(20000) | not null
ipv4 | character varying(255) |
ipv6 | character varying(255) |
public_host_name | character varying(255) |
last_registration_time | bigint | not null
os_arch | character varying(255) | not null
os_info | character varying(1000) | not null
os_type | character varying(255) | not null
rack_info | character varying(255) | not null
total_mem | bigint | not null
Indexes:
"hosts_pkey" PRIMARY KEY, btree (host_name)
Referenced by:
TABLE "clusterhostmapping" CONSTRAINT "clusterhostmapping_cluster_id" FOREIGN KEY (host_name) REFERENCES hosts(host_name)
TABLE "configgrouphostmapping" CONSTRAINT "fk_cghm_hname" FOREIGN KEY (host_name) REFERENCES hosts(host_name)
--More--

ambari=> select host_name, ipv4, public_host_name, total_mem from hosts;
host_name | ipv4 | public_host_name | total_mem
-----------------+-----------+------------------+-----------
nn.example.com | 10.0.2.15 | nn.example.com | 1922680
dn1.example.com | 10.0.2.15 | dn1.example.com | 1922680
gw.example.com | 10.0.2.15 | gw.example.com | 1922680
(3 rows)

ambari=> -- quit
ambari=> \q
[vagrant@gw ~]$