Migrate Data from Sybase to MySQL 6.14.0
Created: 6.10.1; Updated: 6.14.0

This document describes the switch of the database for an ePages installation from Sybase to MySQL.

Chapter Local Single Machine Installation describes the process for a standard installation on a single machine.

Chapter Distributed Installation describes the process for a distributed installation with a separate database machine.

Chapter Case Study: Migration of a Distributed Installation (Windows) shows a case study installing the MySQL database on a new machine for an existing distributed installation.

Table of Contents

1 Local Single Machine Installation

1.1 Prerequisites

In Windows execute the following steps as Windows user 'Administrator' or as a user with administrator permissions.

In UNIX execute the following steps as UNIX user 'root'.

1.2 Backup of Database and Config Files (%EPAGES_CONFIG%)

Perform a backup of the database and save the config files, basically Backup.conf, Site.conf, Store.conf, and maybe other [storedb_name].conf.

1.3 Install MySQL 5.1

Windows:

Make sure the MySQL 5.1 database is installed using the following options:

UNIX:

  mysqladmin -u root password epages

  [mysqld]
  ...
  #
  # Set logging to binary format
  #
  log_bin     = mysql-bin.log
  log_bin_index     = mysql-bin.log.index
  relay-log         = mysqld-relay-bin
  relay-log_index   = mysqld-relay-bin.index
  # binlog-format   = mixed # set binlog format to mixed mode (both statement and row based) (v5.1 or higher!)
  ...

The binary logging is necessary to perform incremental backups.

Redhat/CentOS:

  /etc/init.d/mysqld stop
  /etc/init.d/mysqld start

SuSE:

  /etc/init.d/mysql stop
  /etc/init.d/mysql start

1.4 Prepare Config Files

Copy the config files Backup.conf, Site.conf, and [Storedb].conf to [name]_syb.conf.

Check all database relevant parameters in the original named config files. Replace the Sybase values settings by MySQL values. Check especially the parameter "datasource".

1.4.1 Example for Site.conf

  [Connection]
  datasource=dbi:Sybase:charset=utf8;server=DBServer
  login=usr_sitedb
  passwd=epages
  active=1
  Database=sitedb
  StoreType=Site
  Backup=Backup
  BackupHost=localhost
  DumpDir=_SYBASE_/dumps
  FinalBackupType=-full
  InitialBackupType=-full

  [Connection]
  datasource=dbi:mysql
  login=usr_sitedb
  passwd=epages
  active=1
  Database=sitedb
  StoreType=Site
  Backup=Backup
  BackupHost=localhost
  FinalBackupType=-full
  InitialBackupType=-full

1.4.2 Example for Store.conf

  [Connection]
  datasource=dbi:Sybase(LongReadLen=200000):charset=utf8;server=DBServer
  login=usr_storedb
  passwd=epages
  active=1
  Database=storedb
  StoreType=Store
  Backup=Backup
  BackupHost=localhost
  DumpDir=_SYBASE_/dumps
  FinalBackupType=-full
  InitialBackupType=-full

  [Connection]
  datasource=dbi:mysql
  login=usr_storedb
  passwd=epages
  active=1
  Database=storedb
  StoreType=Store
  Backup=Backup
  BackupHost=localhost
  FinalBackupType=-full
  InitialBackupType=-full

1.4.3 Example for Backup.conf

  [Connection]
  datasource=dbi:Sybase:charset=utf8;server=DBServer
  login=sa
  passwd=epages
  active=1
  Database=master

  [Connection]
  active=1
  datasource=dbi:mysql
  login=root
  passwd=epages
  Database=mysql

Notes:

  datasource=dbi:mysql:mysql_socket=/var/lib/mysql/mysql.sock

1.5 Install the New Databases

Make sure the config files were changed correctly. Sybase entries mustn't exist in the config files.

Windows:

1. Run once for the installation:

  cd %EPAGES_CARTRIDGES%\DE_EPAGES
  perl Makefile.PL
  nmake create_db install_store STORE=Site

2. Run for each STORE database:

  nmake new_store STORE=[storedb_name]

UNIX:

1. Run once for the installation:

  . /etc/default/epages6
  cd $EPAGES_CARTRIDGES/DE_EPAGES
  $PERL Makefile.PL
  make create_db install_store STORE=Site

2. Run for each STORE database:

    make new_store STORE=[storedb_name]

