加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何对比迁移前后的Oracle数据库性能

发布时间:2020-12-12 15:48:15 所属栏目:百科 来源:网络整理
导读:有越来越多的数据库都需要要迁移。如何衡量前后的数据库性能成了一个难点。本文使用AWR Compare Report来解决这个问题。 以下皆为测试库内容 环境描述 SID DBID OS 描述 finally 4033498616 windows 7 x64 假设为迁移后的数据库 zhadanren 97461353 Solaris
finally 4033498616 windows 7 x64 假设为迁移后的数据库 zhadanren 97461353 Solaris Sparc 6 x64 假设为迁移前的数据库

过程

详细过程如下

导出snapshot数据

注意:
这里导出的snapshot最好包含业务最忙时的时间段,以便于更准确的衡量迁移前后的数据库性能。

相关sql:

create directory dpdir as '&dir_path' ;
@?/rdbms/admin/awrextr.sql

步骤:

1、创建directory
SQL> create directory dpdir as '/u01/dpdir' ;

Directory created.
2、执行相应的sql
SQL> @?/rdbms/admin/awrextr.sql

以下需要输入几个参数具体包括:

输入要导出snapshot的dbid,这里使用默认回车即可
Enter value for dbid:

snapshot的列表日期范围,默认只保留8天,可以全部列出,再具体找要导出的snapshot number。
Enter value for num_days:100

要导出的开始snapshot number
Enter value for begin_snap:271

要导出的截止snapshot number

Enter value for end_snap: 280

到导出文件的directory(其实awrextr.sql也是基于datapump的)
Enter value for directory_name: DPDIR

导出文件的名称
Enter value for file_name: zhadanren1026

然后就开始了导出过程。最后会在定义的directory下生成dump文件以及log日志。可以查看log日志,看是否正常导出。

Using the dump file prefix: zhadanren1026
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The AWR extract dump file will be located
| in the following directory/file:
| /u01/dpdir
| zhadanren1026.dmp
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| *** AWR Extract Started ...
|
| This operation will take a few moments. The
| progress of the AWR extract operation can be
| monitored in the following directory/file:
| /u01/dpdir
| zhadanren1026.log
|

End of AWR Extract

导入snapshot数据

相关SQL:

create directory dpdir as '&dir_path' ;
@?/rdbms/admin/awrload.sql

步骤:

1、创建directory(源库也是使用datapump的方式导入的)
sys@FINALLY>create directory dpdir as 'd:appsdpdir' ;

目录已创建。
2、然后将导出的dump文件上传到迁移后的数据库服务器相应的新创建的directory下。
3、执行相应的sql
sys@FINALLY>@?/rdbms/admin/awrload.sql

以下需要输入几个参数具体包括:

输入 directory_name 的值: DPDIR

这里注意不要包含文件后缀名。
输入 file_name 的值: zhadanren1026

这是临时使用schema,导入过程完成以后会自动删除。
输入 schema_name 的值: AWR_STAGE

临时schema 的 默认表空间
输入 default_tablespace 的值: SYSAUX

临时schema的默认临时表空间
输入 temporary_tablespace 的值: TEMP

然后就开始了导入过程。最后会在定义的directory下生成导入log日志。可以查看log日志,看是否正常导入。

... Creating AWR_STAGE user

|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|  Loading the AWR data from the following
|  directory/file:
|   d:appsdpdir
|   zhadanren1026.dmp
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|  *** AWR Load Started ...
|
|  This operation will take a few moments. The
|  progress of the AWR load operation can be
|  monitored in the following directory/file:
|   d:appsdpdir
|   zhadanren1026.log
|
... Dropping AWR_STAGE user

End of AWR Load

生成AWR Compare report

经过上面的步骤,源库的snapshot信息已经导入到迁移后的数据库finally中了,下面我们可以使用AWR Compare report来衡量迁移前后的数据库性能。

相关sql:

查看snapshotSQL
select t.dbid,t.snap_id,to_char(begin_interval_time,'yyyymmddhh24miss') begin_time,to_char(end_interval_time,'yyyymmddhh24miss') end_time from DBA_HIST_SNAPSHOT t order by 1,4 desc;
生成报告SQL
spool awr_compare_report.html
set echo off;
set veri off;
set feedback off;
set head off set verify off set lines 8000 select * from TABLE(DBMS_WORKLOAD_REPOSITORY.awr_diff_report_html(4033498616,1,315,316,97461353,80,81));
spool off

步骤

1、 先找到迁移前数据库snapshot业务忙的时段相应的 snapshot id。

比如我们选择2016.10.26 7点到8点这个时间段。那么相应的snap_id起始为279截止为280。

select t.dbid,'yyyymmddhh24miss') end_time from DBA_HIST_SNAPSHOT t where dbid=97461353 order by 1,4 desc;

2、 找到迁移后数据库snapshot业务忙的时段相应的 snapshot id。

需要有对比性,所以一般选择相同时段来作为比较。不一定要同一日期,但是至少要选择有代表性的时间段。迁移后的数据库7点到8点时间段的snap_id 起始为412,截止为413。

select t.dbid,'yyyymmddhh24miss') end_time from DBA_HIST_SNAPSHOT t where dbid=4033498616 order by 1,4 desc;

根据上面的信息我们就可以使用DBMS_WORKLOAD_REPOSITORY.awr_diff_report_html来生成compare report了。

spool awr_compare_report.html
set echo off;
set veri off;
set feedback off;
set head off
set verify off
set lines 8000
select * from TABLE(DBMS_WORKLOAD_REPOSITORY.awr_diff_report_html(
97461353,279,280,4033498616,412,413));
spool off

示例内容如下:

物理配置对比

负载对比这个比较重要,也是衡量迁移前后性能的重要指标(但是要谨慎选择好时间点,保证时间段内迁移前后数据库承载的业务量一致)

report里面内容很多,还包括了初始化参数的对比等,大家自行生成以后可以多看看。具体指标内容这里不再详述。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

有越来越多的数据库都需要要迁移。如何衡量前后的数据库性能成了一个难点。本文使用AWR Compare Report来解决这个问题。

以下皆为测试库内容

环境描述

SID DBID OS 描述
    推荐文章
      热点阅读