Syntax for scm_prepare_database.sh

Review the syntax of the scm_prepare_database.sh script before you run it to configure the Cloudera Manager database.

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

sudo /opt/cloudera/cm/schema/scm_prepare_database.sh <optional parameter> <databaseType> <databaseName> <databaseUser> <password>

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

Table 1. Parameters
Parameter (Required in bold) Description
<databaseType> One of the supported database types:
  • PostgreSQL: postgresql
  • MariaDB: mysql
  • MySQL: mysql
  • Oracle: oracle
<databaseName> The name of the Cloudera Manager Server database to use. For 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 can also use any other database name such as cm_db or cmdb1.
<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_user, but you can also use any other database user such as cm_user or cm_db_user.
<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:
Table 2. Options
Option Description
-s|--ssl

Optional parameter to enable SSL/TLS encryption.

This parameter will enable SSL. Without this parameter in the command, you cannot enable the SSL encryption.

--jdbc-url

Optional parameter which allows users to provide a custom JDBC URL for connecting to the database.

The provided values in the JDBC URL will override the default values for the database hostname, database type, and database name.

-?|--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:
  • PostgreSQL: 5432
  • MariaDB: 3306
  • MySQL: 3306
  • Oracle: 1521
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 run 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.

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

Example 1: Running the script to configure MySQL with TLS 1.2 enabled

This example demonstrates how to run the script on the MySQL or MariaDB host (db01.example.com):

sudo /opt/cloudera/cm/schema/scm_prepare_database.sh -u<USER 1 TO CREATE THE DB> -p<PASSWORD> -h<DB HOSTNAME> --jdbc-url "jdbc:mysql://<DB HOSTNAME>:<DB-PORT>/<DB-Name>?sslMode=VERIFY_CA&trustCertificateKeyStoreUrl=file://<PATH_TO_TRUSTSTORE_FILE>&trustCertificateKeyStoreType=jks&trustCertificateKeyStorePassword=<TRUSTSTORE_PASSWORD>&enabledTLSProtocols=TLSv1.2" mysql <DB NAME> <USER 2 TO USE FROM CM> <PASSWORD> --ssl
JAVA_HOME=/usr/java/jdk1.8.0_232-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing:  /usr/java/jdk1.8.0_232-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:/opt/cloudera/cm/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
[main] DbCommandExecutor INFO  A JDBC URL override was specified. Using this as the URL to connect to the database and overriding all other values.
[main] DbCommandExecutor INFO  Successfully connected to database.
All done, your SCM database is configured correctly!

Example 2: Running the script to configure PostgreSQL with TLS 1.2 enabled

This example demonstrates how to run the script on the PostgreSQL host (db01.example.com):

sudo /opt/cloudera/cm/schema/scm_prepare_database.sh -u<USER 1 TO CREATE THE DB> -p<PASSWORD> -h<DB HOSTNAME> --jdbc-url "jdbc:postgresql://<DB HOSTNAME>:<DB-PORT>/<DB NAME>?ssl=true&sslmode=verify-ca&sslrootcert=<PATH_TO_ROOT_CERTIFICATE>” postgresql <DB NAME> <USER 2 TO USE FROM CM> <PASSWORD> --ssl
JAVA_HOME=/usr/java/jdk1.8.0_232-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing: /usr/java/jdk1.8.0_232-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:/opt/cloudera/cm/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
[main] DbCommandExecutor INFO A JDBC URL override was specified. Using this as the URL to connect to the database and overriding all other values.
[main] DbCommandExecutor INFO Successfully connected to database.
All done, your SCM database is configured correctly!

Example 3: Running the script to configure Oracle with TLS 1.2 enabled

This example demonstrates how to run the script on the Oracle host (db01.example.com):

sudo /opt/cloudera/cm/schema/scm_prepare_database.sh -u<USER 1 TO CREATE THE DB> -p<PASSWORD> -h<DB HOSTNAME> --jdbc-url "jdbc:oracle:thin:@tcps://<DB HOSTNAME>:<DB-PORT>:<SERVICE_NAME>?javax.net.ssl.trustStore=<PATH_TO_TRUSTSTORE_FILE>&javax.net.ssl.trustStorePassword=<TRUSTSTORE_PASSWORD>&oracle.net.ssl_server_dn_match=false" oracle <SERVICE_ NAME> <USER 2 TO USE FROM CM> <PASSWORD> --ssl
JAVA_HOME=/usr/java/jdk1.8.0_232-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing:  /usr/java/jdk1.8.0_232-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:/opt/cloudera/cm/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
2023-07-14 07:37:58,575 [main] INFO  com.cloudera.enterprise.dbutil.DbCommandExecutor  - A JDBC URL override was specified. Using this as the URL to connect to the database and overriding all other values.
2023-07-14 07:37:59,416 [main] INFO  com.cloudera.enterprise.dbutil.DbCommandExecutor  - Successfully connected to database.
All done, your SCM database is configured correctly!

Example 4: 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 /opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm scm
Enter SCM password:
JAVA_HOME=/usr/java/jdk1.8.0_141-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing:  /usr/java/jdk1.8.0_141-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:/opt/cloudera/cm/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 5: 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 /opt/cloudera/cm/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.8.0_141-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing:  /usr/java/jdk1.8.0_141-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:/opt/cloudera/cm/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 6: Running the script to configure Oracle

sudo /opt/cloudera/cm/schema/scm_prepare_database.sh -h cm-oracle.example.com oracle orcl sample_user sample_pass
JAVA_HOME=/usr/java/jdk1.8.0_141-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing:  /usr/java/jdk1.8.0_141-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:/opt/cloudera/cm/schema/../lib/*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!