天天看點

Oracle常用工具使用-ORAchk

ORAchk 之前被稱為RACcheck,後來它的用途進行了擴充,改名為了ORAchk,它是在資料庫系統進行健康檢查的一個專用工具,這個工具主要用來檢查軟體的配置是否符合要求以及一些最佳實踐是否被應用了。通過這個工具,使用者可以很友善地、自動化地對自己的系統進行健康檢查和評估。

ORAchk 能夠檢查的軟體主要有:OS、Oracle Clusterware (CRS)、 Grid Infrastructure environment(GI)、Automatic Storage Management (ASM)以及Real Application Clusters (RAC)、單執行個體資料庫、Golden Gate。ORAchk更多資訊可參考MOS文檔1268927.2

Oracle ORAchk支援的平台

以下平台支援Oracle ORAchk:

  • Intel Linux* (Oracle Linux/RedHat 4, 5, 6, 7 and SuSE 9, 10, 11, 12)
  • Linux on System Z (RedHat 6, 7 and SuSE 12)
  • Oracle Solaris SPARC (Solaris 9, 10, and 11)
  • Oracle Solaris x86-64 (Solaris 9, 10, and 11)
  • AIX
  • HPUX
  • Microsoft Windows (2008 and 2012)

*不支援Linux Itanium

*在32位EBS環境中僅支援32位平台使用指令./orachk -ebs32bit

1.1. 安裝1. ORAchk

1.1.1. 單執行個體安裝ORAchk

[root@host1 /]# mkdir /orachk
[root@host1 /]# cd /orachk/
[root@host1 orachk]# unzip orachk.zip
[root@host1 /]# chown -R oracle:oinstall /orachk
[root@host1 orachk]# chmod 755 orachk           

1.1.2. RAC安裝ORAchk

[root@rac2 ~]# mkdir /orachk
[root@rac2 ~]# cd /orachk/
[root@rac2 orachk]# unzip orachk.zip
[root@rac2 orachk]# chmod 755 orachk           

1.2. 解除安裝Oracle ORAchk

1)停止所有活動的Oracle ORAchk daemon用戶端

[root@rac2 orachk]# ./orachk -d stop_client           

2)停止任何正在運作的Oracle ORAchk daemon

[root@rac2 orachk]# ./orachk -d stop           

3)從自動重新啟動配置中删除Oracle ORAchk daemon

[root@rac2 orachk]# ./orachk -initrmsetup           

4)删除Oracle ORAchk安裝目錄

[root@rac2 orachk]# rm -rf /orachk/           

1.3. 更新ORAchk

每個資料庫PSU都包含建立時可用的最新Oracle ORAchk版本。應用資料庫PSU時,包含的ORAchk将在$ORACLE_HOME/suptools中暫存。

在下次運作時,如果PSU複制的版本比安裝的版本新,則Oracle ORAchk會提示進行更新。

1.3.1. 單執行個體更新ORAchk

MOS文檔1268927.2下載下傳最新的ORAchk

1)更新前檢查

[oracle@host1 orachk]$ pwd
/u01/app/oracle/product/18.1.0/dbhome_1/suptools/orachk
[oracle@host1 orachk]$./orachk -u -o pre           

2)檢視目前版本

[oracle@host1 orachk]$ ./orachk -v
ORACHK VERSION: 12.2.0.1.4_20171127           

3)更新

将環境變量RAT_UPGRADE_LOC設定下載下傳的ORAchk壓縮包存放的目錄。

[oracle@host1 orachk]$ export RAT_UPGRADE_LOC=/orachk/
[oracle@host1 orachk]$ ./orachk

Running orachk
----------------------------------------------------------
PATH : /u01/app/oracle/product/18.1.0/dbhome_1/suptools/orachk
VERSION : 12.2.0.1.4_20171127
COLLECTIONS DATA LOCATION : /u01/app/oracle/orachk/
----------------------------------------------------------

This version of orachk was released on 27-Nov-2017 and its older than 120 days
Latest version of orachk 12.2.0.1.4_20180518 is available at /orachk//.Do you want to upgrade to the latest version of orachk? [y/n][y] y
NOTE: Please ignore "No such file or directory" errors for the file/directory orachk.py,build,cwallet.sso, wallet.pm,lib. This is due to the change in directory structure between the versions 12.2.0.1.3 and 12.2.0.1.4
Running latest version...


