暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Ora2Pg

oracle分享技术 2021-02-06
1410

测试操作系统:Centos 7.6

测试IP     :192.168.112.88

操作系统安装信息:最小化安装



官方网站:

http://ora2pg.darold.net/



Requirement

The Oracle Instant Client or a full Oracle instaaltion must be installed on the system. You can download the RPM from Oracle download center:


    rpm -ivh oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm

    rpm -ivh oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm

    rpm -ivh oracle-instantclient12.2-jdbc-12.2.0.1.0-1.x86_64.rpm

    rpm -ivh oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm

or simply download the corresponding ZIP archives from Oracle download center and install them where you want, for example: opt/oracle/instantclient_12_2/


You also need a modern Perl distribution (perl 5.10 and more). To connect to a database and proceed to his migration you need the DBI Perl module > 1.614. To migrate an Oracle database you need the DBD::Oracle Perl modules to be installed. To migrate a MySQL database you need the DBD::MySQL Perl modules. These modules are used to connect to the database but they are not mandatory if you want to migrate DDL input files.


To install DBD::Oracle and have it working you need to have the Oracle client libraries installed and the ORACLE_HOME environment variable must be defined.


If you plan to export a MySQL database you need to install the Perl module DBD::mysql which requires that the mysql client libraries are installed.


On some Perl distribution you may need to install the Time::HiRes Perl module.




1.准备 oracle instant client 环境

  1.1 解压软件

[root@ora2pg u01]# unzip instantclient-sqlplus-linux.x64-12.2.0.1.0.zip

[root@ora2pg u01]# unzip instantclient-sdk-linux.x64-12.2.0.1.0.zip

[root@ora2pg u01]# unzip instantclient-jdbc-linux.x64-12.2.0.1.0.zip

[root@ora2pg u01]# unzip instantclient-basic-linux.x64-12.2.0.1.0.zip


  1.2 配置环境变量

PATH=$PATH:$HOME/bin:/u01/instantclient_12_2

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/pgsoft/lib:/u01/instantclient_12_2

export PATH



2.准备 DBD::Oracle  ,  DBI   

    安装依赖包

yum install perl-DBI perl-DBD-Pg perl-ExtUtils-MakeMaker gcc




3. 准备ora2pg 环境


下载文件:

ora2pg-20.0.zip


下载后解压执行

perl Makefile.PL

make

make install


4. 配置 etc/ora2pg.conf


 # oracle connect info

ORACLE_DSN dbi:Oracle:host=192.168.112.77;sid=testdb;port=1521

ORACLE_USER SYSTEM

ORACLE_PWD oracle

# oracle schema

SCHEMA MYUSER

# oracle type

TYPE TABLE COPY DATA

OUTPUT table.sql



 psql -U postgres -d postgres -h 127.0.0.1 -p 5432 -f TABLE_table.sql

 psql -U postgres -d postgres -h 127.0.0.1 -p 5432 -f COPY_table.sql

或者

 psql -U postgres -d postgres -h 127.0.0.1 -p 5432 -f INSERT_table.sql


5. 生成迁移模板



[root@ora2pg ora2pg-20.0]# ora2pg --project_base /u01/migration/ --init_project test_project


文章转载自oracle分享技术,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论