tar -zxf DBD-Oracle-1.80.tar.gz
perl Makefile.PL -l
make
make install
3.4安装Ora2PG
tar -zxf ora2pg-22.1\ \(1\).tar.gz
cd ora2pg-22.1/
perl Makefile.PL
make && make install
4.迁移流程
4.1编辑配置文件
vi ora2pg.conf
ORACLE_HOME /u01/app/oracle/product/11.2.0/db_1
#If you use SID
ORACLE_DSN dbi:Oracle:host=test2;sid=ora11g;port=1521
#If you use service name
ORACLE_DSN dbi:Oracle://localhost:1521/ora11g
ORACLE_USER test2
ORACLE_PWD oracle
TYPE TABLE VIEW GRANT COPY
OUTPUT output.sql
PG_VERSION 14
# Oracle schema/owner to use
SCHEMA test2
PG_SCHEMA test2
# Export Oracle schema to PostgreSQL schema
EXPORT_SCHEMA 1
4.2执行Oracle数据导出
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/db_1/lib:$LD_LIBRARY_PATH
[root@test2 ora2pg]# ora2pg -c ora2pg.conf
[========================>] 4/4 tables (100.0%) end of scanning.
Retrieving table partitioning information...
[> ] 0/4 tables (0.0%) end of scanning.
[========================>] 4/4 tables (100.0%) end of table export.
[========================>] 0/0 views (100.0%) end of output.
[========================>] 1/1 rows (100.0%) Table T1 (1 recs/sec)
[======> ] 1/4 total rows (25.0%) - (0 sec., avg: 1 recs/sec).
[========================>] 172702/1 rows (17270200.0%) Table T1_TMP (10793 recs/sec)
[========================>] 172703/4 total rows (4317575.0%) - (16 sec., avg: 10793 recs/sec).
[========================>] 86358/1 rows (8635800.0%) Table T2 (10794 recs/sec)
[========================>] 259061/4 total rows (6476525.0%) - (24 sec., avg: 10794 recs/sec).
[========================>] 86361/1 rows (8636100.0%) Table T3 (10795 recs/sec)
[========================>] 345422/4 total rows (8635550.0%) - (32 sec., avg: 10794 recs/sec).
[========================>] 4/4 rows (100.0%) on total estimated data (32 sec., avg: 0 recs/sec)
Fixing function calls in output files...
4.3复制导出文件到目标端
[root@test2 ora2pg]# ls -l
total 43356
-rw-r--r-- 1 root root 44378989 Feb 23 22:54 COPY_output.sql
-rw-r--r-- 1 root root 341 Feb 23 22:53 GRANT_output.sql
-rw-r--r-- 1 777 root 448 Feb 23 22:05 ora2pg.conf
-rw-r--r-- 1 root root 1557 Feb 23 22:53 TABLE_output.sql
-rw-r--r-- 1 root root 338 Feb 23 22:53 VIEW_output.sql
[root@node1 conf]# cp ./*.sql /home/pg14/import/
[root@node1 conf]# chown pg14:pg14 /home/pg14/import/*.sql
4.4目标端创建库和用户
psql
create database test2;
exit
psql -Upostgres -d test2
create user test2 with password '123';