oracle數據庫是一種關系型數據庫管理系統,在數據庫領域一直處于領先的地位,適合于大型項目的開發;銀行、電信、電商、金融等各領域都大量使用Oracle數據庫。
greenplum是一款開源的分布式數據庫存儲解決方案,主要關注數據倉庫和BI報表及多維查詢等方面。采用了shared-nothing的大規模并行處理MPP架構。
目前我手頭的工作是需要將oracle數據庫遷移到greenplum庫中,大概收集了一下資料。
因為greenplum數據庫是基于postgresql的,所以可以使用oracle遷移到postgresql的方式來做。
先看一下官網:
https://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL
?
?
官網上列舉了所有oracle遷移到pg的可用工具。帶鎖的是收費的,不帶鎖的是開源的
本次采用的是ora2pg的工具來做。
安裝這邊就不提了,可以參照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的信息,選擇要導出的類型,導出的文件存儲在哪個目錄下等等
目前的問題是,這寫方案都不是一鍵完成的,里面需要手工操作。并且沒有測試過這些工具的可靠性,安全性。未必能夠用于生產環境
?