在采用cloudera-manager安裝cdh時,通常使用内嵌的postgresql資料庫。
cloudera-manager除了儲存cdh叢集的配置中繼資料的scm資料庫外,還為activity monitor(活動監控)、service monitor(服務監控)、report manager(報告管理)、host monitor(主機監控)、cloudera navigator(cloudera導航)等資訊分别建立資料amon、smon、rmon、hmon、nav相應的資料。
如果你運作了hive服務,cloudera-manager還會建立hive資料庫用于儲存hive metastore即建表的中繼資料等。
scm資料庫的使用者名,密碼
more /etc/cloudera-scm-server/db.properties
其他資料庫(如amon,hmon,smon,rman,nav)的使用者名、密碼
more /etc/cloudera-scm-server/db.mgmt.properties
資料庫管理者(相當于oracle dba)cloudera-scm的使用者名、密碼
/var/lib/cloudera-scm-server-db/data/generated_password.txt
hive資料庫的使用者名、密碼
you can find the databaes admin(cloudera-scm) password in /var/lib/cloudera-scm-server-db/data/generated_password.txt.
if you start the hive metastore server, the hive password will be in its hive-site.xml. you can see this file by clicking on your hive metastore server, then clicking on processes, expanding show, and clicking on hive-site.xml.
http://xxxx:7180/cmf/process/808/config?filename=hive-site.xml
即hive資料庫的密碼可以在hive-site.xml中發現。
/usr/share/cmf/schema/scm_prepare_database.sh mysql -uroot -p --scm-host localhost scm scm scm_password
如果不需要建立資料庫和配置檔案,可以在main方法中注釋掉對應的代碼
1:連接配接資料庫
psql --host=localhost --port=7432 --username=scm --dbname=postgres -v on_error_stop=1
psql --host=localhost --port=7432 --username=hmon --dbname=hmon -v on_error_stop=1
psql --host=localhost --port=7432 --username=hive --dbname=hive -v on_error_stop=1
psql --host=localhost --port=7432 --username=cloudera-scm -w=cl5y3a3i6c --dbname=postgres -v on_error_stop=1
輸入使用者密碼後即可進入資料庫
顯示資料庫清單 \l
切換資料庫\c test
退出 \q
清單表、視圖、序列 \d
2:資料查詢
注意在檢視hive資料庫中表中的資料時,可以由于hive資料庫在建表時,表的定義使用了大小寫混合拼寫的方式,在postgresql中使用雙引号來界定辨別符使您的具體大小寫混合的拼寫。否則會報下圖中的錯誤:
error: relation "dbs" does not exist
3、資料導出
pg_dump -h localhost -p 7432 -u scm > /tmp/scm_server_db_backup.$(date +%y%m%d)