Run the installation also for all other cartridges not located in

  Windows:  %EPAGES_CARTRIDGES%\DE_EPAGES.
  UNIX:     $EPAGES_CARTRIDGES/DE_EPAGES.

1.6 Copy Tables

Run the script copyAllTables.pl:

 Windows:

   perl %EPAGES_CARTRIDGES%\DE_EPAGES\Database\Scripts\copyAllTables.pl
  -source [store_config_name]_syb -target [store_config_name]

 UNIX:

   $PERL $EPAGES_CARTRIDGES/DE_EPAGES/Database/Scripts/copyAllTables.pl
   -source [store_config_name]_syb -target [store_config_name]

Run the script just for the Site database and all Store databases. Do not run the script using "Backup"!

1.7 Last Steps

  Windows:
  perl %EPAGES_CARTRIDGES%\DE_EPAGES\Object\Scripts\refreshPoolDB.pl -storename Site
  perl %EPAGES_CARTRIDGES%\DE_EPAGES\Object\Scripts\refreshPoolDB.pl -storename Store

  UNIX:
  $PERL $EPAGES_CARTRIDGES/DE_EPAGES/Object/Scripts/refreshPoolDB.pl -storename Site
  $PERL $EPAGES_CARTRIDGES/DE_EPAGES/Object/Scripts/refreshPoolDB.pl -storename Store

  Windows: %EPAGES_CONFIG%\Scheduler.conf
  UNIX: $EPAGES_CONFIG/Scheduler.conf

  Set IsActive=0 in the relevant sections.

  Windows:  %EPAGES_STATIC%
  UNIX:     $EPAGES_STATIC

  /etc/init.d/epages6 stop
  /etc/init.d/mysqld stop
  mv $SYBASE/ASE-15_0 $SYBASE/ASE-15_0.old
  cp -p $EPAGES_CONFIG/License.xml $EPAGES_CONFIG/License.xml.org
  rpm -hiv http://www.epages.com/RPMS/6.11/i386/epages-mysql-6.11.0-0.i386.rpm
  rpm -hiv http://www.epages.com/RPMS/6.11/i386/epages-mysqld-6.11.0-0.i386.rpm
  cp -p $EPAGES_CONFIG/License.xml.org $EPAGES_CONFIG/License.xml
  /etc/init.d/epages6 start

2 Distributed Installation

Proceed the steps as defined in chapter Local Single Machine Installation.

Addition to step Install MySQL 5.1:
You have to grant the remote user of the MySQL installation the rights to create and set up the database. For this open the MySQL console (Start >> MySQL Command Line Client) and perform the following command after entering the password:
  GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

Addition to step Prepare Config Files:
You have to add host name and port to the datasource paramater:
Example Windows:

  datasource=dbi:mysql:host=[db_server_name];3306

Example UNIX:

  datasource=dbi:mysql:host=[db_server_name];port=3306

3 Case Study: Migration of a Distributed Installation (Windows)

3.1 Starting Point

  1. Distributed installation of ePages patch 6.09.x on two machines
  2. Standard installation, one Site one Store, no additional or customized cartridges
  3. All language pack installed
M1: host name = vm1
Application server machine
M2: host name = vm2
Sybase Database and Shared files

3.2 Objective

Transfer database content from Sybase database to a MySQL database on a new machine M3.

M1: host name = vm1
Application server machine
M2: host name = vm2
Shared files
M3: host name = vm3
MySQL database

3.3 Steps

1. Install patch 6.10.0 on M1 with all LP

2. Test if patch ok

3. Install MySQL DB on M3

Important - Enable remote user access!
See chapter "Custom Installation" in ePages Installation Guide for Windows
Short list: Run in MySQL:

  GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

Check if connection to database works: telnet vm3 3306
4. Change the config files on M2 as described in step Prepare Config Files (see above)

5. Run install cartridges on M1 as described in step Install the New Databases (see above)

  cd %EPAGES_CARTRIDGES%\DE_EPAGES
  perl Makefile.PL
  nmake create_db install_store STORE=Site
  nmake new_store STORE=Store

6. Copy all tables on M1 as described in step Copy Tables (see above)

  perl copyAllTables.pl -source Site_syb -target Site
  perl copyAllTables.pl -source Store_syb -target Store

7. Delete the directory %EPAGES_STATIC% on M2

8. Restart the epages service and the request router service on M1

9. Disable all Sybase related entries on M2 in %EPAGES_CONFIG%\Scheduler.conf. Set IsActive=0 in the relevant section.


Copyright ePages Software GmbH 2012