AWR(三)-迁移AWR数据之导入AWR收集数据
之前写了AWR的基本配置,详见http://www.dbdream.com.cn/2011/12/01/awr%E4%B8%80-%E5%9F%BA%E6%9C%AC%E9%85%8D%E7%BD%AE/和导出AWR数据的文章,详见http://www.dbdream.com.cn/2011/12/01/awr%E4%BA%8C-%E8%BF%81%E7%A7%BBawr%E6%95%B0%E6%8D%AE%E4%B9%8B%E5%AF%BC%E5%87%BAawr%E6%94%B6%E9%9B%86%E6%95%B0%E6%8D%AE/可以参考,现在简单介绍下如何将远程AWR导出的数据加载到本地数据库。
1. 在导入之前还是要创建DIRECTORY,当然,如果数据库已经建立了这些路径,就不需要再建立了。
DATA_FILE_DIR DATA_PUMP_DIR EXP IMP
创建DATA_FILE_DIR路径,将要导入的dmp文件存到此路径指定的操作系统目录下。
SQL> create directory data_file_dir as 'd:dir'; create directory data_pump_dir as 'd:dpdump' * 第 1 行出现错误: ORA-00955: 名称已由现有对象使用
这个路径数据库已经有了,所以报错。
2. 我们使用$ORACLE_HOME/rdbms/admin/awrload.sql脚本加载AWR导出的dmp文件的数据。下面通过小小的实验来演示加载过程。
SQL> @?/rdbms/admin/awrload ~~~~~~~~~~ AWR LOAD ~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ This script will load the AWR data from a dump file. The ~ ~ script will prompt users for the following information: ~ ~ (1) name of directory object ~ ~ (2) name of dump file ~ ~ (3) staging schema name to load AWR data into ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Specify the Directory Name ~~~~~~~~~~~~~~~~~~~~~~~~~~ Directory Name Directory Path ------------------------------ --------------------------------------------- DATA_FILE_DIR D:dir DATA_PUMP_DIR D:oracleadminstreamdpdump EXP d:exp IMP d:imp ORACLECLRDIR D:oracleproduct11.2.0dbhome_1binclr ORACLE_OCM_CONFIG_DIR D:oracleproduct11.2.0dbhome_1ccrstate XMLDIR D:oracleproduct11.2.0dbhome_1rdbmsxml Choose a Directory Name from the list above (case-sensitive). 输入 directory_name 的值:
ORACLE提示输入需要加载的数据在那个路径下,需要注意的是DATA_FILE_DIR一定要大写。
输入 directory_name 的值: DATA_FILE_DIR Using the dump directory: DATA_FILE_DIR Specify the Name of the Dump File to Load ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Please specify the prefix of the dump file (.dmp) to load: 输入 file_name 的值:
ORACLE问你需要加载的文件名字是什么呀?需注意的是这个文件名字不能加后缀。
输入 file_name 的值: AWR_571-575 Loading from the file name: AWR_571-575.dmp Staging Schema to Load AWR Snapshot Data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The next step is to create the staging schema where the AWR snapshot data will be loaded. After loading the data into the staging schema, the data will be transferred into the AWR tables in the SYS schema. The default staging schema name is AWR_STAGE. To use this name, press to continue, otherwise enter an alternative. 输入 schema_name 的值:
ORACLE说了,这些数据要加载到在SYS SCHEMA里的AWR表里,但是默认干这个活的是AWR_STAGE这个小子,然后ORACLE问了,你打算让谁干这个活啊?既然AWR_STAGE小子轻车熟路,当然是让他干啦。
输入 schema_name 的值: AWR_STAGE Using the staging schema name: AWR_STAGE Choose the Default tablespace for the AWR_STAGE user ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Choose the AWR_STAGE users's default tablespace. This is the tablespace in which the AWR data will be staged. TABLESPACE_NAME CONTENTS DEFAULT TABLESPACE ------------------------------ --------- ------------------ ARRANGEMENTS PERMANENT STREAM PERMANENT SYSAUX PERMANENT * THAMS PERMANENT USERS PERMANENT Pressing will result in the recommended default tablespace (identified by *) being used. 输入 default_tablespace 的值:
ORACLE列出了数据库里的所有表空间,问你既然你让AWR_STAGE这小子来干这个活,那你给得给他安排个办公场所啊,你选择那个表空间给他用啊?这里我选择了USERS表空间。
输入 default_tablespace 的值: USERS 输入 default_tablespace 的值: USERS Using tablespace USERS as the default tablespace for the AWR_STAGE Choose the Temporary tablespace for the AWR_STAGE user ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Choose the AWR_STAGE user's temporary tablespace. TABLESPACE_NAME CONTENTS DEFAULT TEMP TABLESPACE ------------------------------ --------- ----------------------- TEMP TEMPORARY * Pressing will result in the database's default temporary tablespace (identified by *) being used. 输入 temporary_tablespace 的值:
估计这个工具的设计者是个美国大妈,这么磨叽,ORACLE又把临时表空间列了出来,然后问你,你选择哪个临时表空间给AWR_STAGE用啊?
输入 temporary_tablespace 的值: TEMP Using tablespace TEMP as the temporary tablespace for AWR_STAGE ... Creating AWR_STAGE user | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Loading the AWR data from the following | directory/file: | D:dir | AWR_571-575.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:dir | AWR_571-575.log
在我的强力谴责下,ORACLE终于开始干活啦,首先ORACLE创建AWR_STAGE用户,然后开始加载AWR数据,还给出了日志供参考,如果出现以下2行信息,数据加载完毕。
... Dropping AWR_STAGE user End of AWR Load
加载完成之后ORACLE会删除AWR_STAGE用户,有点卸磨杀驴的感觉,下面摘录部分导入日志。
已成功加载/卸载了主表 "SYS"."SYS_IMPORT_FULL_01" 启动 "SYS"."SYS_IMPORT_FULL_01": 处理对象类型 TABLE_EXPORT/TABLE/TABLE 已完成 128 TABLE 个对象, 用时 5 秒 处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA . . 导入了 "AWR_STAGE"."WRH$_SQL_PLAN" 1.195 MB 3052 行 . . 导入了 "AWR_STAGE"."WRH$_SQLTEXT" 336.3 KB 336 行 . . 导入了 "AWR_STAGE"."WRH$_SYSMETRIC_SUMMARY" 70.41 KB 790 行 . . 导入了 "AWR_STAGE"."WRH$_WAITCLASSMETRIC_HISTORY" 23.61 KB 177 行 . . 导入了 "AWR_STAGE"."WRH$_SYSMETRIC_HISTORY" 187.4 KB 3540 行
看这个日志是不是和数据泵很像啊,其实调用的就是数据泵。