在采用Cloudera-Manager安装cdh时,一般使用内嵌的PostgreSQL数据库。 java
Cloudera-Manager除了保存CDH集群的配置元数据的scm数据库外,还为Activity Monitor(活动监控)、Service Monitor(服务监控)、Report Manager(报告管理)、Host Monitor(主机监控)、Cloudera Navigator(Cloudera导航)等信息分别建立数据amon、smon、rmon、hmon、nav相应的数据。 mysql
若是你运行了Hive服务,Cloudera-Manager还会建立hive数据库用于保存hive metastore即建表的元数据等。 sql
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中发现。 shell
/usr/share/cmf/schema/scm_prepare_database.sh mysql -uroot -p --scm-host localhost scm scm scm_password 数据库
main() { parse_arguments "$@" # Before making destructive changes, check # some preconditions: locate_java_home check_config_writable #create_user_and_database #write_config_file test_db_connection # This is the important bit! echo "All done, your SCM database is configured correctly!" }
1:链接数据库 oracle
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 post
输入用户口令后便可进入数据库
显示数据库列表 \l
切换数据库\c test
退出 \q
列表表、视图、序列 \d this
2:数据查询 spa
注意在查看hive数据库中表中的数据时,能够因为hive数据库在建表时,表的定义使用了大小写混合拼写的方式,在PostgreSQL中使用双引号来界定标识符使您的具体大小写混合的拼写。不然会报下图中的错误: code
ERROR: relation "dbs" does not exist
三、数据导出
pg_dump -h localhost -p 7432 -U scm > /tmp/scm_server_db_backup.$(date +%Y%m%d)