Running orachk
----------------------------------------------------------
PATH : /u01/app/oracle/product/18.1.0/dbhome_1/suptools/orachk
VERSION : 18.2.0_20180518
COLLECTIONS DATA LOCATION : /u01/app/oracle/orachk/
----------------------------------------------------------
[oracle@host1 orachk]$ ./orachk -v

ORACHK VERSION: 18.2.0_20180518           

如果已設定RAT_UPGRADE_LOC但不想更新,則仍可以使用-noupgrade選項運作Oracle ORAchk:

[oracle@host1 orachk]$./orachk –noupgrade           

4)更新後檢查

[oracle@host1 orachk]$./orachk -u -o post           

注意:

如果在RAT_UPGRADE_LOC中具有最新版本并且還不想更新,請使用-ngradegrade選項。

在RAT_UPGRADE_LOC中使用-noupgrade而沒有最新版本仍會提示您下載下傳最新版本。

1.3.2. RAC更新ORAchk

MOS文檔1268927.2下載下傳最新的ORAchk

1)更新前檢查

[grid@rac2 orachk]$ pwd
/u01/app/18.1.0/grid/suptools/orachk
[grid@rac2 orachk]$ ./orachk -u -o pre           

2)檢視目前版本

[grid@rac2 orachk]$ ./orachk -v
ORACHK VERSION: 12.1.0.2.7_20160526           

3)更新

将環境變量RAT_UPGRADE_LOC設定下載下傳的ORAchk壓縮包存放的目錄。

[grid@rac2 orachk]$ export RAT_UPGRADE_LOC=/orachk/
[grid@rac2 orachk]$ ./orachk

Running orachk
----------------------------------------------------------
PATH : /u01/app/18.1.0/grid/suptools/orachk
VERSION : 12.2.0.1.4_20171127
COLLECTIONS DATA LOCATION : /u01/app/grid/orachk/
----------------------------------------------------------

This version of orachk was released on 27-Nov-2017 and its older than 120 days
Latest version of orachk 12.2.0.1.4_20180518 is available at /orachk//.Do you want to upgrade to the latest version of orachk? [y/n][y] y
NOTE: Please ignore "No such file or directory" errors for the file/directory orachk.py,build,cwallet.sso, wallet.pm,lib. This is due to the change in directory structure between the versions 12.2.0.1.3 and 12.2.0.1.4
Running latest version...


Running orachk
----------------------------------------------------------
PATH : /u01/app/18.1.0/grid/suptools/orachk
VERSION : 18.2.0_20180518
COLLECTIONS DATA LOCATION : /u01/app/grid/orachk/
----------------------------------------------------------
[grid@rac2 orachk]$ ./orachk -v

ORACHK VERSION: 18.2.0_20180518           

如果已設定RAT_UPGRADE_LOC但不想更新,則仍可以使用-noupgrade選項運作Oracle ORAchk:

[grid@rac2 orachk]$./orachk –noupgrade           

4)更新後檢查s

[grid@rac2 orachk]$./orachk -u -o post           

1.4. 執行ORAchk檢查

1.4.1. 單執行個體執行ORAchk檢查

[root@host1 orachk]# ./orachk
Checking ssh user equivalency settings on all nodes in cluster for root

List of running databases

1. cndba
2. None of above

Select databases from list for checking best practices. For multiple databases, select 1 for All or comma separated number like 1,2 etc [1-2][1]. 1
. .

Checking Status of Oracle Software Stack - Clusterware, ASM, RDBMS

. . . . . . . . . . .
. . . . . . . . . . .
-------------------------------------------------------------------------------------------------------
Oracle Stack Status
-------------------------------------------------------------------------------------------------------
Host Name CRS Installed ASM HOME RDBMS Installed CRS UP ASM UP RDBMS UP DB Instance Name
-------------------------------------------------------------------------------------------------------
host1 No No Yes No No Yes cndba
-------------------------------------------------------------------------------------------------------


Copying plug-ins

. .
. . . . . .

*** Checking Best Practice Recommendations ( PASS / WARNING / FAIL ) ***

. .

Collections and audit checks log file is
/orachk/orachk_host1_PDBCNDBA_072518_100235/log/orachk.log

============================================================
Node name - host1
============================================================
……
--------------------------------------------------------------------------------
RDBMS homes patches summary report
--------------------------------------------------------------------------------
Total patches Applied on RDBMS Applied on ASM ORACLE_HOME
--------------------------------------------------------------------------------
1 1 0 /u01/app/oracle/product/18.1.0/dbhome_1
--------------------------------------------------------------------------------

------------------------------------------------------------
Detailed report (html) - /orachk/orachk_host1_PDBCNDBA_072518_100235/orachk_host1_PDBCNDBA_072518_100235.html

UPLOAD [if required] - /orachk/orachk_host1_PDBCNDBA_072518_100235.zip           

ORAchk 檢查完成之後會生成一個html報告,這個報告的命名為:orachk_節點名_資料庫名_時間.html,比如orachk_host1_PDBCNDBA_072518_100235.html。同時,它還會把所有的輸出檔案都打包為一個.zip檔案,比如orachk_host1_PDBCNDBA_072518_100235.zip,可以把這個.zip檔案從RAC伺服器上下載下傳到本地的windows,解壓後檢視其中的生成的orachk_節點名_資料庫名_時間.html 這一個檔案就可以。

生成的報告也非常簡單、清晰,在報告最上部會列出這次檢查的分數,滿分是100分。

1.5. rac 執行ORAchk檢查

ORAchk會自動識别CRS HOME,請使用者确認(當然,檢查單執行個體就沒有這個問題了),還會提問是檢查叢集中的哪個資料庫。因為RAC的所有執行個體的主機都會執行檢查,如果以前沒有配置過root使用者的使用者等效性,還會自動幫你配置,也都比較簡單,跟着提示做就可以。

[root@rac2 orachk]# ./orachk

Clusterware stack is running from /u01/app/18.1.0/grid. Is this the correct Clusterware Home?[y/n][y]

Checking ssh user equivalency settings on all nodes in cluster for root

Node rac1 is not configured for ssh user equivalency and the orachk uses ssh to execute checks on remote nodes.
Without passwordless ssh orachk can not run audit checks on the remote nodes.
If necessary due to security policies the orachk can be run on each node using -localonly option.


Do you want to configure SSH for user root on rac1 [y/n][y] y

Enter rac1 root password :
Verifying root password ...

Node rac1 has been configured for ssh user equivalency for root


Searching for running databases . . . . .

. .
List of running databases registered in OCR

1. cndba
2. None of above

Select databases from list for checking best practices. For multiple databases, select 1 for All or comma separated number like 1,2 etc [1-2][1]. 1
. . . .

Checking Status of Oracle Software Stack - Clusterware, ASM, RDBMS

. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-------------------------------------------------------------------------------------------------------
Oracle Stack Status
-------------------------------------------------------------------------------------------------------
Host Name CRS Installed RDBMS Installed CRS UP ASM UP RDBMS UP DB Instance Name
-------------------------------------------------------------------------------------------------------
rac2 Yes Yes Yes Yes Yes cndba2
rac1 Yes Yes Yes Yes Yes cndba1
-------------------------------------------------------------------------------------------------------


Copying plug-ins

. .
. . . . . .

*** Checking Best Practice Recommendations ( PASS / WARNING / FAIL ) ***

. .

Collections and audit checks log file is
/orachk/orachk_rac2_CNDBAPDB_072518_101258/log/orachk.log

Starting to run orachk in background on rac1



============================================================
Node name - rac2
============================================================
……

------------------------------------------------------------
CLUSTERWIDE CHECKS
------------------------------------------------------------

------------------------------------------------------------
Detailed report (html) - /orachk/orachk_rac2_CNDBAPDB_072518_101258/orachk_rac2_CNDBAPDB_072518_101258.html

UPLOAD [if required] - /orachk/orachk_rac2_CNDBAPDB_072518_101258.zip           

ORAchk 檢查完成之後會生成一個html報告,這個報告的命名為:orachk_節點名_資料庫名_時間.html,比如orachk_rac2_CNDBAPDB_072518_101258.html。同時,它還會把所有的輸出檔案都打包為一個.zip檔案,比如orachk_rac2_CNDBAPDB_072518_101258.zip,可以把這個.zip檔案從RAC伺服器上下載下傳到本地的windows,解壓後檢視其中的生成的orachk_節點名_資料庫名_時間.html 這一個檔案就可以。

生成的報告也非常簡單、清晰,在報告最上部會列出這次檢查的分數,滿分是100分。