Autonomous Health Framework について(その1) 

## はじめに
Oracle Database には 高可用性を求められるシステムに役立つ情報の収集、診断データの分析に加えて様々な問題に対し、ある程度事前の対応も可能になるフレームワークが準備されています。
これらは Autonomous Health Framework (AHF)としてOracle Database 12c (12.2) から実装されました。現時点ではMOSを介してクラスタ環境のみならず、OCIやシングルインスタンスの構成でも利用が可能です。ここでは、AHF 23.8 をベースに解説します。
## AHFの準備
AHFはGrid Infrastructure に含まれているので、GIのインストール時に導入され稼働しますが、概ね6か月程度で新しいバージョンがリリースされます。常に最新である必要は無いと思いますが、メトリックが増えたり診断基準に改善が加わったりと内容を刷新しているので、特にミッション・クリティカルなシステムにおいては現行バージョンと乖離した古いバージョンを使用している場合は要注意かと思います。

![ahf1_01.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3470713/9945c115-8dce-95bc-f340-e3e4585cc986.png)
Autonomous Health Framework (AHF) - Including TFA and ORAchk/EXAchk (Doc ID 2550798.1)

## AHFの導入から稼働環境の確認
### 1) 既存の環境を削除する
現行の環境を確認し、古いバージョンであれば削除->新規インストールの手順で進めてみます。
```
[root@ahft01 ~]# tfactl status
.----------------------------------------------------------------------------------------------.
| Host   | Status of TFA | PID   | Port | Version    | Build ID             | Inventory Status |
+--------+---------------+-------+------+------------+----------------------+------------------+
| ahft02 | RUNNING       |  2610 | 5000 | 23.4.2.0.0 | 23420020230526182819 | COMPLETE         |
| ahft01 | RUNNING       | 13998 | 5000 | 23.4.2.0.0 | 23420020230526182819 | COMPLETE         |
'--------+---------------+-------+------+------------+----------------------+------------------'
```
```
[root@ahft01 ~]# tfactl uninstall

AHF Uninstallation Log : /tmp/ahf_uninstall_1103_2023_09_04-12_16_30.log
Starting AHF Uninstall
NOTE : Uninstalling will delete the repository as well since Install type is GI
AHF will be uninstalled on: 
ahft01 
Do you want to continue with AHF uninstall ? [Y]|N : Y
```
… 削除ログは割愛
### 2)	AHFの新規インストール (ここではMOSから入手した23.8を使用) 
```
[root@ahft01 AHF23.8]# ./ahf_setup
AHF Installer for Platform Linux Architecture x86_64
AHF Installation Log : /tmp/ahf_install_238000_9341_2023_09_04-12_19_06.log
Starting Autonomous Health Framework (AHF) Installation
AHF Version: 23.8.0 Build Date: 202308300211
Default AHF Location : /opt/oracle.ahf
Do you want to install AHF at [/opt/oracle.ahf] ? [Y]|N : Y
```
⇧Default Directory を受け入れてインストール
```
AHF Location : /opt/oracle.ahf
AHF Data Directory stores diagnostic collections and metadata.
AHF Data Directory requires at least 5GB (Recommended 10GB) of free space.
 
Choose Data Directory from below options : 
 
1. /u01/app/21.0.0/grid_base [Free Space : 48872 MB]
2. Enter a different Location
```
⇧前バージョンで使用していたディレクトリを選択した
```
.........

Do you want to add AHF Notification Email IDs ? [Y]|N : N
```
⇧AHFからのアラートを受付けるEmailの設定が可能
```
AHF will also be installed/upgraded on these Cluster Nodes :
1. ahft02
The AHF Location and AHF Data Directory must exist on the above nodes
AHF Location : /opt/oracle.ahf
AHF Data Directory : /u01/app/21.0.0/grid_base/oracle.ahf/data
Do you want to install/upgrade AHF on Cluster Nodes ? [Y]|N : Y
```
⇧Cluster(2Node RAC)だと、2ノード目も同時にインストールするか選択できる
<中略>
```
Starting TFA Services
.---------------------------------------------------------------------------.
| Host   | Status of TFA | PID   | Port | Version    | Build ID             |
+--------+---------------+-------+------+------------+----------------------+
| ahft02 | RUNNING       |  2610 | 5000 | 23.8.0.0.0 | 23800020230830021106 |
| ahft01 | RUNNING       | 13998 | 5000 | 23.8.0.0.0 | 23800020230830021106 |
'--------+---------------+-------+------+------------+----------------------'
 
Running TFA Inventory...
.-------------------------------------------------------------------------.
|                       Summary of AHF Configuration                      |
+-----------------+-------------------------------------------------------+
| Parameter       | Value                                                 |
+-----------------+-------------------------------------------------------+
| AHF Location    | /opt/oracle.ahf                                       |
| TFA Location    | /opt/oracle.ahf/tfa                                   |
| Orachk Location | /opt/oracle.ahf/orachk                                |
| Data Directory  | /u01/app/21.0.0/grid_base/oracle.ahf/data             |
| Repository      | /u01/app/21.0.0/grid_base/oracle.ahf/data/repository  |
| Diag Directory  | /u01/app/21.0.0/grid_base/oracle.ahf/data/ahft01/diag |
'-----------------+-------------------------------------------------------'
 
Starting ORAchk Scheduler from AHF
Setting up AHF CLI and SDK
AHF install completed on ahft02
Installing AHF on Remote Nodes :
AHF will be installed on ahft01, Please wait.
Please Enter the password for ahft01 :
Is password same for all the nodes? [Y]|N : Y
Installing AHF on ahft01:
[ahft01] Copying AHF Installer
[ahft01] Running AHF Installer	
```
⇧インストール完了と稼働確認
### 3) AHFの主なコマンドと実行サンプル
||コマンド||解説|
|:---|:---|:---|:---|
|<font>${\small 例1}$</font>| tfactl | status|TFA稼働状況の確認|
|<font>${\small 例2}$</font>| tfactl | toolstatus|TFAのツール群についての状況確認|
|<font>${\small 例3}$</font>| tfactl | print config|TFAに関する設定情報|
|<font>${\small 例4}$</font>| tfactl | print syncstatus|TFAの同期ステータスを取得|
|<font>${\small 例5}$</font>| ahfctl | showrepo|AHFリポジトリ確認 -tfactl print repositoryと同じ|
|<font>${\small 例6}$</font>| tfactl | print directories|各ツールの使用ディレクトリ表示|

使用方法: ahfctl [command] [options]
※	移行中のためか、ftactl と ahfctl が混在している
例1: tfactl status
```
[root@ ahft01 ~]# tfactl status
.----------------------------------------------------------------------------------------------.
| Host   | Status of TFA | PID   | Port | Version    | Build ID             | Inventory Status |
+--------+---------------+-------+------+------------+----------------------+------------------+
| ahft01 | RUNNING       | 13998 | 5000 | 23.8.0.0.0 | 23800020230830021106 | COMPLETE         |
| ahft02 | RUNNING       |  2610 | 5000 | 23.8.0.0.0 | 23800020230830021106 | COMPLETE         |
'--------+---------------+-------+------+------------+----------------------+------------------'
```
例2: tfactl toolstatus
```
[root@ ahft01 ~]# tfactl toolstatus
Running command tfactltoolstatus on ahft02 ...
.------------------------------------------------------------------.
|                   TOOLS STATUS - HOST : ahft02                    |
+----------------------+--------------+--------------+-------------+
| Tool Type            | Tool         | Version      | Status      |
+----------------------+--------------+--------------+-------------+
| AHF Utilities        | alertsummary |       23.8.0 | DEPLOYED    |
|                      | calog        |       23.8.0 | DEPLOYED    |
|                      | dbglevel     |       23.8.0 | DEPLOYED    |
|                      | grep         |       23.8.0 | DEPLOYED    |
|                      | history      |       23.8.0 | DEPLOYED    |
|                      | ls           |       23.8.0 | DEPLOYED    |
|                      | managelogs   |       23.8.0 | DEPLOYED    |
|                      | menu         |       23.8.0 | DEPLOYED    |
|                      | param        |       23.8.0 | DEPLOYED    |
|                      | ps           |       23.8.0 | DEPLOYED    |
|                      | pstack       |       23.8.0 | DEPLOYED    |
|                      | summary      |       23.8.0 | DEPLOYED    |
|                      | tail         |       23.8.0 | DEPLOYED    |
|                      | triage       |       23.8.0 | DEPLOYED    |
|                      | vi           |       23.8.0 | DEPLOYED    |
+----------------------+--------------+--------------+-------------+
| Development Tools    | oratop       |       14.1.2 | DEPLOYED    |
+----------------------+--------------+--------------+-------------+
| Support Tools Bundle | darda        | 2.10.0.R6036 | DEPLOYED    |
|                      | oswbb        | 22.1.0AHF    | RUNNING     |
|                      | prw          | 12.1.13.11.4 | NOT RUNNING |
'----------------------+--------------+--------------+-------------'
 Note :-
  DEPLOYED    : Installed and Available - To be configured or run interactively.
  NOT RUNNING : Configured and Available - Currently turned off interactively.
  RUNNING     : Configured and Available.
.------------------------------------------------------------------.
|                   TOOLS STATUS - HOST : ahft01                    |
+----------------------+--------------+--------------+-------------+
| Tool Type            | Tool         | Version      | Status      |
+----------------------+--------------+--------------+-------------+
| AHF Utilities        | alertsummary |       23.8.0 | DEPLOYED    |
|                      | calog        |       23.8.0 | DEPLOYED    |
|                      | dbglevel     |       23.8.0 | DEPLOYED    |
|                      | grep         |       23.8.0 | DEPLOYED    |
|                      | history      |       23.8.0 | DEPLOYED    |
|                      | ls           |       23.8.0 | DEPLOYED    |
|                      | managelogs   |       23.8.0 | DEPLOYED    |
|                      | menu         |       23.8.0 | DEPLOYED    |
|                      | param        |       23.8.0 | DEPLOYED    |
|                      | ps           |       23.8.0 | DEPLOYED    |
|                      | pstack       |       23.8.0 | DEPLOYED    |
|                      | summary      |       23.8.0 | DEPLOYED    |
|                      | tail         |       23.8.0 | DEPLOYED    |
|                      | triage       |       23.8.0 | DEPLOYED    |
|                      | vi           |       23.8.0 | DEPLOYED    |
+----------------------+--------------+--------------+-------------+
| Development Tools    | oratop       |       14.1.2 | DEPLOYED    |
+----------------------+--------------+--------------+-------------+
| Support Tools Bundle | darda        | 2.10.0.R6036 | DEPLOYED    |
|                      | oswbb        | 22.1.0AHF    | RUNNING     |
|                      | prw          | 12.1.13.11.4 | NOT RUNNING |
'----------------------+--------------+--------------+-------------'
Note :-
  DEPLOYED    : Installed and Available - To be configured or run interactively.
  NOT RUNNING : Configured and Available - Currently turned off interactively.
  RUNNING     : Configured and Available.
```
クラスタの場合、構成される全ノードで toolのステータスが表示される
例3: tfactl print config
```
[root@ ahft01 ~]# tfactl print config
.-------------------------------------------------------------------------------------.
|                                            ahft01                                   |
+------------------------------------------------------------------------+------------+
| Configuration Parameter                                                | Value      |
+------------------------------------------------------------------------+------------+
| TFA Version ( tfaversion )                                             | 23.8.0.0.0 |
| Java Version ( javaVersion )                                           | 11.0       |
| Public IP Network ( publicIp )                                         | true       |
| Repository current size (MB) ( currentsizemegabytes )                  | 16         |
| Repository maximum size (MB) ( maxsizemegabytes )                      | 10240      |
| Enables the execution of sqls throught SQL Agent process ( sqlAgent )  | ON         |
| Cluster Event Monitor ( clustereventmonitor )                          | ON         |
| scanacfslog                                                            | OFF        |

一部を編集して表示、および大きく割愛　… 

| language                                                               | en         |
| isaModeg                                                               | enabled    |
+------------------------------------------------------------------------+------------+
```
mem.free
minPossibleSpaceForPurge
mem.swapfree  
などなど、AHF(TFA)が稼働するための詳細な設定を確認する事ができる
(コマンドなどで変更可なものもあり、実行環境に合わせて負荷やインフラに適合できる)

