LoginSignup
0
0

More than 1 year has passed since last update.

AWRデータの移動を試す(Oracle Database 19c)

Posted at

AWRとは

AWR (Automatic Workload Repository) は Oracle Database Enterprise Edition の機能です。Oracle Database データベース上で発生した負荷情報を定期的に保存(スナップショット)します。2つのスナップショットを比較することでスナップショット間で発生した負荷情報をレポートに出力できます(AWRレポート)。AWR はデータベース内に自動的に保存されますが、AWRレポートの作成やデータベースの分析を外部で行いたい場合にはAWR情報そのものをエクスポートすることができます。本記事ではAWR情報のエクスポート/インポート手順を解説しています。AWRの実態は WRH$_ からはじまる名前を持つテーブルです。

AWRのエクスポート

AWRのデータをエクスポートするには移行対象データベースに管理者権限で接続し、${ORACLE_HOME}/rdbms/admin/awrextr.sql スクリプトを実行します。このスクリプトは実際には内部で DBMS_WORKLOAD_REPOSITORY.EXTRACT プロシージャのラッパーになっています。以下の例は Real Application Clusters (RAC) 環境で実行しています。RAC 環境のため、同一データベース名(同一DBID)が複数表示されています。

awrextr.sql を実行すると以下の項目に入力する必要があります。

プロンプト 入力項目
dbidに値を入力してください 一覧表示後にエクスポート対象DBIDを指定
num_daysに値を入力してください スナップショット一覧表示日数
begin_snapに値を入力してください 一覧表示後に移行対象の開始スナップショット
end_snapに値を入力してください 移行対象の終了スナップショット
directory_nameに値を入力してください 一覧表示後にData Pumpで利用するDIRECTORYオブジェクト
file_nameに値を入力してください Data Pumpダンプファイル名プレフィックス
SQL> @?/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
------------ ------------ ------------
* 377954733  O19A         rel87-1
* 377954733  O19A         rel87-2

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

dbidに値を入力してください: 377954733

Using 377954733 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.

num_daysに値を入力してください: 1

Listing the last day's Completed Snapshots

DB Name        Snap Id    Snap Started
------------ --------- ------------------
O19A              1617 05 12月 2022 08:10
                  1618 05 12月 2022 09:00
                  1619 05 12月 2022 10:00

Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
begin_snapに値を入力してください: 1617
Begin Snapshot Id specified: 1617

end_snapに値を入力してください: 1619
End   Snapshot Id specified: 1619

Specify the Directory Name
~~~~~~~~~~~~~~~~~~~~~~~~~~

Directory Name                 Directory Path
------------------------------ ---------------------------------------------------------
DATA_PUMP_DIR                  /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/log/
DBMS_OPTIM_ADMINDIR            /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/admin
DBMS_OPTIM_LOGDIR              /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs
JAVA$JOX$CUJS$DIRECTORY$       /u01/app/oracle/product/19.0.0/dbhome_1/javavm/admin
OPATCH_INST_DIR                /u01/app/oracle/product/19.0.0/dbhome_1/OPatch
OPATCH_LOG_DIR                 /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/log
OPATCH_SCRIPT_DIR              /u01/app/oracle/product/19.0.0/dbhome_1/QOpatch
ORACLE_BASE                    /u01/app/oracle
ORACLE_HOME                    /u01/app/oracle/product/19.0.0/dbhome_1
ORACLE_OCM_CONFIG_DIR          /u01/app/oracle/product/19.0.0/dbhome_1/ccr/state
ORACLE_OCM_CONFIG_DIR2         /u01/app/oracle/product/19.0.0/dbhome_1/ccr/state
SDO_DIR_ADMIN                  /u01/app/oracle/product/19.0.0/dbhome_1/md/admin
SDO_DIR_WORK
XMLDIR                         /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/xml
XSDDIR                         /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/xml/schema

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

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_1617_1619.
To use this name, press <return> to continue, otherwise enter
an alternative.

file_nameに値を入力してください:

Using the dump file prefix: awrdat_1617_1619
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|  The AWR extract dump file will be located
|  in the following directory/file:
|   /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/log/
|   awrdat_1617_1619.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/product/19.0.0/dbhome_1/rdbms/log/
|   awrdat_1617_1619.log
|

End of AWR Extract
SQL>

エクスポート結果は DIRECTORY オブジェクト内にダンプファイル名と同じ名前で拡張子が .log となっているファイルが作成されます。

AWRのインポート

エクスポートしたダンプファイルを別のデータベースに移動し、インポートを行います。インポートを行うには管理者権限でインポート先データベースに接続し、${ORACLE_HOME}/rdbms/admin/awrload.sql スクリプトを実行します。このスクリプトは内部でDBMS_WORKLOAD_REPOSITORY.AWR_IMPプロシージャをコールしています。

awrload.sql を実行すると以下の項目に入力する必要があります。

プロンプト 入力項目
directory_nameに値を入力してください Data Pumpで利用するDIRECTORYオブジェクト
file_nameに値を入力してください Data Pumpダンプファイル名プレフィックス(拡張子の前まで)
SQL> @?/rdbms/admin/awrload.sql
~~~~~~~~~~
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                                   ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Specify the Directory Name
~~~~~~~~~~~~~~~~~~~~~~~~~~

Directory Name                 Directory Path
------------------------------ ----------------------------------------------------------
DATA_PUMP_DIR                  /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/log/
DBMS_OPTIM_ADMINDIR            /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/admin
DBMS_OPTIM_LOGDIR              /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs
JAVA$JOX$CUJS$DIRECTORY$       /u01/app/oracle/product/19.0.0/dbhome_1/javavm/admin/
OPATCH_INST_DIR                /u01/app/oracle/product/19.0.0/dbhome_1/OPatch
OPATCH_LOG_DIR                 /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/log
OPATCH_SCRIPT_DIR              /u01/app/oracle/product/19.0.0/dbhome_1/QOpatch
ORACLE_BASE                    /u01/app/oracle
ORACLE_HOME                    /u01/app/oracle/product/19.0.0/dbhome_1
ORACLE_OCM_CONFIG_DIR          /u01/app/oracle/product/19.0.0/dbhome_1/ccr/state
ORACLE_OCM_CONFIG_DIR2         /u01/app/oracle/product/19.0.0/dbhome_1/ccr/state
SDO_DIR_ADMIN                  /u01/app/oracle/product/19.0.0/dbhome_1/md/admin
SDO_DIR_WORK
XMLDIR                         /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/xml
XSDDIR                         /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/xml/schema

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

directory_nameに値を入力してください: DATA_PUMP_DIR

Using the dump directory: DATA_PUMP_DIR

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

file_nameに値を入力してください: awrdat_1617_1619

Loading from the file name: awrdat_1617_1619.dmp

|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|  Loading the AWR data from the following
|  directory/file:
|   /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/log/
|   awrdat_1617_1619.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:
|   /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/log/
|   awrdat_1617_1619.log
|

End of AWR Load
SQL>

インポート結果は DIRECTORY オブジェクト内にダンプファイル名と同じ名前で拡張子が .log となっているファイルが作成されます。

AWRレポートの作成

AWRインポート後のAWRレポート作成手順は通常と変わりません。${ORACLE_HOME}/rdbms/admin/awrrpti.sql スクリプト等を実行すると、自データベース以外にインポートしたデータベースの情報が一覧で表示されます。インポートしたデータベースのDBIDを指定することでAWRレポートを生成できます。下記の例は自データベース(DBID=3008402508)とインポートしたデータベース(DBID=377954733)が表示され、インポートしたデータベースからAWRレポートを生成しています。

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

Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
AWR reports can be generated in the following formats.  Please enter the
name of the format at the prompt. Default value is 'html'.

   'html'          HTML format (default)
   'text'          Text format
   'active-html'   Includes Performance Hub active report

report_typeに値を入力してください: html

Type Specified: html

Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  DB Id      Inst Num   DB Name      Instance     Host
------------ ---------- ---------    ----------   ------
  3008402508     2      O19B         O19B2        rel87-3
  377954733      1      O19A         O19A1        rel87-1
  377954733      2      O19A         O19A2        rel87-2
* 3008402508     1      O19B         O19B1        rel87-4

dbidに値を入力してください: 377954733
Using 377954733 for database Id
inst_numに値を入力してください: 1
Using 1 for instance number

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.

num_daysに値を入力してください: 1

Listing the last day's Completed Snapshots
Instance     DB Name      Snap Id       Snap Started    Snap Level
------------ ------------ ---------- ------------------ ----------

O19A1        O19A              1617  05 12月 2022 08:10   1
                               1618  05 12月 2022 09:00   1
                               1619  05 12月 2022 10:00   1

Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
begin_snapに値を入力してください: 1617
Begin Snapshot Id specified: 1617

end_snapに値を入力してください: 1618
End   Snapshot Id specified: 1618

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

report_nameに値を入力してください:

Using the report name awrrpt_1_1617_1618.html
...

<p />
End of Report
</body></html>

Report written to awrrpt_1_1617_1618
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0