Unfortunately, the process detailed does not work for me. The PG Dump works fine and provides a large file of data. It runs in the blink of an eye.
The conversion fails.
Code: Select all
php pg2mysql_cli.php nagiosxi.psql nagiosxi.mysql myisam
Filesize: 38.5M
PHP Notice: Undefined offset: 24 in /usr/local/src/Testing/PG-2-MySQL/pg2mysql-master/pg2mysql.inc.php on line 336
Reading progress: 70% position: 27.0M line: 90000 sql chunk: 17 mem usage: 43M
Completed! 99389 lines 17 sql chunks
Notes:
- No its not perfect
- Yes it discards ALL stored procedures
- Yes it discards ALL queries except for CREATE TABLE and INSERT INTO
- Yes you can email us suggestsions: info[AT]lightbox.org
- In emails, please include the Postgres code, and the expected MySQL code
- If you're having problems creating your postgres dump, make sure you use "--format p --inserts"
- Default output engine if not specified is MyISAM
(Linux 2.6.32-642.6.2.el6.x86_64)nagios@crulnxicore01:/usr/local/src/Testing/PG-2-MySQL/pg2mysql-master
!> ll
total 39432
drwxr-xr-x 2 nagios users 4096 Dec 7 11:45 .
drwxr-xr-x 3 nagios users 4096 Dec 7 11:44 ..
-rw-r--r-- 1 nagios users 15145 Feb 21 2015 gpl.txt
-rw-r--r-- 1 nagios users 2751 Dec 7 11:45 nagiosxi.mysql
-rw-r--r-- 1 nagios users 40318590 Dec 7 11:44 nagiosxi.psql
-rw-r--r-- 1 nagios users 1534 Feb 21 2015 pg2mysql_cli.php
-rw-r--r-- 1 nagios users 13189 Feb 21 2015 pg2mysql.inc.php
-rw-r--r-- 1 nagios users 2370 Feb 21 2015 pg2mysql.php
-rw-r--r-- 1 nagios users 2985 Feb 21 2015 README
The result is a very small file that barely starts to setup the table data, and has no actual content.
That is fine with me though. Once I understood that it is a simple move of data from location A to location B and no other changes of any importance, I took a slightly different path. The basics are the same. The MySQL Workbench takes it in small steps, lets you verify and make changes if needed. just keep clicking 'next' until it is completed. I felt very comfortable with the results. I would prefer linux command line stuff, but I had no success there.
These are the steps I took - with great success. I use MySQL Workbench all the time anyway, so adding an ODBC connector was simple.
My notes follow: Test Test Test... always
1. Set PostgreSQL to allow remote connections
This is specifically to allow access for the system that will run the convert process
On the system running PostgreSQL
sudo vi /var/lib/pgsql/data/pg_hba.conf
Add the line
host all all [your IP here]/23 trust
sudo vi /var/lib/pgsql/data/postgresql.conf
Find configuration line that read as follows:
listen_addresses='localhost'
Change it to
listen_addresses='*'
Then restart PostgreSQL
As the nagios user, run
sudo /usr/local/nagiosxi/scripts/manage_services.sh restart postgresql
Or as root pick one...
/etc/init.d/postgresql restart
service postgresql restart
systemctl restart postgresql
2. Install PostgreSQL ODBC Driver on your workstation
Set it up in the ODBC Control Panel and add the host, user, pass, port, etc.
Make sure it tests okay.
Acquire the driver from here - Note newest versions are at the bottom.
http://www.postgresql.org/ftp/odbc/versions/msi/
“First you download ODBC driver, then you installed it. After that go to START->Program->Administrative tools then you select Data Source ODBC then you double click on the same after that you select PostgreSQL 30 then you select configure then you provide proper details such as db name user Id host name password of the same database in this way you will configure your DSN connection.
Then you go on next tab system DSN then you select ADD tab then select postgreSQL_ANSI_64X ODBC after you that you have created PostgreSQL ODBC connection.” or something like that… Use your own judgement.
Use these resources as a guide to setup the driver
https://odbc.postgresql.org/
http://stackoverflow.com/questions/6796 ... on-windows
Once the ODBC driver tests says Okay, proceed.
If not okay, back to step 1 and verify your work, do not forget the PG restart.
3. Use MySQL Workbench Data Migration tool
http://dba.stackexchange.com/questions/ ... l-to-mysql
“Use MySQL Workbench
The following steps are based on MySQL Workbench 6.1
Source & Target
Open MySQL Workbench and start the Migration Wizard Database > Migration Wizard... Set up connection to your source database (PostgreSQL) Setup connection to your target database (MySQL) Select the schemas to migrate
Object Migration
Select the source objects to migrate Review and manual editing proposed migration Target creation options Create schemas Create target results
Data Migration
Data transfer setup Bulk data transfer” - or however it works for you.
4. If this process worked for you then do it for real.
Stop Nagios, database, ndo2db, etc.
Run step 3 again to transfer the data to the real system / Database.
Tell Nagios to use MySQL now
sed -i 's/pgsql/mysql/' /usr/local/nagiosxi/html/config.inc.php
Start Nagios, database, ndo2db, etc.
I was going to post this eventually, but I felt that it should be put out there now as I did try your process without success. In case other folks get your method to work, that is great. If not, then they have an additional method to try. But I understand the methodology now and to me that makes all the difference.
Thanks
Steve B