ora2pg --init\_project oramig
创建迁移项目后会在当前目录下生成oramig目录模板,如下所示。其中主要包含两个脚本export_schema.sh和import_all.sh,后续导出和导入即使用这两个脚本。schema和sources目录存放各对象的DDL语句,区别在于schema存放PL/SQL语法转化为PL/PGSQL后的语句, sources目录存放转化前PL/SQL的语句,data目录存放表数据文件,config目录包含配置文件ora2pg.conf,reports目录存放迁移报告。
建用户和表
Oracle建个表,用来做测试数据
create table customerchat.test(name char(10));
insert into customerchat.test values('opengauss');
create table customerchat.xxx(name char(20));
insert into customerchat.xxx values('yy');
openGauss侧新建数据库mydb和用户tuser ,迁移时会用到。
mydb=#create database mydb;
mydb=# CREATE USER tuser WITH PASSWORD '自己定义';
mydb=# GRANT ALL PRIVILEGES TO tuser;
mydb=# alter database mydb owner to tuser;
配置ora2pg.conf
拷贝配置文件,注意路径,后面执行sh的时候会找config/ora2pg.conf。
cp <your_install_dir>/etc/ora2pg/ora2pg.conf.dist <source_code_dir>/config/ora2pg.conf
ORACLE相关参数:
ORACLE_HOME /u01/app/oracle/product/11.2.0/
ORACLE_DSN dbi:Oracle:host=oracleIP;sid=orcl;port=1521
ORACLE_USER customerchat // 这里用的oracle普通用户和密码
ORACLE_PWD XXXXX
SCHEMA customerchat //一般和用户名一样
openGauss相关参数:
PG_DSN dbi:Pg:dbname=mydb;host=localhost;port=5432
PG_USER tuser
PG_PWD 自己定义的密码
工具自身参数:
DATA_LIMIT 默认是10000,如果oracle服务器内存较小,比如4G以下,可以修改为2500或5000,否则可能会报内存不足。
更多更详细的配置项说明,可查看ora2pg.darold.net官网.
测试