例4: tfactl print syncstatu
```
[root@ahft01 ~]# tfactl print syncstatus
SYNC MESSAGE : TFA Synced on all Cluster Nodes
.----------------------.
| Node   | Sync Status |
+--------+-------------+
| ahft01 | SYNCED      |
| ahft02 | SYNCED      |
'--------+-------------'
```
例5: ahfctl showrepo
```
.-----------------------------------------------------------------------------.
|                                    ahft02                                   |
+----------------------+------------------------------------------------------+
| Repository Parameter | Value                                                |
+----------------------+------------------------------------------------------+
| Location             | /u01/app/21.0.0/grid_base/oracle.ahf/data/repository |
| Maximum Size (MB)    | 10240                                                |
| Current Size (MB)    | 2                                                    |
| Free Size (MB)       | 10238                                                |
| Status               | OPEN                                                 |
'----------------------+------------------------------------------------------'
 .-----------------------------------------------------------------------------.
|                                    ahft01                                   |
+----------------------+------------------------------------------------------+
| Repository Parameter | Value                                                |
+----------------------+------------------------------------------------------+
| Location             | /u01/app/21.0.0/grid_base/oracle.ahf/data/repository |
| Maximum Size (MB)    | 10240                                                |
| Current Size (MB)    | 6                                                    |
| Free Size (MB)       | 10234                                                |
| Status               | OPEN                                                 |
'----------------------+------------------------------------------------------'
```
例6: tfactl print directories
```
.--------------------------------------------------------------------------------------.
|                                    ahft01                                            |
+------------------------------------+-------------------------+------------+----------+
| Trace Directory                    | Component               | Permission | Added By |
+------------------------------------+-------------------------+------------+----------+
| /etc/oracle                        | [CRS]                   | public     | root     |
| Collection policy : Exclusions     |                         |            |          |
+------------------------------------+-------------------------+------------+----------+
| /u01/app/21.0.0/grid/cfgtoollogs   | [CFGTOOLS, ODAPATCHING] | public     | root     |
| Collection policy : Exclusions     |                         |            |          |
+------------------------------------+-------------------------+------------+----------+
| /u01/app/21.0.0/grid/install       | [INSTALL]               | public     | root     |
| Collection policy : Exclusions     |                         |            |          |
+------------------------------------+-------------------------+------------+----------+
※ 一部編集および割愛　… 
```
## 最後に
AHF について(その1)としてセットアップの手順のおよび、導入後の環境確認を一般的なコマンドと実行例という形で確認してきました。AHFは多くの機能の集合体であり、かつ日々改良・改善されているため統一性が薄い印象を受けますが、全体的には整う方向で進化しています。
その２以降で、有益な収集・診断などに触れていく予定です。