bugcy013
9/25/2014 - 3:58 PM

migrate scm database from PostgreSQL to MySQL

migrate scm database from PostgreSQL to MySQL

These are the steps that you need to follow in order to migrate scm database from PostgreSQL to MySQL - let me know if you need assistance or have any further questions. 

1. Stop all cluster services including the Cloudera Manager monitoring services and Agents on all hosts, using the Cloudera Manager UI. 
2. Invoke the API call to /api/v4/cm/deployment. Example that directs the resulting output to a file for later use: 
$ curl -v -u admin:password http://your_cloudera_manager_host:7180/api/v4/cm/deployment > path/to/file 
Note: It is critical this file be retained and protected as it will be needed to re-import the functional configuration into the new database. 
3. Take a fail-safe database backup from the embedded postgres database or make a tarball (or other copy) of the /var/lib/cloudera-scm-server-db/ directory to a safe location. Either will accomplish the needed outcome, just pick the most convenient for your environment. And backup contents of the directory /etc/cloudera-scm-server/* 
4. On the server where the Cloudera Manager embedded database is running: 
$ service cloudera-scm-server stop 
$ service cloudera-scm-server-db stop 
$ chkconfig cloudera-scm-server-db off 
5. If not already done, ensure the MYSQL JDBC connector is installed and in the correct location [1] see "Installing the MySQL JDBC Connector". 
6. Install, configure, and start a new database following the published instructions for MySQL (or Postgres ). 
7. Follow the best-practice configuration inclusions to the my.cnf file. 
8. Create "temp" db and grants for "temp" db as documented in this "Example 1: Running the script when MySQL is installed on another host" [2] 
Example: 
mysql> create temp; 
mysql> grant all on *.* to 'temp'@'%' identified by 'temp' with grant option; 
9. Execute $ scm_prepare_database.sh mysql -h mysqlhost -u temp -ptemp --scm-host [cloudera-manager-host] [database-name] [username] [password] 
Note: NB: run /usr/share/cmf/schema/scm_prepare_database.sh with no arguments to get syntax assistance and for help customizing this preparation for your environment (see more in [3]). 
10. When complete, start the Cloudera Manager server service: 
$ service cloudera-scm-server start 
11. Log in to the Cloudera Manager web user interface and upload the enterprise license key. 
12. After license upload do the following: 
$ service cloudera-scm-server restart 
13. From the command line of the node where the configuration export (from step 2) was performed, issue: 
$ curl --upload-file /path/to/file -u youruser:yourpassword http://your_cloudera_manager_host:7180/api/v4/cm/deployment?deleteCurrentDeployment=true 
14. Log in to Cloudera Manager and verify configuration options are now all present. 
15. To avoid later contention: yum erase cloudera-manager-server-db 
Note: Ensure the file /etc/cloudera-scm-server/db.properties reflects the detail for the newly-established database and not the previous embedded postgres database. 

Links: 
[1] http://www.cloudera.com/content/cloudera-content/cloudera-docs/CM4Ent/latest/Cloudera-Manager-Installation-Guide/cmig_install_mysql.html 
[2] http://www.cloudera.com/content/cloudera-content/cloudera-docs/CM4Ent/latest/Cloudera-Manager-Installation-Guide/cmig_install_path_C.html 
[3] http://www.cloudera.com/content/cloudera-content/cloudera-docs/CM4Ent/latest/Cloudera-Manager-Installation-Guide/cmig_install_path_B.htm