溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

AWR 導(dǎo)出/導(dǎo)入/生成報(bào)告

發(fā)布時(shí)間:2020-08-12 10:51:11 來源:ITPUB博客 閱讀:168 作者:不一樣的天空w 欄目:關(guān)系型數(shù)據(jù)庫
      客戶的生產(chǎn)系統(tǒng)總是那么重要,一般不會(huì)讓你長時(shí)間的在他們的生產(chǎn)機(jī)器上做操作,但是分析和生成AWR報(bào)告都是一個(gè)相對(duì)耗時(shí)的工作,當(dāng)然只生成一個(gè)AWR報(bào)告是不費(fèi)時(shí)的,但是要對(duì)系統(tǒng)進(jìn)行詳細(xì)分析的時(shí)候,我們可能需要的是一段時(shí)間內(nèi)的所有AWR數(shù)據(jù),需要根據(jù)實(shí)際情況進(jìn)行選取。這時(shí)我們就需要將客戶的AWR數(shù)據(jù)導(dǎo)出,然后進(jìn)行分析,這個(gè)操作主要涉及AWR數(shù)據(jù)導(dǎo)出、導(dǎo)入和生成報(bào)告三個(gè)階段,下面對(duì)每個(gè)步驟進(jìn)行詳細(xì)描述。
     1、導(dǎo)出

  1. SQL> @?/rdbms/admin/awrextr.sql
  2. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. Disclaimer: This SQL/Plus script should only be called under
  5. the guidance of Oracle Support.
  6. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  8. ~~~~~~~~~~~~~
  9. AWR EXTRACT
  10. ~~~~~~~~~~~~~
  11. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. ~ This script will extract the AWR data for a range of snapshots ~
  13. ~ into a dump file. The script will prompt users for the     ~
  14. ~ following information:                     ~
  15. ~ (1) database id                         ~
  16. ~ (2) snapshot range to extract                 ~
  17. ~ (3) name of directory object                 ~
  18. ~ (4) name of dump file                     ~
  19. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  20. Databases in this Workload Repository schema
  21. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  22.    DB Id DB Name     Host
  23. ------------ ------------ ------------
  24. * 2182516689 GYL     rac01
  25. * 2182516689 GYL     rac02

  26. The default database id is the local one: '2182516689'. To use this
  27. database id, press <return> to continue, otherwise enter an alternative.

  28. Enter value for dbid: 2182516689        <<<<<<<輸入DBID

  29. Using 2182516689 for Database ID


  30. Specify the number of days of snapshots to choose from
  31. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  32. Entering the number of days (n) will result in the most recent
  33. (n) days of snapshots being listed. Pressing <return> without
  34. specifying a number lists all completed snapshots.


  35. Enter value for num_days: 7                  <<<<<<<輸入需要導(dǎo)出數(shù)據(jù)的天數(shù)

  36. Listing the last 7 days of Completed Snapshots

  37. DB Name Snap Id     Snap Started
  38. ------------ --------- ------------------
  39. GYL         37 07 Nov 2014 10:05
  40.          38 07 Nov 2014 11:00
  41.          39 07 Nov 2014 12:00
  42.          40 07 Nov 2014 13:00
  43.          41 07 Nov 2014 14:00
  44.          42 07 Nov 2014 15:00
  45.          43 07 Nov 2014 16:00
  46.          44 10 Nov 2014 13:51
  47.          45 10 Nov 2014 15:00
  48.          46 10 Nov 2014 16:00
  49.          47 12 Nov 2014 14:11

  50. DB Name Snap Id     Snap Started
  51. ------------ --------- ------------------
  52. GYL         48 12 Nov 2014 14:37
  53.          49 12 Nov 2014 16:00
  54.          50 12 Nov 2014 17:00
  55.          51 12 Nov 2014 18:00
  56.          52 13 Nov 2014 10:16
  57.          53 13 Nov 2014 11:00
  58.          54 13 Nov 2014 12:00
  59.          55 13 Nov 2014 13:00
  60.          56 13 Nov 2014 14:00
  61.          57 13 Nov 2014 16:21


  62. Specify the Begin and End Snapshot Ids
  63. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  64. Enter value for begin_snap: 52            <<<<<<< 輸入起始snap_id
  65. Begin Snapshot Id specified: 52           

  66. Enter value for end_snap: 57              <<<<<<< 輸入結(jié)束snap_id
  67. End Snapshot Id specified: 57


  68. Specify the Directory Name
  69. ~~~~~~~~~~~~~~~~~~~~~~~~~~

  70. Directory Name         Directory Path
  71. ------------------------------ -------------------------------------------------
  72. DATA_PUMP_DIR         /oracle/app/oracle/product/10.2/db_1/rdbms/log/
  73. ORACLE_OCM_CONFIG_DIR     /oracle/app/oracle/product/10.2/db_1/ccr/state

  74. Choose a Directory Name from the above list (case-sensitive).

  75. Enter value for directory_name: DATA_PUMP_DIR

  76. Using the dump directory: DATA_PUMP_DIR             <<<<<<< 指定一個(gè)存放導(dǎo)出數(shù)據(jù)的directory(如果沒有需要自己建立一個(gè)directory)

  77. Specify the Name of the Extract Dump File
  78. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  79. The prefix for the default dump file name is awrdat_52_57.
  80. To use this name, press <return> to continue, otherwise enter
  81. an alternative.

  82. Enter value for file_name: gyl_rac01

  83. ...........省略部分輸出.............
  84. Master table \"SYS\".\"SYS_EXPORT_TABLE_01\" successfully loaded/unloaded
  85. ******************************************************************************
  86. Dump file set for SYS.SYS_EXPORT_TABLE_01 is:
  87. /oracle/app/oracle/product/10.2/db_1/rdbms/log/gyl_rac01.dmp
  88. Job \"SYS\".\"SYS_EXPORT_TABLE_01\" successfully completed at 12:38:07
        2、導(dǎo)入
       先將上面生成的dump文件拷貝到目標(biāo)機(jī)器的一個(gè)directory下,然后按如下操作進(jìn)行導(dǎo)入。

  1. SQL> @$ORACLE_HOME/rdbms/admin/awrload.sql
  2. ~~~~~~~~~~
  3. AWR LOAD
  4. ~~~~~~~~~~
  5. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. ~ This script will load the AWR data from a dump file. The ~
  7. ~ script will prompt users for the following information: ~
  8. ~ (1) name of directory object             ~
  9. ~ (2) name of dump file                 ~
  10. ~ (3) staging schema name to load AWR data into     ~
  11. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  12. Specify the Directory Name
  13. ~~~~~~~~~~~~~~~~~~~~~~~~~~

  14. Directory Name         Directory Path
  15. ------------------------------ -------------------------------------------------
  16. DATA_FILE_DIR         /oracle/app/oracle/product/11.2.0/db_1/demo/schem
  17.              a/sales_history/

  18. DATA_PUMP_DIR         /oracle/app/oracle/admin/gyl/dpdump/
  19. LOG_FILE_DIR         /oracle/app/oracle/product/11.2.0/db_1/demo/schem
  20.              a/log/

  21. MEDIA_DIR         /oracle/app/oracle/product/11.2.0/db_1/demo/schem
  22.              a/product_media/

  23. ORACLE_OCM_CONFIG_DIR     /oracle/app/oracle/product/11.2.0/db_1/ccr/state

  24. Directory Name         Directory Path
  25. ------------------------------ -------------------------------------------------
  26. SS_OE_XMLDIR         /oracle/app/oracle/product/11.2.0/db_1/demo/schem
  27.              a/order_entry/

  28. SUBDIR             /oracle/app/oracle/product/11.2.0/db_1/demo/schem
  29.              a/order_entry//2002/Sep

  30. XMLDIR             /oracle/app/oracle/product/11.2.0/db_1/rdbms/xml

  31. Choose a Directory Name from the list above (case-sensitive).

  32. Enter value for directory_name: DATA_PUMP_DIR           <<<<<<< 輸入dump所在directory

  33. Using the dump directory: DATA_PUMP_DIR

  34. Specify the Name of the Dump File to Load
  35. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  36. Please specify the prefix of the dump file (.dmp) to load:

  37. Enter value for file_name: gyl_rac01                  <<<<<<< 輸入dump文件名,不要帶后綴

  38. Loading from the file name: gyl_rac01.dmp

  39. Staging Schema to Load AWR Snapshot Data
  40. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  41. The next step is to create the staging schema
  42. where the AWR snapshot data will be loaded.
  43. After loading the data into the staging schema,
  44. the data will be transferred into the AWR tables
  45. in the SYS schema.


  46. The default staging schema name is AWR_STAGE.
  47. To use this name, press <return> to continue, otherwise enter
  48. an alternative.

  49. Enter value for schema_name: AWR_STAGE          <<<<<<< 輸入一個(gè)schema名,用于導(dǎo)入,導(dǎo)入結(jié)束后自動(dòng)會(huì)刪除該schema

  50. Using the staging schema name: AWR_STAGE

  51. Choose the Default tablespace for the AWR_STAGE user
  52. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  53. Choose the AWR_STAGE users's default tablespace. This is the
  54. tablespace in which the AWR data will be staged.

  55. TABLESPACE_NAME      CONTENTS DEFAULT TABLESPACE
  56. ------------------------------ --------- ------------------
  57. EXAMPLE          PERMANENT
  58. SYSAUX             PERMANENT *
  59. TEST             PERMANENT
  60. USERS             PERMANENT

  61. Pressing <return> will result in the recommended default
  62. tablespace (identified by *) being used.

  63. Enter value for default_tablespace: SYSAUX           <<<<<<< 輸入存放AWR數(shù)據(jù)的表空間名

  64. Using tablespace SYSAUX as the default tablespace for the AWR_STAGE


  65. Choose the Temporary tablespace for the AWR_STAGE user
  66. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  67. Choose the AWR_STAGE user\'s temporary tablespace.

  68. TABLESPACE_NAME      CONTENTS DEFAULT TEMP TABLESPACE
  69. ------------------------------ --------- -----------------------
  70. TEMP             TEMPORARY *

  71. Pressing <return> will result in the database\
       3、生成報(bào)告
      在目標(biāo)機(jī)器上生成報(bào)告

  1. SQL> @?/rdbms/admin/awrrpti.sql

  2. Specify the Report Type
  3. ~~~~~~~~~~~~~~~~~~~~~~~
  4. Would you like an HTML report, or a plain text report?
  5. Enter 'html' for an HTML report, or 'text' for plain text
  6. Defaults to 'html'
  7. Enter value for report_type: html

  8. Type Specified: html


  9. Instances in this Workload Repository schema
  10. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  11.    DB Id     Inst Num DB Name     Instance    Host
  12. ------------ -------- ------------ ------------ ------------
  13. * 2184766987     1 GYL     gyl        oracle11g
  14.   2182516689     2 GYL     gyl2       rac02
  15.   2182516689     1 GYL     gyl1       rac01

  16. Enter value for dbid: 2182516689            <<<<<<< 輸入dbid
  17. Using 2182516689 for database Id
  18. Enter value for inst_num: 1                 <<<<<<< 輸入inst_num號(hào)
  19. Using 1 for instance number


  20. Specify the number of days of snapshots to choose from
  21. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  22. Entering the number of days (n) will result in the most recent
  23. (n) days of snapshots being listed. Pressing <return> without
  24. specifying a number lists all completed snapshots.


  25. Enter value for num_days: 2                <<<<<<< 輸入生成報(bào)告的天數(shù)  

  26. Listing the last 2 days of Completed Snapshots

  27.                             Snap
  28. Instance DB Name     Snap Id Snap Started Level
  29. ------------ ------------ --------- ------------------ -----
  30. gyl1     GYL         52 13 Nov 2014 10:16     1
  31.                  53 13 Nov 2014 11:00     1
  32.                  54 13 Nov 2014 12:00     1
  33.                  55 13 Nov 2014 13:00     1
  34.                  56 13 Nov 2014 14:00     1

  35.                  57 13 Nov 2014 16:21     1



  36. Specify the Begin and End Snapshot Ids
  37. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. Enter value for begin_snap: 52                <<<<<<< 輸入起始snap_id
  39. Begin Snapshot Id specified: 52

  40. Enter value for end_snap: 56                  <<<<<<< 輸入結(jié)束snap_id
  41. End Snapshot Id specified: 56



  42. Specify the Report Name
  43. ~~~~~~~~~~~~~~~~~~~~~~~
  44. The default report file name is awrrpt_1_52_56.html. To use this name,
  45. press <return> to continue, otherwise enter an alternative.

  46. Enter value for report_name: /oracle/app/oracle/admin/gyl/dpdump/awr_rac.html
       整個(gè)過程都很簡(jiǎn)單,但有幾點(diǎn)需要注意:
      1、不能將同一個(gè)數(shù)據(jù)庫的AWR數(shù)據(jù)導(dǎo)出后再導(dǎo)入到自己,這樣會(huì)遇到下面的錯(cuò)誤
            ERROR at line 1:
             ORA-20105: unable to move AWR data to SYS
             ORA-06512: at "SYS.DBMS_SWRF_INTERNAL", line 2950
             ORA-20107: not allowed to move AWR data for local dbid
             ORA-06512: at line 3
       2、在導(dǎo)入的時(shí)候,在輸入值時(shí),盡量用大寫;
       3、如果不再需要的數(shù)據(jù),可以用如下存儲(chǔ)過程刪除:
            SQL> exec DBMS_SWRF_INTERNAL.UNREGISTER_DATABASE(bdid);     --將dbid換成需要?jiǎng)h除的dbid號(hào)



向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI