您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“Oracle 12C如何實現跨網絡傳輸數據庫”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“Oracle 12C如何實現跨網絡傳輸數據庫”這篇文章吧。
前言
跨網絡傳輸數據庫,可以通過使用network_link參數來執行導入操作,導入操作將使用數據庫鏈路,不需要生成dump文件。
操作步驟如下:
1、在目標數據庫中創建鏈接到源數據庫的數據鏈路。執行導入操作的用戶必須要有datapump_imp_full_database權限,并且連接到源數據庫的數據鏈路也必須連接到一個有datapump_exp_full_database角色的用戶。在源數據庫中用戶不能有sysdba管理權限。
2、在源數據庫上將所有用戶表空間置為只讀模式
3、將源數據庫中所有用戶表空間相關的數據文件傳輸到目標數據庫。如果源平臺與目標平臺的字節編碼不同,那么查詢v$transportable_platform視圖來進行查看。并且將可以使用以下一種方法來轉換數據文件:
.使用dbms_file_transfer包中的get_file或put_file過程來傳輸數據文件。這些過程會自動將數據文件的字節編碼轉換為目標平臺的字節編碼。
.使用rman的convert命令來將數據文件的字節編碼轉換為目標平臺的字節編碼。
4、在目標數據庫上執行導入操作。使用Data Pump工具來導入所有用戶表空間的元數據與管理表空間的元數據與真實數據。
確保以下參數正確設置:
.transportable=always .transport_datafiles=list_of_datafiles .full=y .network_link=database_link .version=12
如果源數據庫為11.2.0.3或11g之后的版本,那么必須設置version=12。如果源數據庫與目標數據庫都是12c,那么version參數不用設置。
如果源數據庫包含任何加密表空間或表空間包含加密列,那么你必須指定encryption_pwd_prompt=yes或指定encryption_password參數。
Data Pump跨網絡導入將會復制所有用戶表空間所存儲對象的元數據與管理表空間中的元與用戶對象的真實數據。當導入完成后,用戶表空間將會置于讀寫模式。
5、可選操作將源數據庫中的所有用戶表空間置為讀寫模式。
下面的例子是將源數據庫jyrac傳輸到目標數據庫jypdb
1.在目標數據庫中以sys用戶來創建鏈接到源數據庫的數據鏈路。源數據庫中的用戶為jy
SQL> conn sys/xxzx7817600@jypdb as sysdba Connected. SQL> create public database link jyrac_link 2 connect to jy identified by "jy" 3 using '(DESCRIPTION = 4 (ADDRESS_LIST = 5 (ADDRESS = (PROTOCOL = TCP)(HOST =10.138.130.153)(PORT = 1521)) 6 ) 7 (CONNECT_DATA = 8 (SERVER = DEDICATED) 9 (SERVICE_NAME =jyrac) 10 ) 11 )'; Database link created.
2.在源數據庫上將所有用戶表空間置為只讀模式
SQL> select tablespace_name,status from dba_tablespaces; TABLESPACE_NAME STATUS ------------------------------ --------- SYSTEM ONLINE SYSAUX ONLINE UNDOTBS1 ONLINE TEMP ONLINE USERS ONLINE UNDOTBS2 ONLINE EXAMPLE ONLINE TEST ONLINE 8 rows selected. SQL> alter tablespace test read only; Tablespace altered. SQL> alter tablespace users read only; Tablespace altered. SQL> alter tablespace example read only; Tablespace altered. SQL> select tablespace_name,status from dba_tablespaces; TABLESPACE_NAME STATUS ------------------------------ --------- SYSTEM ONLINE SYSAUX ONLINE UNDOTBS1 ONLINE TEMP ONLINE USERS READ ONLY UNDOTBS2 ONLINE EXAMPLE READ ONLY TEST READ ONLY 8 rows selected.
3.在目標數據庫中使用dbms_file_transfer包中的get_file過程將源數據庫中所有用戶表空間相關的數據文件傳輸到目標數據庫上
在源數據庫中創建目錄tts_datafile(存儲數據文件)
SQL> create or replace directory tts_datafile as '+datadg/jyrac/datafile/'; Directory created. SQL> grant execute,read,write on directory tts_datafile to public; Grant succeeded.
在目標數據庫中創建目錄tts_datafile(存儲數據文件)
SQL> create or replace directory tts_datafile as '+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/'; Directory created. SQL> grant execute,read,write on directory tts_datafile to public; Grant succeeded.
在目標數據庫中執行dbms_file_transfer.get_file過程將源數據庫中所有用戶表空間所相關的數據文件傳輸到目標數據庫中
SQL> exec dbms_file_transfer.get_file(source_directory_object =>'TTS_DATAFILE',source_file_name => 'test01.dbf',source_database =>'jyrac_link',destination_directory_object => 'TTS_DATAFILE',destination_file_name => 'test01.dbf'); PL/SQL procedure successfully completed. SQL> exec dbms_file_transfer.get_file(source_directory_object =>'TTS_DATAFILE',source_file_name => 'example.260.930413057',source_database =>'jyrac_link',destination_directory_object => 'TTS_DATAFILE',destination_file_name => 'example01.dbf'); PL/SQL procedure successfully completed. SQL> exec dbms_file_transfer.get_file(source_directory_object =>'TTS_DATAFILE',source_file_name => 'users.263.930413057',source_database =>'jyrac_link',destination_directory_object => 'TTS_DATAFILE',destination_file_name => 'users01.dbf'); PL/SQL procedure successfully completed.
ASMCMD [+data/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile] > ls -lt Type Redund Striped Time Sys Name DATAFILE UNPROT COARSE JUN 02 16:00:00 N users01.dbf => +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/FILE_TRANSFER.298.945620417 DATAFILE UNPROT COARSE JUN 02 16:00:00 N test01.dbf => +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/FILE_TRANSFER.300.945620337 DATAFILE UNPROT COARSE JUN 02 16:00:00 N example01.dbf => +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/FILE_TRANSFER.299.945620391 DATAFILE UNPROT COARSE JUN 02 16:00:00 Y FILE_TRANSFER.300.945620337 DATAFILE UNPROT COARSE JUN 02 16:00:00 Y FILE_TRANSFER.299.945620391 DATAFILE UNPROT COARSE JUN 02 16:00:00 Y FILE_TRANSFER.298.945620417 DATAFILE UNPROT COARSE JUN 02 00:00:00 N testtb01.dbf => +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/TESTTB.295.944828399 DATAFILE UNPROT COARSE JUN 02 00:00:00 Y UNDO_2.277.939167063 DATAFILE UNPROT COARSE JUN 02 00:00:00 Y UNDOTBS2.278.945029905 DATAFILE UNPROT COARSE JUN 02 00:00:00 Y UNDOTBS1.273.939167015 DATAFILE UNPROT COARSE JUN 02 00:00:00 Y TESTTB.295.944828399 DATAFILE UNPROT COARSE JUN 02 00:00:00 Y SYSTEM.274.939167015 DATAFILE UNPROT COARSE JUN 02 00:00:00 Y SYSAUX.275.939167015
4.在目標數據庫上執行導入操作。使用Data Pump工具來導入所有用戶表空間的元數據與管理表空間的元數據與真實數據。
[oracle@jytest1 tts]$ impdp system/xxzx7817600@JYPDB_175 full=y network_link=jyrac_link transportable=always transport_datafiles='+data/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/test01.dbf','+data/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/example01.dbf','+data/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/users01.dbf' version=12 directory=TTS_DUMP_LOG logfile=import.log Import: Release 12.2.0.1.0 - Production on Fri Jun 2 16:30:40 2017 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production Starting "SYSTEM"."SYS_IMPORT_FULL_01": system/********@JYPDB_175 full=y network_link=jyrac_link transportable=always transport_datafiles=+data/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/test01.dbf,+data/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/example01.dbf,+data/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/users01.dbf version=12 directory=TTS_DUMP_LOG logfile=import.log Estimate in progress using BLOCKS method... Processing object type DATABASE_EXPORT/PLUGTS_FULL/FULL/PLUGTS_TABLESPACE Processing object type DATABASE_EXPORT/PLUGTS_FULL/PLUGTS_BLK Processing object type DATABASE_EXPORT/EARLY_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/TABLE_DATA Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA ....... Processing object type DATABASE_EXPORT/SCHEMA/DIMENSION Processing object type DATABASE_EXPORT/END_PLUGTS_BLK Processing object type DATABASE_EXPORT/FINAL_POST_INSTANCE_IMPCALLOUT/MARKER Processing object type DATABASE_EXPORT/SCHEMA/TABLE/POST_INSTANCE/PROCACT_INSTANCE Processing object type DATABASE_EXPORT/SCHEMA/TABLE/POST_INSTANCE/PROCDEPOBJ Processing object type DATABASE_EXPORT/SCHEMA/POST_SCHEMA/PROCOBJ Processing object type DATABASE_EXPORT/SCHEMA/POST_SCHEMA/PROCACT_SCHEMA Processing object type DATABASE_EXPORT/AUDIT Processing object type DATABASE_EXPORT/POST_SYSTEM_IMPCALLOUT/MARKER ORA-39082: Object type PROCEDURE:"APEX_030200"."F" created with compilation warnings ORA-39082: Object type PROCEDURE:"APEX_030200"."APEX_ADMIN" created with compilation warnings ORA-39082: Object type PROCEDURE:"APEX_030200"."HTMLDB_ADMIN" created with compilation warnings Job "SYSTEM"."SYS_IMPORT_FULL_01" completed with 1689 error(s) at Fri Jun 2 16:43:47 2017 elapsed 0 00:13:03
傳輸完成后我們抽查用戶jy的dba_tables表的數據在傳輸后是否與源數據庫中的數據一致。
源數據庫
SQL> conn sys/xxzx7817600@jyrac as sysdba Connected. SQL> select count(*) from jy.dba_tables; COUNT(*) ---------- 2141
目標數據庫
SQL> conn sys/xxzx7817600@jypdb as sysdba Connected. SQL> select count(*) from jy.dba_tables; COUNT(*) ---------- 2141
查詢傳輸后用戶表空間的狀態是否為online,可以看到test,example,users表空間狀態為online
SQL> select tablespace_name,status from dba_tablespaces; TABLESPACE_NAME STATUS ------------------------------ --------- SYSTEM ONLINE SYSAUX ONLINE UNDOTBS1 ONLINE TEMP ONLINE UNDO_2 ONLINE USERS ONLINE TESTTB ONLINE TEMP2 ONLINE TEMP3 ONLINE EXAMPLE ONLINE TEST ONLINE UNDOTBS2 ONLINE 12 rows selected.
5.將源數據庫中的所有用戶表空間設置為讀寫模式
SQL> alter tablespace test read write; Tablespace altered. SQL> alter tablespace example read write; Tablespace altered. SQL> alter tablespace users read write; Tablespace altered. SQL> select tablespace_name,status from dba_tablespaces; TABLESPACE_NAME STATUS ------------------------------ --------- SYSTEM ONLINE SYSAUX ONLINE UNDOTBS1 ONLINE TEMP ONLINE USERS ONLINE UNDOTBS2 ONLINE EXAMPLE ONLINE TEST ONLINE 8 rows selected.
到此通過網絡執行完整數據庫傳輸的操作就完成了。
以上是“Oracle 12C如何實現跨網絡傳輸數據庫”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。