PostgreSQL Migration Using Ora2pg
Oracle to PostgreSQL Migration – ORA2PG
Ora2Pg is a free tool used to migrate an Oracle database to a PostgreSQL compatible schema. It connects to the Oracle database, scans it automatically, extracts its structure or data and then generates SQL scripts that you can load into your PostgreSQL database.The cost estimation in an Oracle to PostgreSQL migration is not easy.Ora2Pg inspects all database objects, all functions and stored procedures to detect if there’s still some objects and PL/SQL code that cannot be automatically converted by Ora2Pg.
This tool is very helpful for the following conversions:
- Schema conversion
- PLSQL to PLPGSQL conversion
TOOLS:
Software Tools
- DBA-ORACLE //Oracle machine
- DBD-PG //PostgreSQL machine
- DBI-1 //PostgreSQL machine
- ORA2PG //PostgreSQL machine
INSTALLATION STEPS:
STEPS 1: (oracle machine)
go to https://metacpan.org/pod/DBD::Oracle and download DBA-ORACLE
tar -xvzf DBD-Oracle-1.75_2.tar.gz //Extract to DBA-ORACLE
Open DBA-ORACLE directory
Export oracle base path,home path and library path
[root@server1 DBD-Oracle-1.75_2]# ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
[root@server1 DBD-Oracle-1.75_2]# ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db_1; export ORACLE_HOME
[root@server1 DBD-Oracle-1.75_2]# LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
And next type the content on terminal
Oracle=#perl MakeFile.PL
Oracle=# make
Oracle=# make instal
STEPS 2: (postgresql machine)
goto https://metacpan.org/pod/DBD::Pg and download DBD-PG
tar -xvzf DBD-Pg-3.6.0.tar.gz //Extract to DBD-PG
Open dbd-pg directory
And type terminal:
Postgres=# perl MakeFile.PL
Postgres=# make
Postgres=#make install
STEPS 3: (postgresql machine)
goto https://metacpan.org/pod/DBI //download DBI-1
tar -xvf DBI-1.641.tar.gz //Extract to DBI-1
Open DBI-1 directory
And type terminal:
Postgres=# perl MakeFile.PL
Postgres=# make
Postgres=#make install
STEPS 4: (postgresql machine)
goto https://github.com/darold/ora2pg/releases and download or2pg latest version
tar -xvf ora2pg-19.1.tar.bz2 //Extract to ORA2PG
Open ora2pg directory
And type terminal:
Postgres=# perl MakeFile.PL
Postgres=# make
Postgres=#make instal
STEP 5: star Listener for oracle machine
su - oracle
Export ORACLE_SID=pearl
Sysdba / as sysdba
Startup
Conn muthu/siva
exit
===============================================
check oracle listener status
Lsnrctl status ----(and) cannot work
Netmgr (create listener and type db details)
lsnrctl not work create .ora files
home/network/admin
vi listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = REGISTER))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.201)(PORT = 1521))
)
)
vi tnsnames.ora
pearl =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.201)(PORT = 1521)))
(CONNECT_DATA =
(SERVICE_NAME = pearl)
)
)
SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.201)(PORT=1521)))' scope = spfile;
System altered.
SQL> alter system register;
System altered.
========================================================================
[oracle@server1 ~]$ lsnrctl start
[oracle@server1 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-JUL-2020 08:47:55
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=REGISTER)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 28-JUL-2020 08:46:09
Uptime 0 days 0 hr. 1 min. 46 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0.4/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/server1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=REGISTER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.201)(PORT=1521)))
Services Summary...
Service "pearl" has 1 instance(s).
Instance "pearl", status READY, has 1 handler(s) for this service...
Service "pearlXDB" has 1 instance(s).
Instance "pearl", status READY, has 1 handler(s) for this service...
The command completed successfully
========================================================================
STEP 6: (postgresql machine)
Goto ora2pg configuration file (/etc/ora2pg)
vi ora2pg.conf
ORACLE_HOME /u01/app/oracle/product/11.2.0.4/db_1
ORACLE_DSN dbi:Oracle:host=192.168.1.201;sid=pearl;port=1521
ORACLE_USER system
ORACLE_PWD manager
SCHEMA MMS
TYPE TABLE PACKAGE INSERT COPY VIEW GRANT SEQUENCE TRIGGER FUNCTION PROCEDURE
OUTPUT muthusiva_ora2pg_migrate.sql
OUTPUT_DIR /home/oracle
--save and exit conf file--
• Next open /usr/local/bin and run ./ora2pg file next automatically created migration.sql
• Next open postgresqlAnd import migration.sql
Postgresql=#\i /home/pearl/Documents/migrate.sql
Comments
Post a Comment