標籤:oracle 資料移轉 aws rds
如何安裝Oracle跟建立Oracle的AWS RDS在此就不再詳述。只是簡單的在本地Oracle建立一些簡單的資料,後嘗試匯入RDS.
·
Step 1:賦予許可權
登入到本地Oracle輸入下面命令:
SQL> grant unlimited tablespace to SCOTT;SQL> grant read,write on directory data_pump_dir to SCOTT;SQL> grant execute on dbms_datapump to SCOTT;SQL> @/usr/oracle/dumpscott.sql
PL/SQL procedure successfully completed.
dumpscott.sql 內容:
DECLAREhdnl NUMBER;BEGINhdnl := DBMS_DATAPUMP.open( operation => ‘EXPORT‘, job_mode => ‘SCHEMA‘, job_name=>null);DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => ‘scott.dmp‘, directory => ‘DATA_PUMP_DIR‘, filetype => dbms_datapump.ku$_file_type_dump_file);DBMS_DATAPUMP.add_file( handle => hdnl, filename => ‘exp.log‘, directory => ‘DATA_PUMP_DIR‘, filetype => dbms_datapump.ku$_file_type_log_file);DBMS_DATAPUMP.METADATA_FILTER(hdnl,‘SCHEMA_EXPR‘,‘IN (‘‘SCOTT‘‘)‘);DBMS_DATAPUMP.start_job(hdnl);END;/
Step 4: 使用 DBMS_FILE_TRANSFER 傳輸 dump file 到 Amazon RDS DB
BEGIN
DBMS_FILE_TRANSFER.PUT_FILE(
source_directory_object => ‘DATA_PUMP_DIR‘,
source_file_name => ‘scott.dmp‘,
destination_directory_object => ‘DATA_PUMP_DIR‘,
destination_file_name => ‘scott_copied.dmp‘,
destination_database => ‘to_rds‘
);
END;
/
在sqlplus則行該SQL檔案:
SQL> @/usr/oracle/putscott.sql
PL/SQL procedure successfully completed.
Step 4:利用Data pump 把資料import到RDS
impdp <username>@<TNS_ENTRY> DUMPFILE=user1copied.dmpDIRECTORY=DATA_PUMP_DIR full=y
輸入如下內容:
impdp [email protected]_DB DUMPFILE=scott_copied.dmp DIRECTORY=DATA_PUMP_DIR full=y
提示輸入密碼後將自動完成上傳匯入處理程序。然後串連到RDS可以查詢到SCOTT的emp表等草操作。此處會有兩個error不過可以忽略
本文出自 “技術部落格” 部落格,請務必保留此出處http://raytech.blog.51cto.com/7602157/1684108
本地Oracle資料上傳到AWS的RDS