迁移 AWR数据
Oracle Database 允许我们在几个数据库之间传输 AWR数据。当您要在单独的系统上分析 AWR数据时,这非常有用。要传输 AWR数据,您必须先从源数据库上抽取出 AWR快照数据,然后将该数据载入目标数据库中。以下内容将介绍如何在 Oracle Database上抽抽取和载入 AWR数据。
利用awrextr.sql脚本可以将数据库中一系列的 AWR快照数据抽取到Data Pump导出文件中。导出 AWR快照数据后,您就可以将此 dump文件传输到您要载入该数据库的其他数据库上。要运行awrextr.sql脚本,您必须以SYS用户身份连接到数据库中。
抽取 AWR数据的步骤如下:
- 在 sqlplus 命令行中,输入:
@$ORACLE_HOME/rdbms/admin/awrextr.sql
显示 AWR schema中的数据库列表。
- 指定要从其中抽取 AWR 数据的数据库的 DBID:
Enter value for dbid: 220853307
- 指定您要列出多少天内的快照 IDs。
Enter value for num_days: 2
4. 指定起始和结束snapshot_id,定义要抽取的 AWR数据的范围:
Enter value forbegin_snap: 31
Enter value for end_snap: 41
- 指定要存放导出的 dump 文件的 directory 对象名称(需要提前创建):
sys@PROD> createdirectory db_dir as '/home/oracle/backup';
Enter value for directory_name: DB_DIR
- 指定导出 dump 文件的名称前置(将自动加上.dmp 后缀):
Enter value for file_name: awrdata_31_41
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The AWR extract dump file will be located
| in the following directory/file:
| /home/oracle/backup
| awrdata_31_41.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:
| /home/oracle/backup
| awrdata_31_41.log
|
Elapsed:00:00:00.06
Elapsed:00:01:41.66
End of AWR ExtractAWR
数据导出的时间由要导出 AWR数据量决定,导出后您就可以将其传送到其他数据库系统。
[oracle@prod backup]$ ls -lt
total 10196
-rw-r----- 1 oracle oinstall10407936 Mar 9 21:36 awrdata_31_41.dmp
-rw-r--r-- 1 oracleoinstall 15577 Mar 9 21:36 awrdata_31_41.log
2 载入 AWR数据
将导出的 dump文件传送到目标数据库后,可以使用awrload.sql脚本载入抽取的 AWR数据。awrload.sql脚本首先会创建一个中转schema,将Data Pump文件载入数据库中。随后会将该数据从中转 schema传入相应的AWR表。要运行awrload.sql脚本,必须以 SYS用户身份连接到数据库。
载入 AWR数据的步骤:
- 在sqlplus 命令提示符中输入:
@$ORACLE_HOME/rdbms/admin/awrload.sql
显示一个目录对象列表。
- 指定导出的 dump 文件所在的目录对应的 directory 对象:
Entervalue for directory_name: DB_DIR
- 指定导出的 dump 文件的前缀( .dmp 后缀将自动加上):
Enter valuefor file_name: awrdata_31_41
- 指定将要载入 AWR 数据的中转 schema 的名称:
Enter value for schema_name: AWR_STAGE
- 指定中转 schema 的默认表空间:
Enter value for default_tablespace: SYSAUX
- 指定中转 schema 的临时表空间:
Enter value for temporary_tablespace: TEMP
- 执行上述操作后,就会在数据库中创建一个名为 AWR_STAGE 的schema,用来载入 AWR 数据。将AWR 数据载入 AWR_STAGE schema 后,这些数据就会传入 SYS schema 中的 AWR 表中:
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Loading the AWR data from the following
| directory/file:
| /home/oracle/backup
| awrdata_31_41.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:
| /home/oracle/backup
| awrdata_31_41.log
|
Elapsed:00:00:00.02
Elapsed:00:00:56.56
Elapsed:00:00:16.11
... DroppingSTAGE_AWR user
载入的时间由要载入的 AWR数据量决定。载入 AWR数据后,中转schema将自动删除。
转载请注明作者出处及原文链接:
http://blog.youkuaiyun.com/xiangsir/article/details/8666184