Oracle 数据库重放(Database Replay)---样例

简介: 1 生产环境 创建存放抓取文件的directory mkdir DBReplay sqlplus / as sysdba create directory cap10g as 'XXXXX/dbreplay'; 2 生产环境 开始抓取trace sqlplus / as sysdba<spool capture_trace.

1 生产环境 创建存放抓取文件的directory
mkdir DBReplay
sqlplus / as sysdba
create directory cap10g as 'XXXXX/dbreplay';
2 生产环境 开始抓取trace
sqlplus / as sysdba<spool capture_trace.log
alter 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 off
EOF
备注:DIR的值必须大写
--检查抓取进度
select * from dba_workload_captures;
3 生产环境 结束抓取trace
sqlplus / as sysdba
EXEC 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:55
end_time:2018/9/6 16:18:55
5 生产环境 生成抓取时间段生产环境的awr报告
sqlplus / as sysdba
select dbms_workload_repository.awr_report_html('2781309325',1,'111','113','')from dual;

第一个参数为dbid,第3个参数为begin_snapshot,第4个参数为end_snapshot

6 性能影响分析环境 创建存放抓取文件的directory
sqlplus / as sysdba
create 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; -----当前值为16050982577944
3.安全起见,再创建一个闪回点:
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.sh

wrc 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_replays

17 性能影响分析环境 生成重放结果文件
生成重放结果文件
select id from dba_workload_replays; 输出结果为3
select dbms_workload_replay.REPORT(3,'HTML') FROM DUAL;

18 性能影响分析环境 查询awr需要的snap id
查询awr需要的snap id
select 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方式备份性能数据

目录
相关文章
|
1天前
|
存储 SQL Oracle
|
1天前
|
SQL 存储 Oracle
关系型数据库Oracle
【7月更文挑战第4天】
7 2
|
1天前
|
SQL 存储 Oracle
Oracle数据库中游标的工作原理与优化方法
Oracle数据库中游标的工作原理与优化方法
|
23小时前
|
SQL 存储 Oracle
Oracle数据库基础教程与操作技巧
Oracle数据库基础教程与操作技巧
|
1天前
|
SQL Oracle 关系型数据库
Oracle数据库基础教程:从安装到基本操作的全面介绍
Oracle数据库基础教程:从安装到基本操作的全面介绍
|
2天前
|
数据库
数据库bug-[08001] Could not create connection to database server. Attempted reconnect 3,主机名ip必须写对
数据库bug-[08001] Could not create connection to database server. Attempted reconnect 3,主机名ip必须写对
|
2天前
|
XML Java 关系型数据库
Action:Consider the following: If you want an embedde ,springBoot配置数据库,补全springBoot的xml和mysql配置信息就好了
Action:Consider the following: If you want an embedde ,springBoot配置数据库,补全springBoot的xml和mysql配置信息就好了
|
2天前
|
关系型数据库 MySQL 数据库
关系型数据库mysql数据增量恢复
【7月更文挑战第3天】
12 2
|
2天前
|
关系型数据库 MySQL Shell
关系型数据库mysql数据完全恢复
【7月更文挑战第3天】
10 2
|
2天前
|
存储 关系型数据库 MySQL

推荐镜像

更多