Oracle RAT- Real Application Testing

來源:互聯網
上載者:User

RAT 是Oracle 11g的一個新特性.它的目的是評估資料的效能。當我們對資料庫進行升級或改動一些配置,換資料庫伺服器時可以對改動之前和改動之後的效能進行對比.要使兩者的效能具有可比性,並且切合實際。就需要先在生產環境中capture某一個時間段的所有操作。然後把它們在測試環境中進行replay.

                            一.Capture步驟

  • 建立一個系統目錄,例如d:\capture
  • 建立一個Oracle 目錄:create directory dir1 as ‘d:\capture’
  • 開始capture:dbms_workload_capture.start_capture(name=>’TEST’,dir=>’DIR1’);(此處DIR1必須大寫)
  • 在資料庫中做一些操作
  • 結束capture: dbms_workload_capture.finish_capture;

                                                                             

                               二.Replay 準備工作 
    1. 把目標server上的capture files拷貝到測試的server上.假設在測試的server上同樣建一個目標d:\capture
    2. 建立一個Oracle 目錄:create directory dir1 as ‘d:\capture’
    Process workload:dbms_workload_replay.process_capture(capture_dir => ‘DIR1′));

    • Initialize the replay
    dbms_workload_replay.initialize_replay(replay_name => ‘REPLAY1′,replay_dir => ‘DIR1′);

    • Prepare the replay
    dbms_workload_replay.prepare_replay(synchronization => FALSE);                                                          三.Replay 正式開始:把capture files 拷貝到本地,假設也拷到d:\capture.開啟cmd.運行命令:wrc Arwen/Arwen@ora11r2 mode = calibrate replaydir=’d:\capture’;接著運行wrc Arwen/Arwen@ora11r2 mode = replay replaydir = ‘d:\capture’開啟別外一個cmd用sqlplus 串連到db然後運行exec dbms_workload_replay.start_replay.在前一個cmd中會有提示:replay started :時間 replay finished :時間Replay完之後產生報表:DECLAREl_cap_idNUMBER;l_rep_idNUMBER;v_rep_rptCLOB;REPORTFILE          UTL_FILE.FILE_TYPE;BEGINl_cap_id:=
    dbms_workload_replay.get_replay_info(dir
    =>'DIR1');SELECTMAX
    (id) INTO l_rep_id
    FROM dba_workload_replaysWHERE capture_id= l_cap_id;v_rep_rpt:=
    dbms_workload_replay.report(replay_id=> l_rep_id,format=>'HTML');REPORTFILE:=UTL_FILE.FOPEN('DIR1','report.HTML','W',32767);UTL_FILE.PUT_LINE( REPORTFILE, v_rep_rpt,
    true);UTL_FILE.FCLOSE(REPORTFILE);END; (注:capture完之後在對應的目錄中也會產生一個html的report.可以拿來和replay產生的report.html對比).

     

                                                                  

     

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.