支持主流MySQL中間件的數據遷移工具ora2mysql


原文地址在(http://www.yougemysqldba.com/dis ... &extra=page%3D1
企業去IOE、或者轉型MySQL,不是一蹴而就的,而是需要長期的積累。只有當企業能夠真正駕馭MySQL時,才會將其作為核心數據庫。在未來很長一段時間,MySQL的比重會不斷的增加、Oracle的比重將會逐漸降低。而在這個時間內,企業經常需要將Oracle中的數據遷移到MySQL中。
      目前較出名的有kettle(http://community.pentaho.com/projects/data-integration/),這款工具的核心特點是可視化、支持的數據庫種類多。但是
其缺點也很明顯,安裝包大(接近一個G)、抽取和插入效率不敢恭維。
     為了給大家一個額外的選擇,我們提供了一個命令行下的數據遷移工具,專門針對從Oracle到MySQL,效率上要完爆kettle,而且配合一兩行shell腳本,可以輕松
實現多線程。
     安裝
操作系統        Centos5、centos6  X64
軟件環境        Oracle instant client軟件包
上傳上述rpm包與二進制包至/usr/local/ora2mysql/,並安裝
oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm(該文件太大,自己去網上下載)
oracle-instantclient-devel-10.2.0.4-1.x86_64.rpm
oracle-instantclient-sqlplus-10.2.0.4-1.x86_64.rpm
libmysqlclient.so.18(該文件太大,自己去網上下載)

 oracle-instantclient-devel-10.2.0.4-1.x86_64.rpm (283.04 KB) 
 oracle-instantclient-sqlplus-10.2.0.4-1.x86_64.rpm (766.96 KB) 
 ora2mysql (143.22 KB) 

rpm -ivh *.rpm
數據拷貝工具        ora2mysql
上傳到/usr/local/ora2mysql/下
環境變量        修改/etc/profile,在末尾增加如下
export ORACLE_HOME=/usr/lib/oracle/10.2.0.4/client64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/10.2.0.4/client64/lib:/usr/local/ora2mysql/
export TNS_ADMIN=/usr/lib/oracle/10.2.0.4/client64

運行 source  /ect/profile

        
運行
1.        進入ora2mysql目錄/usr/local/ora2mysql/下
運行
./ora2mysql
顯示如下
DataCopy: Fast Oracle Data Copy Utility, Release 3.0.1
(c) Copyright Lou Fangxin (AnySQL.net) 2010, all rights reserved.
Support by Wang Guang You(www.yougemysqldba.com) or WeChat(onesoft007)

Usage: ora2mysql keyword=value [,keyword=value,...]

Valid Keywords:
   user1   = username/password@hostort:sid for source database.
   user2   = username/password@hostort:database for target database.
   table   = table name for both source and target.
   tables  = table name list for both source and target.
   table1  = source table name to query data from.
   table2  = target table name to insert data into.
   query1  = select SQL for source database.
   query2  = insert SQL for target database.
   read    = set DB_FILE_MULTIBLOCK_READ_COUNT at session level
   sort    = set SORT_AREA_SIZE at session level (UNIT:MB) 
   hash    = set HASH_AREA_SIZE at session level (UNIT:MB) 
   serial  = set _serial_direct_read to TRUE at session level
   array   = array fetch size 
   rows    = print log information for every given rows.
   long    = maximum size for long, long raw, CLOB, BLOB columns.
   crypt   = encrypt the connection info only, no data copy (YES/NO).
   parfile = read command option from parameter file 
* wait    = wait time in microsecond after each array.
* sync    = sync mode (INSERT,UPDATE,DELETE,INSUPD,ARRINS,ARRUPD).
* unique  = primary key or unique key columns of target table.
* conflict= conflict columns for update on target table.
* filler  = filler columns (exclude columns) for target table.
* safe    = double column buffer for character set conversion.
* degree  = parallelize data copy degree (2-128).
   log     = log file name for screen messages.

Notes:
   ora2mysql user1=scott/tiger user2=scott/tiger table=emp
   ora2mysql user1=scott/tiger user2=scott/tiger table1=emp table2=emp_his

2.        根據Oracle表結構生成對應的MySQL表結構。由Oracle DBA和MySQL DBA配合完成。

3.        若兩個表字段數和含義相同,運行如下命令
./ora2mysql user1=<username>/<password>@<host>:<port>:<sid> user2=<username/<password>@<host>:<port>:<database>  table=<tablename>

4.        若兩個表字段數或者含義不同,運行如下命令
./ora2mysql user1=<username>/<password>@<host>:<port>:<sid> user2=<username/<password>@<host>:<port>:<database> query1=”select <column> from <table>”  query2=”insert into <table>( <column> )”


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM