问题描述:有一个问题,有同事在查询awr报告收集策略的时候,发现有两个库的策略,一套自己的,另一套已经找不到属于谁了,那么究竟是什么情景会出现这样的场景呢?
1.一开始网上找解答也没有得到解决,询问技术群和同事得到了两种解答,得到了两种比较靠谱的答案。一种是怀疑这个库之前导入过AWR报告;一种是说这个库之前做过不完全恢复,导致遗留了两种不通的DBID
2.测试了导入导出AWR报告的方式,将一个库的AWR报告导入到另一个库中,测试中使用的是11g到19c的环境
导出AWR:@$ORACLE_HOME/rdbms/admin/awrextr.sql
导入AWR:@$ORACLE_HOME/rdbms/admin/awrload.sql
3.11g导出AWR报告:
SQL> @$ORACLE_HOME/rdbms/admin/awrextr.sql ~~~~~~~~~~~~~ AWR EXTRACT ~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ This script will extract the AWR data for a range of snapshots ~ ~ into a dump file. The script will prompt users for the ~ ~ following information: ~ ~ (1) database id ~ ~ (2) snapshot range to extract ~ ~ (3) name of directory object ~ ~ (4) name of dump file ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Databases in this Workload Repository schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DB Id DB Name Host ------------ ------------ ------------ * 459838110 PROD orcl The default database id is the local one: ' 459838110'. To use this database id, press <return> to continue, otherwise enter an alternative. Enter value for dbid: 459838110 Using 459838110 for Database ID Specify the number of days of snapshots to choose from ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Entering the number of days (n) will result in the most recent (n) days of snapshots being listed. Pressing <return> without specifying a number lists all completed snapshots. Enter value for num_days: 10 Listing the last 10 days of Completed Snapshots DB Name Snap Id Snap Started ------------ --------- ------------------ PROD 141 03 Jun 2021 15:16 142 03 Jun 2021 16:00 143 11 Jun 2021 11:15 144 11 Jun 2021 12:06 Specify the Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter value for begin_snap: 141 Begin Snapshot Id specified: 141 Enter value for end_snap: 144 End Snapshot Id specified: 144 Specify the Directory Name ~~~~~~~~~~~~~~~~~~~~~~~~~~ Directory Name Directory Path ------------------------------ ------------------------------------------------- DATA_FILE_DIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/sche ma/sales_history/ DATA_PUMP_DIR /u01/app/oracle/admin/PROD/dpdump/ GGS_DDL_TRACE /u01/app/oracle/diag/rdbms/prod/PROD/trace LOG_FILE_DIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/sche ma/log/ MEDIA_DIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/sche ma/product_media/ Directory Name Directory Path ------------------------------ ------------------------------------------------- ORACLE_OCM_CONFIG_DIR /u01/app/oracle/product/11.2.0/dbhome_1/ccr/hosts /orcl/state ORACLE_OCM_CONFIG_DIR2 /u01/app/oracle/product/11.2.0/dbhome_1/ccr/state SS_OE_XMLDIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/sche ma/order_entry/ SUBDIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/sche ma/order_entry//2002/Sep XMLDIR /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/xml Choose a Directory Name from the above list (case-sensitive). Enter value for directory_name: DATA_PUMP_DIR Using the dump directory: DATA_PUMP_DIR Specify the Name of the Extract Dump File ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The prefix for the default dump file name is awrdat_141_144. To use this name, press <return> to continue, otherwise enter an alternative. 这里schema名称必须是oracle数据库中不存在的,不然会异常退出,必须是两个数据库之间没有的schema名字 Enter value for file_name: AWREXPIMP Using the dump file prefix: AWREXPIMP | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | The AWR extract dump file will be located | in the following directory/file: | /u01/app/oracle/admin/PROD/dpdump/ | AWREXPIMP.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/app/oracle/admin/PROD/dpdump/ | AWREXPIMP.log | Channel(Socket) closed from remote host(ks) at 12:29:37.