這篇文章將為大家詳細(xì)講解有關(guān)Oracle 12.2如何使用Database Link優(yōu)化Standby Database Workload,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
創(chuàng)新互聯(lián)是一家專(zhuān)注于成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)與策劃設(shè)計(jì),東山網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專(zhuān)注于網(wǎng)站建設(shè)10余年,網(wǎng)設(shè)計(jì)領(lǐng)域的專(zhuān)業(yè)建站公司;建站業(yè)務(wù)涵蓋:東山等地區(qū)。東山做網(wǎng)站價(jià)格咨詢(xún):18982081108
從Oracle 12.2開(kāi)始,可以通過(guò)在database_link_to參數(shù)來(lái)指定一個(gè)數(shù)據(jù)庫(kù)鏈路來(lái)優(yōu)化備庫(kù)workload。由于安全原因,Oracle建議使用私有數(shù)據(jù)庫(kù)鏈路。這個(gè)鏈路必須屬于sys用戶(hù)并且能讓有權(quán)限的用戶(hù)來(lái)訪(fǎng)問(wèn)。Oracle數(shù)據(jù)庫(kù)包含一個(gè)缺省的權(quán)限用戶(hù)名為SYS$UMF。
在主庫(kù)中使用sys用戶(hù)創(chuàng)建表t1與配置sys$umf用戶(hù),這個(gè)用戶(hù)默認(rèn)是被鎖定的,所以需要先解鎖這個(gè)用戶(hù)并設(shè)置密碼:
SQL> alter user sys$umf account unlock identified by xxzx7817600; User altered. SQL>create table t1 as select * from user_tables; Table created. SQL> create index idx_t1_tablename on t1(table_name); Index created. SQL> exec dbms_stats.gather_table_stats('sys','t1',degree => 4,cascade => true); PL/SQL procedure successfully completed.
創(chuàng)建一個(gè)備庫(kù)(cs_dg)到主庫(kù)的鏈路,由于ADG是只讀的,所以創(chuàng)建數(shù)據(jù)庫(kù)鏈路操作都需要在主庫(kù)中執(zhí)行:
SQL> create database link cs_dg2_to_cs2 connect to sys$umf identified by abcd1234 using 'CS'; Database link created.
在備庫(kù)中驗(yàn)證數(shù)據(jù)庫(kù)鏈路是否創(chuàng)建成功
col owner for a20 SQL> col object_name for a50 SQL> select owner,object_name from dba_objects where object_type='DATABASE LINK'; OWNER OBJECT_NAME -------------------- -------------------------------------------------- SYS CS_DG2_TO_CS2 SYS SYS_HUB SQL> select table_name from user_tables@cs_dg2_to_cs2; no rows selected SQL> select sysdate from dual@cs_dg2_to_cs2; SYSDATE ------------ 24-JAN-19
在備庫(kù)中對(duì)表t1執(zhí)行查詢(xún),database_link_to參數(shù)用來(lái)指定備庫(kù)到主庫(kù)的數(shù)據(jù)鏈路名cs_dg2_to_cs2
SQL> variable tname varchar2(30); SQL> variable query varchar2(500); SQL> exec :tname := 'jy_task'; PL/SQL procedure successfully completed. SQL> exec :query := 'select /*+ full(t)*/ col1 from t1 t where table_name=''T1'''; PL/SQL procedure successfully completed. SQL> begin 2 :tname := dbms_sqltune.create_tuning_task 3 ( 4 sql_text => :query, 5 task_name => :tname, 6 database_link_to => 'CS_DG2_TO_CS2', 7 scope=>'COMPREHENSIVE', 8 time_limit=>60, 9 description=>'Task to tune a query_on adg'); 10 end; 11 / PL/SQL procedure successfully completed. SQL> exec dbms_sqltune.execute_tuning_task(:tname); PL/SQL procedure successfully completed. SQL> select dbms_sqltune.report_tuning_task(:tname) from dual; DBMS_SQLTUNE.REPORT_TUNING_TASK(:TNAME) -------------------------------------------------------------------------------- GENERAL INFORMATION SECTION ----------------------------------------------------
關(guān)于“Oracle 12.2如何使用Database Link優(yōu)化Standby Database Workload”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。