oracle數據庫是一種關係型數據庫管理系統,在數據庫領域一直處於領先的地位,適合於大型項目的開發;銀行、電信、電商、金融等各領域都大量使用Oracle數據庫。git
greenplum是一款開源的分佈式數據庫存儲解決方案,主要關注數據倉庫和BI報表及多維查詢等方面。採用了shared-nothing的大規模並行處理MPP架構。github
目前我手頭的工做是須要將oracle數據庫遷移到greenplum庫中,大概收集了一下資料。sql
由於greenplum數據庫是基於postgresql的,因此能夠使用oracle遷移到postgresql的方式來作。數據庫
先看一下官網:安全
https://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL架構
官網上列舉了全部oracle遷移到pg的可用工具。帶鎖的是收費的,不帶鎖的是開源的oracle
本次採用的是ora2pg的工具來作。app
安裝這邊就不提了,能夠參照git官網的說明來安裝 https://github.com/darold/ora2pg分佈式
咱們的目的是要將oracle的表的表結構轉換成pg的建表語句。數據的抽取咱們須要另外想辦法。工具
這個ora2pg工具主要是用配置文件來控制須要轉換的東西。能夠單獨轉換表結構,能夠導出數據。也能夠導出視圖、索引、包結構等。
主要的配置文件內容以下:
#---------------------------------# #---------------------------------# # Set the Oracle home directory ORACLE_HOME /usr/lib/oracle/18.3/client64 # Set Oracle database connection (data source, user, password) ORACLE_DSN dbi:Oracle:host=192.168.***.***;sid=xe;port=**** ORACLE_USER *** ORACLE_PWD **** # Oracle schema/owner to use #SCHEMA SCHEMA_NAME SCHEMA TIANYA SYSTEM #-------------------------- # EXPORT SECTION (Export type and filters) #-------------------------- # Type of export. Values can be the following keyword: # TABLE Export tables, constraints, indexes, … # PACKAGE Export packages # INSERT Export data from table as INSERT statement # COPY Export data from table as COPY statement # VIEW Export views # GRANT Export grants # SEQUENCE Export sequences # TRIGGER Export triggers # FUNCTION Export functions # PROCEDURE Export procedures # TABLESPACE Export tablespace (PostgreSQL >= 8 only) # TYPE Export user-defined Oracle types # PARTITION Export range or list partition (PostgreSQL >= v8.4) # FDW Export table as foreign data wrapper tables # MVIEW Export materialized view as snapshot refresh view # QUERY Convert Oracle SQL queries from a file. # KETTLE Generate XML ktr template files to be used by Kettle. TYPE TABLE VIEW COPY # By default all output is dump to STDOUT if not send directly to PostgreSQL # database (see above). Give a filename to save export to it. If you want # a Gzip’d compressed file just add the extension .gz to the filename (you # need perl module Compress::Zlib from CPAN). Add extension .bz2 to use Bzip2 # compression. OUTPUT output2.sql # Base directory where all dumped files must be written #OUTPUT_DIR /var/tmp OUTPUT_DIR /application/ora2pg/output
主要就是配置了鏈接oracle的信息,選擇要導出的類型,導出的文件存儲在哪一個目錄下等等
目前的問題是,這寫方案都不是一鍵完成的,裏面須要手工操做。而且沒有測試過這些工具的可靠性,安全性。未必可以用於生產環境