步骤5:设置Cloudera Manager数据库
Cloudera Manager Server包含一个可以为自己创建和配置数据库的脚本。该脚本可以:
- 创建Cloudera Manager Server数据库配置文件。
- (MariaDB,MySQL和PostgreSQL)为Cloudera Manager Server创建和配置数据库以供使用。
- (MariaDB,MySQL和PostgreSQL)为Cloudera Manager Server创建和配置用户帐户。
虽然脚本可以创建数据库,但以下过程假定您已按步骤4:安装和配置数据库中所述创建了数据库。
以下部分描述了脚本的语法并演示了如何使用它:
语法 scm_prepare_database.sh
的语法 scm_prepare_database.sh 脚本如下:
/usr/share/cmf/schema/scm_prepare_database.sh [options] <databaseType> <databaseName> <databaseUser> <password>
注意:您也可以运行scm_prepare_database.sh 没有选项来查看语法。
要创建新数据库,必须指定 -u 和 -p具有创建数据库权限的用户的参数。如果已按照步骤4:安装和配置数据库中的说明创建了数据库,请不要指定这些选项。
下表描述了该参数和选项 scm_prepare_database.sh 脚本:
参数
Parameter (Required in bold) | Description |
---|---|
<databaseType> | One of the supported database types:
|
<databaseName> | The name of the Cloudera Manager Server database to use. For MySQL, MariaDB, and PostgreSQL databases, the script can create the specified database if you specify the -u and -p options with the credentials of a user that has privileges to create databases and grant privileges. The default database name provided in the Cloudera Manager configuration settings is scm, but you are not required to use it. |
<databaseUser> | The username for the Cloudera Manager Server database to create or use. The default username provided in the Cloudera Manager configuration settings is scm, but you are not required to use it. |
<password> | The password for the <databaseUser> to create or use. If you do not want the password visible on the screen or stored in the command history, do not specify the password, and you are prompted to enter it as follows:
Enter SCM password: |
选项
选项 | 描述 |
---|---|
-?|--help
|
显示帮助。 |
--config-path | Cloudera Manager Server配置文件的路径。默认是的/etc/cloudera-scm-server。 |
-f | --force | 如果指定,则在发生错误时脚本不会停止。 |
-h | --host | 安装数据库的主机的IP地址或主机名。默认是使用localhost。 |
-p | --password | 数据库应用程序的管理员密码。与...一起使用-u选项。默认为无密码。不要在它们之间留一个空格-p 和密码(例如, -phunter2)。如果您不希望密码在屏幕上可见或存储在命令历史记录中,请使用-p选项而不指定密码,系统会提示您输入密码,如下所示:
输入数据库密码: 如果您已经创建了数据库,请不要使用此选项。 |
-P | --port | 用于连接数据库的端口号。对于MariaDB,默认端口为3306,对于MySQL为3306,对于PostgreSQL为5432,对于Oracle为1521。此选项仅用于远程连接。 |
--scm-host | 安装Cloudera Manager Server的主机名。如果Cloudera Manager Server和数据库安装在同一主机上,请不要使用此选项或-h 选项。 |
--scm-password-script
|
一个执行其脚本的脚本 stdout 提供用户SCM的密码(用于数据库)。
|
-u | --user | 数据库应用程序的管理员用户名。与...一起使用-p选项。不要在它们之间留一个空格 -u 和用户名(例如, -uroot)。如果提供此选项,脚本将为Cloudera Manager Server创建用户和数据库。如果您已经创建了数据库,请不要使用此选项。 |
准备Cloudera Manager Server数据库
- 跑过 scm_prepare_database.shCloudera Manager Server主机上的脚本,使用您在步骤4:安装和配置数据库中创建的数据库名称,用户名和密码:
sudo /usr/share/cmf/schema/scm_prepare_database.sh <databaseType> <databaseName> <databaseUser>
出现提示时,输入密码。
- 如果存在,请删除嵌入的PostgreSQL属性文件:
sudo rm /etc/cloudera-scm-server/db.mgmt.properties
以下示例演示了语法和输出 scm_prepare_database.sh 不同场景的脚本:
示例1:当MySQL或MariaDB与Cloudera Manager Server位于同一位置时运行脚本
此示例假定您已创建Cloudera Management Server数据库和数据库用户,同时命名两者 SCM:
sudo /usr/share/cmf/schema/scm_prepare_database.sh mysql scm scm
Enter SCM password:
JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing: /usr/java/jdk1.7.0_67-cloudera/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:/usr/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
[ main] DbCommandExecutor INFO Successfully connected to database.
All done, your SCM database is configured correctly!
JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing: /usr/java/jdk1.7.0_67-cloudera/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:/usr/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
[ main] DbCommandExecutor INFO Successfully connected to database.
All done, your SCM database is configured correctly!
示例2:在另一台主机上安装MySQL或MariaDB时运行脚本
此示例演示如何在Cloudera Manager Server主机上运行脚本(cm01.example.com)并连接到远程MySQL或MariaDB主机(db01.example.com):
sudo /usr/share/cmf/schema/scm_prepare_database.sh mysql -h db01.example.com --scm-host cm01.example.com scm scm
Enter database password:
JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing: /usr/java/jdk1.7.0_67-cloudera/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:/usr/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
[ main] DbCommandExecutor INFO Successfully connected to database.
All done, your SCM database is configured correctly!
JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing: /usr/java/jdk1.7.0_67-cloudera/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:/usr/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
[ main] DbCommandExecutor INFO Successfully connected to database.
All done, your SCM database is configured correctly!
示例3:运行脚本以配置Oracle
sudo /usr/share/cmf/schema/scm_prepare_database.sh -h cm-oracle.example.com oracle orcl sample_user sample_pass
Enter SCM password:
JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing: /usr/java/jdk1.7.0_67-cloudera/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:/usr/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
[ main] DbCommandExecutor INFO Successfully connected to database.
All done, your SCM database is configured correctly!
JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing: /usr/java/jdk1.7.0_67-cloudera/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:/usr/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
[ main] DbCommandExecutor INFO Successfully connected to database.
All done, your SCM database is configured correctly!
安装CDH
配置Cloudera Manager Server数据库后,继续执行步骤6:安装CDH和其他软件。
sudo /usr/share/cmf/schema/scm_prepare_database.sh mysql scm scm
sudo /usr/share/cmf/schema/scm_prepare_database.sh mysql amon amon
sudo /usr/share/cmf/schema/scm_prepare_database.sh mysql rman rman
sudo /usr/share/cmf/schema/scm_prepare_database.sh mysql hue hue
sudo /usr/share/cmf/schema/scm_prepare_database.sh mysql metastore hive
sudo /usr/share/cmf/schema/scm_prepare_database.sh mysql sentry sentry
sudo /usr/share/cmf/schema/scm_prepare_database.sh mysql nav nav
sudo /usr/share/cmf/schema/scm_prepare_database.sh mysql navms navms
sudo /usr/share/cmf/schema/scm_prepare_database.sh mysql oozie oozie
echo "vm.swappiness=10" >>/etc/sysctl.conf
sysctl -p
cat /proc/sys/vm/swappiness