Step 5: Set up the Cloudera Manager Database

Step 1: Configure a Repository Step 2: Install Java Step 3: Install Cloudera Manager Server Step 4: Install Databases Step 5: Set Up the Cloudera Manager Database Step 6: Install CDH and Other Software Step 7: Set Up a Cluster

Cloudera Manager Server includes a script that can create and configure a database for itself. The script can:

  • Create the Cloudera Manager Server database configuration file.
  • (MariaDB, MySQL, and PostgreSQL) Create and configure a database for Cloudera Manager Server to use.
  • (MariaDB, MySQL, and PostgreSQL) Create and configure a user account for Cloudera Manager Server.

Although the script can create a database, the following procedures assume that you have already created the database as described in Step 4: Install and Configure Databases.

The following sections describe the syntax for the script and demonstrate how to use it:

Syntax for scm_prepare_database.sh

The syntax for the scm_prepare_database.sh script is as follows:

/usr/share/cmf/schema/scm_prepare_database.sh [options] <databaseType> <databaseName> <databaseUser> <password>

To create a new database, you must specify the -u and -p parameters for a user with privileges to create databases. If you have already created the database as instructed in Step 4: Install and Configure Databases, do not specify these options.

The following tables describe the parameters and options for the scm_prepare_database.sh script:

Parameters
Parameter (Required in bold) Description
<databaseType> One of the supported database types:
  • MariaDB: mysql
  • MySQL: mysql
  • Oracle: oracle
  • PostgreSQL: postgresql
<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:
Options
Option Description
-?|--help Display help.
--config-path The path to the Cloudera Manager Server configuration files. The default is /etc/cloudera-scm-server.
-f|--force If specified, the script does not stop if an error occurs.
-h|--host The IP address or hostname of the host where the database is installed. The default is to use localhost.
-p|--password The admin password for the database application. Use with the -u option. The default is no password. Do not put a space between -p and the password (for example, -phunter2). If you do not want the password visible on the screen or stored in the command history, use the -p option without specifying a password, and you are prompted to enter it as follows:
Enter database password:
If you have already created the database, do not use this option.
-P|--port The port number to use to connect to the database. The default port is 3306 for MariaDB, 3306 for MySQL, 5432 for PostgreSQL, and 1521 for Oracle. This option is used for a remote connection only.
--scm-host The hostname where the Cloudera Manager Server is installed. If the Cloudera Manager Server and the database are installed on the same host, do not use this option or the -h option.
--scm-password-script A script to execute whose stdout provides the password for user SCM (for the database).
-u|--user The admin username for the database application. Use with the -p option. Do not put a space between -u and the username (for example, -uroot). If this option is supplied, the script creates a user and database for the Cloudera Manager Server. If you have already created the database, do not use this option.

Preparing the Cloudera Manager Server Database

  1. Run the scm_prepare_database.sh script on the Cloudera Manager Server host, using the database name, username, and password you created in Step 4: Install and Configure Databases:
    sudo /usr/share/cmf/schema/scm_prepare_database.sh <databaseType> <databaseName> <databaseUser>

    When prompted, enter the password.

  2. If it exists, remove the embedded PostgreSQL properties file:
    sudo rm /etc/cloudera-scm-server/db.mgmt.properties

The following examples demonstrate the syntax and output of the scm_prepare_database.sh script for different scenarios:

Example 1: Running the script when MySQL or MariaDB is co-located with the Cloudera Manager Server

This example assumes that you have already created the Cloudera Management Server database and database user, naming both 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!

Example 2: Running the script when MySQL or MariaDB is installed on another host

This example demonstrates how to run the script on the Cloudera Manager Server host (cm01.example.com) and connect to a remote MySQL or MariaDB host (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!

Example 3: Running the script to configure 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!

Installing CDH

After configuring the Cloudera Manager Server database, continue to Step 6: Install CDH and Other Software.