ora2pg 从Oracle迁移到opengauss

发布于:2024-05-10 ⋅ 阅读:(28) ⋅ 点赞:(0)

ora2og初始代码源自ora2pg,版本为release v21.1:https://github.com/darold/ora2pg/tree/v21.1
Ora2Pg优秀特性
1、支持导出数据库绝大多数对象类型,包括表、视图、序列、索引、外键、约束、函数、存储过程等。
2、提供PL/SQL到PL/PGSQL语法的自动转换,一定程度避免了人工修正。
3、可生成迁移报告,包括迁移难度评估、人天估算。
4、可选对导出数据进行压缩,节约磁盘开销。
5、配置选项丰富,可自定义迁移行为。

openGauss-tools-ora2og-master下载地址:
https://gitee.com/opengauss/openGauss-tools-ora2og#https://gitee.com/link?target=https%3A%2F%2Fgithub.com%2Fdarold%2Fora2pg%2Ftree%2Fv21.1%25E3%2580%2582

安装DBI

#root用户下操作
yum install -y perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
yum install perl-CPAN
yum -y install perl-DBI

安装 DBD-ORACLE

下载https://cpan.metacpan.org/authors/id/Z/ZA/ZARQUON/DBD-Oracle-1.90.tar.gz

tar -xvf DBD-Oracle-1.90.tar.gz
编译:
cd DBD-Oracle-1.90
perl Makefile.PL
make
make install

安装oracle-instantclient

-rwxr-xr-x   1 root root   53948820 May  8 17:30 oracle-instantclient19.23-basic-19.23.0.0.0-1.x86_64.rpm
-rwxr-xr-x   1 root root     614824 May  8 17:30 oracle-instantclient19.23-devel-19.23.0.0.0-1.x86_64.rpm
-rwxr-xr-x   1 root root    1525412 May  8 17:30 oracle-instantclient19.23-jdbc-19.23.0.0.0-1.x86_64.rpm
-rwxr-xr-x   1 root root     704164 May  8 17:30 oracle-instantclient19.23-sqlplus-19.23.0.0.0-1.x86_64.rpm

yum -y install oracle-instantclient19*

设置环境

export ORACLE_HOME=/usr/lib/oracle/19.23/client64
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH

openGauss-tools-ora2og-master.zip 安装

perl Makefile.PL PREFIX=<your_install_dir>
make && make install
# 设置环境变量,查看是否安装成功
export PERL5LIB=<source_code_dir>/lib
export PATH=$PATH:<your_install_dir>/usr/local/bin
ora2pg --help

[root@opengauss01 oramig]# ora2pg --help

Usage: ora2pg [-dhpqv --estimate_cost --dump_as_html] [--option value]

    -a | --allow str  : Comma separated list of objects to allow from export.
			Can be used with SHOW_COLUMN too.
    -b | --basedir dir: Set the default output directory, where files
			resulting from exports will be stored.
    -c | --conf file  : Set an alternate configuration file other

创建迁移项目

ora2pg --init_project oramig

./oramig
├── config
│   ├── ora2pg.conf
│   └── ora2pg.conf.bak
├── data
├── export_schema.sh
├── import_all.sh
├── reports
│   ├── columns.txt
│   ├── report.html
│   └── tables.txt
├── schema
│   ├── dblinks
│   ├── directories
│   ├── functions
│   ├── grants
│   ├── mviews
│   ├── packages
│   ├── partitions
│   ├── procedures
│   ├── sequences
│   ├── synonyms
│   ├── tables
│   ├── tablespaces
│   ├── triggers
│   ├── types
│   └── views
└── sources
    ├── functions
    ├── mviews
    ├── packages
    ├── partitions
    ├── procedures
    ├── triggers
    ├── types
    └── views

生成oramig目录创建迁移项目模板,包含导出脚本export_schema.sh、导入脚本import_all.sh、schema目录存放转化后对象ddl语句脚本、sources目录存储转化之前的PL/SQL语句脚本、data目录存放表数据、config目录存放配置文件ora2pg.conf、report存放迁移报告。


网站公告

今日签到

点亮在社区的每一天
去签到