本文共 4700 字,大约阅读时间需要 15 分钟。
1 生产环境 创建存放抓取文件的directory
mkdir DBReplay sqlplus / as sysdba create directory cap10g as 'XXXXX/dbreplay'; 2 生产环境 开始抓取trace sqlplus / as sysdba<spool capture_trace.logalter system set PRE_11G_ENABLE_CAPTURE=true scope=memory;EXEC DBMS_WORKLOAD_CAPTURE.START_CAPTURE(name =>'cap10g',dir =>'CAP10G',duration =>7200);alter system set PRE_11G_ENABLE_CAPTURE=false scope=memory;exit;spool offEOF备注:DIR的值必须大写--检查抓取进度 select * from dba_workload_captures;3 生产环境 结束抓取trace sqlplus / as sysdbaEXEC DBMS_WORKLOAD_CAPTURE.FINISH_CAPTURE();1、如果生产已结束抓取,则不必执行。2、如果生产在抓取过程中因为cpu飙升等原因需要立即结束,可以提前执行该步骤。3、如果生产抓取结束后仍然在抓取,需要执行该步骤。4 生产环境 生成抓取时间段生产环境的DB性能数据 生成抓取时间段生产环境的DB性能数据
sqlplus / as sysdba
select id from dba_workload_captures;select dbms_workload_capture.REPORT(3,'HTML') from dual;需要在pl/SQL develop工具里执行start_time:2018/9/6 14:18:55end_time:2018/9/6 16:18:555 生产环境 生成抓取时间段生产环境的awr报告 sqlplus / as sysdbaselect dbms_workload_repository.awr_report_html('2781309325',1,'111','113','')from dual;第一个参数为dbid,第3个参数为begin_snapshot,第4个参数为end_snapshot
6 性能影响分析环境 创建存放抓取文件的directory
sqlplus / as sysdbacreate directory rep as 'XXXXXXXXXXX/dbreplay'; 7 10g生产库性能影响分析环境拷贝抓取文件到12c性能测试库重放目录下 8 性能影响分析环境 导入统计信息 9 性能影响分析环境 导入SPM 10 性能影响分析环境 打开闪回并记录当前SCN,作为以后闪回的SCN 1.数据库启动到mount状态,打开闪回 alter database flashback on; ----确认FRA空间足够2.记录当前scn号: select current_scn from v$database; -----当前值为160509825779443.安全起见,再创建一个闪回点: create restore point point201811021423; 11 性能影响分析环境 重放前预处理 exec dbms_workload_replay.process_capture(capture_dir => 'REP'); 12 性能影响分析环境 重放前检查客户端 wrc MODE=calibrate REPLAYDIR=XXXXXXX/dbreplay 这里提示开多少个客户端,等会第15步就起多少个13 性能影响分析环境 重放前初始化 EXEC DBMS_WORKLOAD_REPLAY.initialize_replay(replay_name => 'UP_REP2', replay_dir => 'REP'); 这一步比较耗时14 性能影响分析环境 设置重放参数 "EXEC DBMS_WORKLOAD_REPLAY.SET_REPLAY_TIMEOUT (FALSE);EXEC DBMS_WORKLOAD_REPLAY.prepare_replay(synchronization => FALSE);----这个也比较耗时,并且还耗system表空间,记得提前扩容 15 性能影响分析环境 启动重放客户端 vi wrc.shwrc system/XXXXX replaydir=XXXXXXX/dbreplay
请后台执行,第12步提示要多少个客户端就后台开多少个,一定要后台跑
nohup sh wrc.sh > wrc_2.log 2>&1 &nohup sh wrc.sh > wrc_3.log 2>&1 &nohup sh wrc.sh > wrc_4.log 2>&1 &nohup sh wrc.sh > wrc_5.log 2>&1 &nohup sh wrc.sh > wrc_6.log 2>&1 &nohup sh wrc.sh > wrc_7.log 2>&1 &nohup sh wrc.sh > wrc_8.log 2>&1 &nohup sh wrc.sh > wrc_9.log 2>&1 &nohup sh wrc.sh > wrc_10.log 2>&1 &nohup sh wrc.sh > wrc_11.log 2>&1 &nohup sh wrc.sh > wrc_12.log 2>&1 &nohup sh wrc.sh > wrc_13.log 2>&1 &nohup sh wrc.sh > wrc_14.log 2>&1 &nohup sh wrc.sh > wrc_15.log 2>&1 &nohup sh wrc.sh > wrc_16.log 2>&1 &nohup sh wrc.sh > wrc_17.log 2>&1 &nohup sh wrc.sh > wrc_18.log 2>&1 &nohup sh wrc.sh > wrc_19.log 2>&1 &nohup sh wrc.sh > wrc_20.log 2>&1 &nohup sh wrc.sh > wrc_21.log 2>&1 &nohup sh wrc.sh > wrc_22.log 2>&1 &nohup sh wrc.sh > wrc_23.log 2>&1 &nohup sh wrc.sh > wrc_24.log 2>&1 &nohup sh wrc.sh > wrc_25.log 2>&1 &nohup sh wrc.sh > wrc_26.log 2>&1 &nohup sh wrc.sh > wrc_27.log 2>&1 &nohup sh wrc.sh > wrc_28.log 2>&1 &nohup sh wrc.sh > wrc_29.log 2>&1 &nohup sh wrc.sh > wrc_30.log 2>&1 &nohup sh wrc.sh > wrc_31.log 2>&1 &nohup sh wrc.sh > wrc_32.log 2>&1 &nohup sh wrc.sh > wrc_33.log 2>&1 &nohup sh wrc.sh > wrc_34.log 2>&1 &nohup sh wrc.sh > wrc_35.log 2>&1 &nohup sh wrc.sh > wrc_36.log 2>&1 &nohup sh wrc.sh > wrc_37.log 2>&1 &nohup sh wrc.sh > wrc_38.log 2>&1 &nohup sh wrc.sh > wrc_39.log 2>&1 &nohup sh wrc.sh > wrc_40.log 2>&1 &nohup sh wrc.sh > wrc_41.log 2>&1 &nohup sh wrc.sh > wrc_42.log 2>&1 &nohup sh wrc.sh > wrc_43.log 2>&1 &nohup sh wrc.sh > wrc_44.log 2>&1 &nohup sh wrc.sh > wrc_45.log 2>&1 &nohup sh wrc.sh > wrc_46.log 2>&1 &nohup sh wrc.sh > wrc_47.log 2>&1 &nohup sh wrc.sh > wrc_48.log 2>&1 &nohup sh wrc.sh > wrc_59.log 2>&1 &nohup sh wrc.sh > wrc_50.log 2>&1 &nohup sh wrc.sh > wrc_51.log 2>&1 &nohup sh wrc.sh > wrc_52.log 2>&1 &nohup sh wrc.sh > wrc_53.log 2>&1 &nohup sh wrc.sh > wrc_54.log 2>&1 &nohup sh wrc.sh > wrc_55.log 2>&1 &nohup sh wrc.sh > wrc_56.log 2>&1 &nohup sh wrc.sh > wrc_57.log 2>&1 &nohup sh wrc.sh > wrc_58.log 2>&1 &nohup sh wrc.sh > wrc_59.log 2>&1 &nohup sh wrc.sh > wrc_60.log 2>&1 &nohup sh wrc.sh > wrc_61.log 2>&1 &16 性能影响分析环境 启动重放(在另一个终端执行)
启动重放EXEC DBMS_WORKLOAD_REPLAY.START_REPLAY();检查回放进度select * from dba_workload_replays17 性能影响分析环境 生成重放结果文件
生成重放结果文件select id from dba_workload_replays; 输出结果为3select dbms_workload_replay.REPORT(3,'HTML') FROM DUAL;18 性能影响分析环境 查询awr需要的snap id
查询awr需要的snap idselect dr.awr_dbid,dr.awr_begin_snap,dr.awr_end_snap,dr.awr_exported from dba_workload_replays dr;19 性能影响分析环境 取awr报告 select dbms_workload_repository.awr_report_html('61647356',1,'170','172','')from dual;
20 性能影响分析环境 以exp方式备份性能数据转载地址:http://efwql.baihongyu.com/