You are here: RPM Installation > Upgrading > Migrating the MAM Database from MySQL to PostgreSQL

2.28 Migrating the MAM Database from MySQL to PostgreSQL

PostgreSQL is the preferred DBMS for MAM. Customers who have already installed MySQL as the DBMS for MAM are not required to migrate their database to use PostgreSQL at this time. However, MySQL is considered deprecated and new installations will only use PostgreSQL.

PostgreSQL does not provide a standard procedure for migrating an existing database from MySQL to PostgreSQL. Adaptive Computing has had success using the py-mysql2pgsql tools for migrating/converting/exporting data from MySQL to PostgreSQL. See https://github.com/philipsoutham/py-mysql2pgsq for additional details.

To Migrate the MAM Database

This procedure was successfully tested on an actual customer MySQL database with millions of transactions on CentOS 6.4. It completed in less than an hour.

  1. Make a backup copy of your MySQL mam database.

    [root]# mysqldump mam > /archive/mam.mysql
  2. Follow the instructions to Install PostgreSQL.
  3. Install the prerequisite packages.

    [root]# yum install git postgresql-devel gcc MySQL-python python-psycopg2 PyYAML termcolor python-devel
  4. Install pg-mysql2pgsql (from source).

    [root]# cd /software
    [root]# git clone git://github.com/philipsoutham/py-mysql2pgsql.git
    [root]# cd py-mysql2pgsql
    [root]# python setup.py install
  5. Run pg-mysql2pgsql once to create a template yaml config file.

    [root]# py-mysql2pgsql -v
  6. Edit the config file to specify the MySQL database connection information and a file to output the result.

    [root]# vi mysql2pgsql.yml
    mysql:
    hostname: localhost
    port: 3306
    socket:
    username: mam
    password: changeme
    database: mam
    compress: false
    destination:
    # if file is given, output goes to file, else postgres
    file: /archive/mam.pgsql
    postgres:
    hostname: localhost
    port: 5432
    username:
    password:
    database:
  7. Run the pg-mysql2pgsql program again to convert the database.

    [root]# py-mysql2pgsql -v
  8. Create the mam database in PostgreSQL.

    [root]# su - postgres
    [postgres]$ psql
    postgres=# create database "mam";
    postgres=# create user mam with password 'changeme!';
    postgres=# \q
    [postgres]$ exit
  9. Import the converted data into the PostgreSQL database.

    [root]# su - mam
    [mam]$ psql mam < /archive/mam.pgsql
  10. Point MAM to use the new postgresql database.

    [mam]$ cd /software/mam-latest
    [mam]$ ./configure                  # This will generate an etc/mam-server.conf.dist file
    [mam]$ vi /opt/mam/etc/mam-server.conf   # Merge in the database.datasource from etc/mam-server.conf.dist
  11. Restart Moab Accounting Manager.

    [mam]$ mam-server -r

© 2016 Adaptive Computing