Oracle遷移到Greenplum的方案
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的資訊,選擇要匯出的型別,匯出的檔案儲存在哪個目錄下等等
目前的問題是,這寫方案都不是一鍵完成的,裡面需要手工操作。並且沒有測試過這些工具的可靠性,安全性。未必能夠用於生產環境
更多Oracle相關資訊見 Oracle 專題頁面 https://www.linuxidc.com/topicnews.aspx?tid=12
Linux公社的RSS地址 : https://www.linuxidc.com/rssFeed.aspx
本文永久更新連結地址: https://www.linuxidc.com/Linux/2019-03/157588.htm