ITPub博客

首页 > 数据库 > PostgreSQL > Ora2Pg

Ora2Pg

原创 PostgreSQL 作者:wanghao2979 时间:2020-10-07 14:01:50 0 删除 编辑

测试操作系统: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











来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7569309/viewspace-2725567/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: oracle_fdw
请登录后发表评论 登录
全部评论
主要负责客户现场exadata与exalogic设备的维护工作, 擅长于ORACLE数据库环境/高可用环境的搭建及故障诊断, 并且也获有 11g ocp 证书,10g ocm 证书

注册时间:2017-01-10

  • 博文量
    90
  • 访问量
    84716