Oracle迁移至PostgreSQL工具之Ora2Pg
生活随笔
收集整理的這篇文章主要介紹了
Oracle迁移至PostgreSQL工具之Ora2Pg
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1. 描述
Ora2Pg是一個免費的工具,用于將Oracle數據庫遷移到PostgreSQL兼容的模式。它連接您的Oracle數據庫,自動掃描并提取它的結構或數據,然后生成可以裝載到PostgreSQL數據庫的SQL腳本。Ora2Pg可以從逆向工程Oracle數據庫到大型企業數據庫遷移,或者簡單地將一些Oracle數據復制到PostgreSQL數據庫中。它非常容易使用,并且不需要任何Oracle數據庫知識,而不需要提供連接到Oracle數據庫所需的參數。
2.?安裝
2.1. 依賴環境要求
- perl版本5.10以上
- 安裝DBI
下載地址:https://metacpan.org/release/DBI
# tar -zxvf DBI-1.641.tar.gz # cd DBI-1.641 # perl Makefile.PL # make # make install- 安裝Oracle客戶端
安裝Oracle的客戶端軟件;步驟略
- 安裝DBD-Oracle
下載地址:http://search.cpan.org/~pythian/DBD-Oracle-1.74/lib/DBD/Oracle.pm
# tar -zxvf DBD-Oracle-1.74.tar.gz加載環境變量;因為必須定義ORACLE_HOME環境變量;本例在postgres用戶下配置環境變量 # source /home/postgres/.bashrc # cd DBD-Oracle-1.74 # perl Makefile.PL # make # make install- 安裝DBD::Pg[可選]
下載地址:http://search.cpan.org/~turnstep/DBD-Pg/
# tar -zxvf DBD-Pg-1.32.tar.gz # source /home/postgres/.bashrc # cd DBD-Pg-1.32 # perl Makefile.PL # make # make install2.2?安裝Ora2Pg
下載地址 :https://sourceforge.net/projects/ora2pg/
[root@Postgres201 ~]# tar -zxvf ora2pg-18.2.tar.gz ora2pg-18.2/ ora2pg-18.2/INSTALL ora2pg-18.2/LICENSE ora2pg-18.2/MANIFEST ora2pg-18.2/Makefile.PL ora2pg-18.2/README ora2pg-18.2/changelog ora2pg-18.2/doc/ ora2pg-18.2/doc/Ora2Pg.pod ora2pg-18.2/doc/ora2pg.3 ora2pg-18.2/lib/ ora2pg-18.2/lib/Ora2Pg.pm ora2pg-18.2/lib/Ora2Pg/ ora2pg-18.2/lib/Ora2Pg/GEOM.pm ora2pg-18.2/lib/Ora2Pg/MySQL.pm ora2pg-18.2/lib/Ora2Pg/PLSQL.pm ora2pg-18.2/packaging/ ora2pg-18.2/packaging/README ora2pg-18.2/packaging/RPM/ ora2pg-18.2/packaging/RPM/ora2pg.spec ora2pg-18.2/packaging/debian/ ora2pg-18.2/packaging/debian/create-deb-tree.sh ora2pg-18.2/packaging/debian/ora2pg/ ora2pg-18.2/packaging/debian/ora2pg/DEBIAN/ ora2pg-18.2/packaging/debian/ora2pg/DEBIAN/control ora2pg-18.2/packaging/debian/ora2pg/DEBIAN/copyright ora2pg-18.2/packaging/slackbuild/ ora2pg-18.2/packaging/slackbuild/Ora2Pg.SlackBuild ora2pg-18.2/packaging/slackbuild/Ora2Pg.info ora2pg-18.2/packaging/slackbuild/README ora2pg-18.2/packaging/slackbuild/doinst.sh ora2pg-18.2/packaging/slackbuild/slack-desc ora2pg-18.2/scripts/ ora2pg-18.2/scripts/ora2pg ora2pg-18.2/scripts/ora2pg_scanner [root@Postgres201 ~]# cd ora2pg-18.2 [root@Postgres201 ora2pg-18.2]# perl Makefile.PL Checking if your kit is complete... Looks good Writing Makefile for Ora2PgDone... ------------------------------------------------------------------------------ Please read documentation at http://ora2pg.darold.net/ before asking for help ------------------------------------------------------------------------------ Now type: make && make install [root@Postgres201 ora2pg-18.2]# make && make install cp lib/Ora2Pg.pm blib/lib/Ora2Pg.pm cp lib/Ora2Pg/GEOM.pm blib/lib/Ora2Pg/GEOM.pm cp lib/Ora2Pg/PLSQL.pm blib/lib/Ora2Pg/PLSQL.pm cp lib/Ora2Pg/MySQL.pm blib/lib/Ora2Pg/MySQL.pm cp scripts/ora2pg blib/script/ora2pg /usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/ora2pg cp scripts/ora2pg_scanner blib/script/ora2pg_scanner /usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/ora2pg_scanner Manifying blib/man3/ora2pg.3 Installing /usr/local/share/perl5/Ora2Pg.pm Installing /usr/local/share/perl5/Ora2Pg/MySQL.pm Installing /usr/local/share/perl5/Ora2Pg/GEOM.pm Installing /usr/local/share/perl5/Ora2Pg/PLSQL.pm Installing /usr/local/share/man/man3/ora2pg.3 Installing /usr/local/bin/ora2pg Installing /usr/local/bin/ora2pg_scanner Installing default configuration file (ora2pg.conf.dist) to /etc/ora2pg Appending installation info to /usr/lib64/perl5/perllocal.pod2.3?檢查所有軟件是否安裝成功
[root@Postgres201 ~]# vi check.pl #!/usr/bin/perl use strict; use ExtUtils::Installed; my $inst= ExtUtils::Installed->new(); my @modules = $inst->modules(); foreach(@modules) {my $ver = $inst->version($_) || "???";printf("%-12s -- %s\n", $_, $ver); } exit; [root@Postgres201 ~]# perl check.pl DBD::Oracle -- 1.74 DBD::Pg -- 1.32 DBI -- 1.641 Ora2Pg -- 18.2 Perl -- 5.10.13. 小試牛刀
3.1 配置配置文件
- 導出表結構
- 導出數據
3.2 導出數據
[postgres@Postgres201 config]$ ora2pg -c ora2pg_table.conf [========================>] 2/2 tables (100.0%) end of scanning. [========================>] 2/2 tables (100.0%) end of table export.[postgres@Postgres201 config]$ ora2pg -c ora2pg_data.conf [========================>] 2/2 tables (100.0%) end of scanning. [========================>] 4/1 rows (400.0%) Table DEPT (4 recs/sec) [===================> ] 4/5 total rows (80.0%) - (0 sec., avg: 4 recs/sec). [========================>] 4/4 rows (100.0%) Table ORATAB (4 recs/sec) [========================>] 8/5 total rows (160.0%) - (0 sec., avg: 8 recs/sec). [========================>] 5/5 rows (100.0%) on total estimated data (1 sec., avg: 5 recs/sec)3.3 導入PostgreSQL數據庫中
[postgres@Postgres201 config]$ psql lottu lottu -f table.sql SET SET CREATE TABLE ALTER TABLE CREATE TABLE [postgres@Postgres201 config]$ psql lottu lottu -f data.sql SET SET BEGIN COPY 4 COPY 4 COMMIT?
FAQ:導出出現"Can't locate Time/HiRes.pm in"錯誤?
[root@Postgres201 ora2pg]# ora2pg -c ora2pg.conf Can't locate Time/HiRes.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/share/perl5/Ora2Pg.pm line 33. BEGIN failed--compilation aborted at /usr/local/share/perl5/Ora2Pg.pm line 33. Compilation failed in require at /usr/local/bin/ora2pg line 30. BEGIN failed--compilation aborted at /usr/local/bin/ora2pg line 30. [root@Postgres201 ora2pg]# yum install -y perl-Time-HiRes解決方案:
[root@Postgres201 ora2pg]# yum install -y perl-Time-HiRes?
更多詳細查考http://ora2pg.darold.net/documentation.html#installation
總結
以上是生活随笔為你收集整理的Oracle迁移至PostgreSQL工具之Ora2Pg的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: kali 解决Metasploit拿到s
- 下一篇: 专访赵加雨:WebRTC在网易云信的落地