ORAchk-数据库健康检查

ORAchk-数据库健康检查 



原文地址:ORAchk-数据库健康检查 作者:paulyibinyi

ORAchk 之前被称为RACcheck,后来它的检查范围进行了扩展,改名为了ORAchk,它是在数据库系统进行健康检查的一个专用工具,
这个工具主要用来检查软件的配置是否符合要求以及一些最佳实践是否被应用了。
通过这个工具,用户可以很方便地、自动化地对自己的系统进行健康检查和评估。

 ORAchk 能够检查的软件主要有:OS、Oracle Clusterware (CRS)、 Grid Infrastructure environment(GI)、Automatic Storage Management (ASM)以及Real Application Clusters (RAC)、单机的数据库、Golden Gate。

    检查的项目包括:
      o OS kernel 参数
      o OS 包/补丁
      o OS上其它和RAC相关的配置
      o CRS/Grid Infrastructure
      o RDBMS
      o ASM
      o 数据库参数
      o 对于RAC数据库影响较大的设置
      o 升级到11.2.0.3/11.2.0.4/12c时的升级检查
      o Maximum Availability Architecture (MAA)检查

    目前支持的平台:
       o Linux x86-64* (Enterprise Linux, RedHat and SuSE 9, SuSE 10 & SuSE 11)
       o Oracle Solaris SPARC (64-bit)(Solaris 10 and 11)
       o Oracle Solaris x86-64 (Solaris 10 and 11)
       o IBM AIX on POWER Systems (64-bit) **
       o HP-UX PA-RISC (64-bit)**
       o HP-UX Itanium **

       *  不支持32位平台,不支持 Linux Itanium
       ** 需要安装BASH Shell 3.2 或之上

    目前支持的数据库版本:

       o 10gR2
       o 11gR1
       o 11gR2
       o 12cR1

下面是具体界面输出:

[oracle@rac1 ~]$ orachk -ebs32bit

CRS stack is running and CRS_HOME is not set. Do you want to set CRS_HOME to /home/grid/11R2/grid?[y/n][y]y

Checking ssh user equivalency settings on all nodes in cluster

Node rac2 is configured for ssh user equivalency for oracle user
 

Searching for running databases . . . . .

. . 
List of running databases registered in OCR
1. racdb
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
-------------------------------------------------------------------------------------------------------
rac1        Yes             N/A             Yes             Yes        Yes      Yes      racdb1    
rac2        Yes             N/A             Yes             Yes        Yes      Yes      racdb2    
-------------------------------------------------------------------------------------------------------

Copying plug-ins

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . .

64 of the included audit checks require root privileged data collection . If sudo is not configured or the root password is not available, audit checks which  require root privileged data collection can be skipped.

1. Enter 1 if you will enter root password for each  host when prompted

2. Enter 2 if you have sudo configured for oracle user to execute root_orachk.sh script

3. Enter 3 to skip the root privileged collections

4. Enter 4 to exit and work with the SA to configure sudo  or to arrange for root access and run the tool later.

Please indicate your selection from one of the above options for root access[1-4][1]:- 1

Is root password same on all nodes?[y/n][y]y

Enter root password :-

Verifying root password.

. . .

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

 

Collections and audit checks log file is 
/home/oracle/orachk_rac1_racdb_081814_152310/log/orachk.log

 

Checking for prompts in /home/oracle/.bash_profile on rac1 for oracle user...

 

Checking for prompts in /home/oracle/.bash_profile on rac2 for oracle user...

 

Starting to run orachk in background on rac2

=============================================================
                    Node name - rac1                                
=============================================================

Collecting - ASM DIsk I/O stats 
Collecting - ASM Disk Groups 
Collecting - ASM Diskgroup Attributes 
Collecting - ASM disk partnership imbalance 
Collecting - ASM diskgroup attributes 
Collecting - ASM initialization parameters 
Collecting - Active sessions load balance for racdb database
Collecting - Archived Destination Status for racdb database
Collecting - Cluster Interconnect Config for racdb database
Collecting - Database Archive Destinations for racdb database
Collecting - Database Files for racdb database
Collecting - Database Instance Settings for racdb database
Collecting - Database Parameters for racdb database
Collecting - Database Parameters for racdb database
Collecting - Database Properties for racdb database
Collecting - Database Registry for racdb database
Collecting - Database Sequences for racdb database
Collecting - Database Undocumented Parameters for racdb database
Collecting - Database Undocumented Parameters for racdb database
Collecting - Database Workload Services for racdb database
Collecting - Dataguard Status for racdb database
Collecting - Files not opened by ASM 
Collecting - Log Sequence Numbers for racdb database
Collecting - Percentage of asm disk  Imbalance 
Collecting - Process for shipping Redo to standby for racdb database
Collecting - RDBMS Feature Usage for racdb database
Collecting - Redo Log information for racdb database
Collecting - Standby redo log creation status before switchover for racdb database
Collecting - /proc/cmdline
Collecting - /proc/modules
Collecting - CPU Information
Collecting - CRS active version
Collecting - CRS oifcfg
Collecting - CRS software version
Collecting - CSS Reboot time
Collecting - CSS disktimout
Collecting - Cluster interconnect (clusterware)
Collecting - Clusterware OCR healthcheck 
Collecting - Clusterware Resource Status
Collecting - DiskFree Information
Collecting - DiskMount Information
Collecting - Huge pages configuration
Collecting - Kernel parameters
Collecting - Linux module config.
Collecting - Maximum number of semaphore sets on system
Collecting - Maximum number of semaphores on system
Collecting - Maximum number of semaphores per semaphore set
Collecting - Memory Information
Collecting - NUMA Configuration
Collecting - Network Interface Configuration
Collecting - Network Performance
Collecting - Network Service Switch
Collecting - OS Packages
Collecting - OS version
Collecting - Operating system release information and kernel version
Collecting - Oracle Executable Attributes
Collecting - Patches for Grid Infrastructure 
Collecting - Patches for RDBMS Home 
Collecting - Shared memory segments
Collecting - Table of file system defaults
Collecting - Verify ioctl to advm [ACFS]
Collecting - Voting disks (clusterware)
Collecting - number of semaphore operations per semop system call
Preparing to run root privileged commands  rac1.

Collecting - ACFS and ASM driver version comparison [ACFS] 
Collecting - CRS user time zone check 
Collecting - Custom rc init scripts (rc.local) 
Collecting - Disk Information 
Collecting - Generic ACFS health [ACFS] 
Collecting - Grid Infastructure user shell limits configuration 
Collecting - Health of the mounted ACFS file systems [ACFS] 
Collecting - Health of unmounted ACFS file systems [ACFS] 
Collecting - Interconnect interface config 
Collecting - Network interface stats 
Collecting - Number of RDBMS LMS running in real time 
Collecting - OCFS2 disks 
Collecting - OLR Integrity 
Collecting - Volume list for unmount ACFS file system [ACFS] 
Collecting - ocsf status 
Collecting - root time zone check

Data collections completed. Checking best practices on rac1.
--------------------------------------------------------------------------------------

 WARNING => SYS.AUDSES$ sequence cache size < 10,000 for racdb
 WARNING => Without ARCHIVELOG mode the database cannot be recovered from an online backup and Data Guard cannot be used. for racdb
 WARNING => OCR is NOT being backed up daily
 INFO =>    At some times checkpoints are not being completed for racdb
 WARNING => Controlfile is NOT multiplexed for racdb
 WARNING => One or more redo log groups are NOT multiplexed for racdb
 WARNING => /tmp is NOT on a dedicated filesystem
 WARNING => Linux Swap Configuration does NOT meet Recommendation
 INFO =>    Number of SCAN listeners is NOT equal to the recommended number of 3.
 WARNING => NIC bonding is not configured for interconnect
 WARNING => NIC bonding is NOT configured for public network (VIP)
 WARNING => OSWatcher is not running as is recommended.
 INFO =>    Jumbo frames (MTU >= 8192) are not configured for interconnect
 WARNING => NTP is not running with correct setting
 WARNING => Database parameter DB_BLOCK_CHECKING on PRIMARY is NOT set to the recommended value. for racdb
 FAIL =>    Flashback on PRIMARY is not configured for racdb
 INFO =>    Operational Best Practices
 INFO =>    Database Consolidation Best Practices
 INFO =>    Computer failure prevention best practices
 INFO =>    Data corruption prevention best practices
 INFO =>    Logical corruption prevention best practices
 INFO =>    Database/Cluster/Site failure prevention best practices
 INFO =>    Client failover operational best practices
 WARNING => fast_start_mttr_target should be greater than or equal to 300. on racdb1 instance

 INFO =>    IMPORTANT: Oracle Database Patch 17478514 PSU is NOT applied to RDBMS Home /home/oracle/11gR2/db_1
 INFO =>    Information about hanganalyze and systemstate dump
 FAIL =>    Table AUD$[FGA_LOG$] should use Automatic Segment Space Management for racdb
 INFO =>    Database failure prevention best practices
 WARNING => Database Archivelog Mode should be set to ARCHIVELOG for racdb
 FAIL =>    Primary database is NOT protected with Data Guard (standby database) for real-time data protection and availability for racdb
 WARNING => avahi-daemon process is running
 WARNING => Redo log write time is more than 500 milliseconds for racdb
 INFO =>    Parallel Execution Health-Checks and Diagnostics Reports for racdb
 INFO =>    Oracle recovery manager(rman) best practices
 WARNING => RMAN controlfile autobackup should be set to ON for racdb
 INFO =>    Consider increasing the COREDUMPSIZE size
 INFO =>    Consider investigating changes to the schema objects such as DDLs or new object creation for racdb

 

Copying results from rac2 and generating report. This might take a while. Be patient.

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

Collecting - /proc/cmdline
Collecting - /proc/modules
Collecting - CPU Information
Collecting - CRS active version
Collecting - CRS oifcfg
Collecting - CRS software version
Collecting - Cluster interconnect (clusterware)
Collecting - DiskFree Information
Collecting - DiskMount Information
Collecting - Huge pages configuration
Collecting - Kernel parameters
Collecting - Linux module config.
Collecting - Maximum number of semaphore sets on system
Collecting - Maximum number of semaphores on system
Collecting - Maximum number of semaphores per semaphore set
Collecting - Memory Information
Collecting - NUMA Configuration
Collecting - Network Interface Configuration
Collecting - Network Performance
Collecting - Network Service Switch
Collecting - OS Packages
Collecting - OS version
Collecting - Operating system release information and kernel version
Collecting - Oracle Executable Attributes
Collecting - Patches for Grid Infrastructure 
Collecting - Patches for RDBMS Home 
Collecting - Shared memory segments
Collecting - Table of file system defaults
Collecting - Verify ioctl to advm [ACFS]
Collecting - number of semaphore operations per semop system call
Preparing to run root privileged commands  rac2.

Collecting - ACFS and ASM driver version comparison [ACFS] 
Collecting - CRS user time zone check 
Collecting - Disk Information 
Collecting - Generic ACFS health [ACFS] 
Collecting - Grid Infastructure user shell limits configuration 
Collecting - Health of the mounted ACFS file systems [ACFS] 
Collecting - Health of unmounted ACFS file systems [ACFS] 
Collecting - Interconnect interface config 
Collecting - Network interface stats 
Collecting - Number of RDBMS LMS running in real time 
Collecting - OCFS2 disks 
Collecting - OLR Integrity 
Collecting - Volume list for unmount ACFS file system [ACFS] 
Collecting - ocsf status 
Collecting - root time zone check

Data collections completed. Checking best practices on rac2.
--------------------------------------------------------------------------------------

 

 WARNING => /tmp is NOT on a dedicated filesystem
 WARNING => Linux Swap Configuration does NOT meet Recommendation
 INFO =>    Number of SCAN listeners is NOT equal to the recommended number of 3.
 WARNING => NIC bonding is not configured for interconnect
 WARNING => NIC bonding is NOT configured for public network (VIP)
 WARNING => OSWatcher is not running as is recommended.
 INFO =>    Jumbo frames (MTU >= 8192) are not configured for interconnect
 WARNING => NTP is not running with correct setting
 WARNING => Database parameter DB_BLOCK_CHECKING on PRIMARY is NOT set to the recommended value. for racdb
 WARNING => fast_start_mttr_target should be greater than or equal to 300. on racdb2 instance

 INFO =>    IMPORTANT: Oracle Database Patch 17478514 PSU is NOT applied to RDBMS Home /home/oracle/11gR2/db_1
 WARNING => ezconnect should be configured in sqlnet.ora
 WARNING => avahi-daemon process is running
 WARNING => Redo log write time is more than 500 milliseconds for racdb
 INFO =>    Consider increasing the COREDUMPSIZE size

 

---------------------------------------------------------------------------------
                      CLUSTERWIDE CHECKS
---------------------------------------------------------------------------------
 WARNING => OS Kernel version(uname -r) does not match across cluster.
---------------------------------------------------------------------------------
 

 

 

 

 

Detailed report (html) - /home/oracle/orachk_rac1_racdb_081814_152310/orachk_rac1_racdb_081814_152310.html

UPLOAD(if required) - /home/oracle/orachk_rac1_racdb_081814_152310.zip

 

[oracle@rac1 ~]$ ls -ltr
total 36284
drwxr-xr-x  7 root   root         4096 Aug 28  2013 database
-rwxr-xr-x  1 oracle oinstall  1604239 May 31 14:37 orachk
-rw-r--r--  1 oracle oinstall      432 May 31 14:37 UserGuide.txt
-rw-r--r--  1 oracle oinstall     3879 May 31 14:37 readme.txt
-rwxr-xr-x  1 oracle oinstall  1604239 May 31 14:37 raccheck
-rw-rw-r--  1 oracle oinstall  3384097 May 31 14:37 rules.dat
-rw-rw-r--  1 oracle oinstall 22951324 May 31 14:37 collections.dat
drwxr-xr-x  3 oracle oinstall     4096 Aug 14 11:34 11gR2
drwxrwxr-x 11 oracle oinstall     4096 Aug 14 11:52 diag
drwxr-xr-x  2 oracle oinstall     4096 Aug 14 12:17 checkpoints
drwxr-x---  3 oracle oinstall     4096 Aug 14 12:43 admin
drwxr-x---  6 oracle oinstall     4096 Aug 14 13:06 cfgtoollogs
-rw-r--r--  1 root   root      5770368 Aug 18 15:18 orachk.zip
drwxr-xr-x  7 oracle oinstall    94208 Aug 18 15:38 orachk_rac1_racdb_081814_152310
-rw-r--r--  1 oracle oinstall  1639658 Aug 18 15:38 orachk_rac1_racdb_081814_152310.zip



使用Oracle官方巡检工具ORAchk巡检数据库

2016-12-21 饶冰 OCM之家

饶冰,中国OCM之家核心成员,现就职于北京海天起点,拥有十余年Oracle产品服务及实施经验,曾供职于Oracle University和Oracle Support Service部门。拥有OCM,Exadata,EM12c,WebLogic12c等多项认证。目前主要负责基于Oracle产品的解决方案研发和实施工作,涉猎行业有电信、政府、金融、能源、制造等等。ORAchk概述

ORAchk是Oracle官方出品的Oracle产品健康检查工具,可以从MOS(My Oracle Support)网站上下载,免费使用。这个工具可以检查Oracle数据库,GoldenGate,Oracle Enterprise Manager 12c、13c等Oracle产品,具体支持的产品和相关资料可以参考MOS文档:ORAchk - Health Checks for the Oracle Stack (Doc ID 1268927.2)。

ORAchk支持所有主流平台,当然,对有些平台的支持并不是很完美,比如,对windows平台的支持是限定版本,而且需要安装Cygwin这样的软件。最新版本的ORAchk对Oracle数据库的版本支持是:10gR2,11gR1,11gR2,12cR1,12cR2

ORAchk是一个命令行工具,运行后收集系统配置信息,同时按照预定义的规则,评估配置是否符合Oracle的最佳实践,评估结果输出为一份html格式的健康检查报告,报告中会有所有检查项的细节数据,以及根据规则给被检查系统的一个综合评分。虽然这个评分规则比较“简单粗暴”,(所有检查项的分值都一样),但这个分数还是有一定意义的,起码给领导或甲方看的时候,可以给出一个量化指标了,而且可以在不同的系统之间,或不同时间的同一个系统之间进行比较。

ORAchk执行及报告样例

(ORAchk目前最新的版本是12.2.0.1.1,后续的例子里都是这个版本)

ORAchk的执行比较简单,下载软件包(链接在上面提到的MOS文档中),上传到服务器,解压缩,然后直接以root身份执行orachk,也可以用oracle软件安装用户执行,在运行时会提问root口令,也可以选择使用sudo或者略过需要使用root身份的检查。

以检查一套linux平台上的oracle 11.2.0.4 RAC为例:

ORAchk会自动识别CRS HOME,请用户确认(当然,检查单实例就没有这个问题了),还会提问是检查集群中的哪个数据库。因为RAC的所有实例的主机都会执行检查,如果以前没有配置过root用户的用户等效性,还会自动帮你配置,也都比较简单,跟着提示做就可以。检查完成后,会生成一个打包文件,里面包含最终的html格式的报告,以及相关的细节数据,报告的例子:

请点击此处输入图片描述

请点击此处输入图片描述

以上面的检查为例,报告分5部分。Database Server章节主要是OS,ASM和数据据的检查项,我们只要关注fail和warning的检查项就可以了:

可以点击“view”,查看检查项的具体细节:

请点击此处输入图片描述

Patch Recommendation 是补丁建议:

请点击此处输入图片描述

Cluster Wide的检查主要是检查RAC节点之间的配置是否一致,比如时间、目录属主之类的:

MAA 记分卡主要是检查系统是否符合Oracle推荐的最大可用性架构:(什么是最大可用性架构,不是本文的重点)

请点击此处输入图片描述

请点击此处输入图片描述

另外最耗时的10个检查什么的,我觉得没什么意义。

请点击此处输入图片描述

ORAchk以后台进程的方式定时运行

ORAchk可以配置成以后台进程模式,按照用户定义的时间间隔,自动运行,同时把结果通过email的方式发送给用户。

Daemon Mode配置方法

1. 配置orachk

使用orachk设置自动运行参数,有两个参数是必须设置的:AUTORUN_SCHEDULE 和NOTIFICATION_EMAIL,设置的例子:

# ./orachk –set “AUTORUN_SCHEDULE=3 * * 0 ;NOTIFICATION_EMAIL=raobing@hthorizon.com”

其中AUTORUN_SCHEDULE是运行的时间,含义是:AUTORUN_SCHEDULE=hour day month day_of_week

用*代表所有值,比如上面例子中“3 * * 0” 代表每个星期天的3点执行(0代表星期天,6代表星期六

NOTIFICATION_EMAIL参数的值就是接受报告的邮箱地址。

2. 启动后台进程

# ./orachk –d start

这种模式需要工具expect来处理root口令,避免多次交互输入口令,这个工具的下载地址:http://expect.sourceforge.net/

Expect 安装是源码安装,在linux平台上,需要tcl-devel 这个rpm包,安装expect和tcl-devel 包的过程略。

邮件相关配置

ORAchk支持使用mailx和sendmail两种方式发送邮件,为了外部邮箱能够收到邮件,我使用了mailx的方式,在我的测试机上,安装的是Oracle Linux 6.5,系统自带mailx 12.4,为了保证能够让ORAchk使用mailx,需要保证系统上安装了uuencode,sharutils rpm包里面有这个工具。

另外,在/etc/mail.rc,增加下列配置行,主要是目前大部分外部smtp服务器都是需要认证才能发邮件,所以要给出认证信息:

如果一切正常,在orachk目录下的orachk_daemon.log会有类似的字样:

请点击此处输入图片描述

请点击此处输入图片描述

邮件样例

第一次的邮件报告就是一份html格式的报告,后续的报告会包含上一次的报告和本次报告,以及两份报告的不同之处。

请点击此处输入图片描述

Collection Manager

ORAchk的软件包里面还提供了一个web应用,用于管理健康检查的结果,应用的名字叫Collection Manager(CM),在这个应用中,一次检查被称为一个Collection。

CM是一个Oracle APEX应用,Oracle APEX显然不是这篇文章讨论的问题,关于APEX的介绍及安装部署会在其他文章介绍。

CM在导入APEX后,运行应用,登录的界面是这个样子的:

在系统中应用包含两个样例Collection,是在一个sample系统上运行的2次检查。可以很直观地看到最新一次的检查,FAIL的检查项31%,WARNING的检查项31%,PASS的检查项38%。

请点击此处输入图片描述

我们把我们实际的Collection上传两个:

直接上传zip包,系统会自动在后台解压缩并处理,需要花几分钟时间。 

请点击此处输入图片描述

查看我们上传的两个不同系统的Collection:

请点击此处输入图片描述

点击图表,可以转到具体信息页面,比如我们点击4%的红色区域,会转向这个页面,除了能查看具体的检查项信息外,还可以针对问题创建Ticket: 

请点击此处输入图片描述

请点击此处输入图片描述

CM应用中应该算是自带了一个事件管理系统,可以将检查后发现的配置缺陷,当作一个事件,通过CM中的事件管理功能,进行追踪管理: 

请点击此处输入图片描述

另外这个应用还可以进行不同Collection的比较,也很方便。

从这个应用的内容看,官方希望的系统健康检查流程应该是这样的:

  1. 客户自助或服务商现场工程师运行orachk,生成Collection。
  2. 上传Collection到CM应用,CM是部署在云(公有或私有)上的。
  3. 客户登录系统查看、管理自己系统的检查报告,不再需要服务人员提供检查结果。
  4. 检查出的问题可以使用CM应用来进行跟踪管理。

其实要真能这样也不错,但是个人觉得目前可能实现起来还有一些障碍:

  1. Orachk和CM系统都没有中文版,估计还得有服务商翻译,可能最后还是要转变成传统的交付物。
  2. Orachk目前检查的内容还不能算全面,比如性能方面的数据。

使用自定义检查项

ORAchk支持自定义检查项,用户只要安装一定的规则,创建对应的XML配置文件,就可以让ORAchk进行自定义检查。

ORAchk的软件包里面提供了一个sample_user_defined_checks.xml,给出了几个例子,而且有详细的注释,只要按照这个规则,生成user_defined_checks.xml,放在orachk所在的目录,就可以让orachk进行自定义检查了。自定义检查项目前支持两种类型:OS 命令和SQL语句。下面我看一个SQL语句的自定义检查:

这个检查返回空闲空间比例小于10%的表空间的个数,为0是检查通过,不为0是FAIL。

<userdefinedchecks </userdefinedchecks<>

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:noNamespaceSchemaLocation="user_defined_checks.xsd">

                *

               

                       

                          *

                       

               

                tbs_ut  

                                   

                      <!--[CDATA[  select 'tbs_ut = '||count(*) from (select a.tablespace_name,

           trunc(sum(a.tots) / 1024 / 1024, 2) Tot_Size_mb,

           round(sum(a.sumb) / 1024 / 1024, 2) Tot_Free_mb,

           round(sum(a.sumb) * 100 / sum(a.tots), 2) Pct_Free,

           round(sum(a.largest) / 1024 / 1024, 2) Max_Free_mb,

           sum(a.chunks) Chunks_Free

      from (select tablespace_name,

                   0 tots,

                   sum(bytes) sumb,

                   max(bytes) largest,

                   count(*) chunks

              from dba_free_space a

             group by tablespace_name

            union

            select tablespace_name, sum(bytes) tots, 0, 0, 0

              from dba_data_files

             group by tablespace_name) a

     group by a.tablespace_name)

 where PCT_FREE < 10;]]>                      

               

               

                        <!--[CDATA[select 'Free PCT less 10% TBS = '||count(*) from (select a.tablespace_name,

           trunc(sum(a.tots) / 1024 / 1024, 2) Tot_Size_mb,

           round(sum(a.sumb) / 1024 / 1024, 2) Tot_Free_mb,

           round(sum(a.sumb) * 100 / sum(a.tots), 2) Pct_Free,

           round(sum(a.largest) / 1024 / 1024, 2) Max_Free_mb,

           sum(a.chunks) Chunks_Free

      from (select tablespace_name,

                   0 tots,

                   sum(bytes) sumb,

                   max(bytes) largest,

                   count(*) chunks

              from dba_free_space a

             group by tablespace_name

            union

            select tablespace_name, sum(bytes) tots, 0, 0, 0

              from dba_data_files

             group by tablespace_name) a

     group by a.tablespace_name)

 where PCT_FREE < 10;]]>

               

                =

                0            

                *

                RDBMS

                3            

                CDB:PDB:NORMAL

                PRIMARY

                FAIL

                The number of Tablespaces which free PCT less 10% is zero

                The number of Tablespaces which free PCT less 10% is not zero

               

                     

               

               

                     

               

               

                       

               

               

                       

               

       

自定义检查项,可以和其他检查项一起执行,也可以单独执行,单独执行自定义检查项的语法是:

# ./orachk –profile user_defined_checks

下面是自定义检查项报告样例:

请点击此处输入图片描述

如果你觉得这样写XML麻烦,还可以使用CM应用来生成自定义检查项的XML文件,菜单路径:Administration -> “+ Add New User Defined Checks”

请点击此处输入图片描述

定义好后,可以生成XML文件并下载:

请点击此处输入图片描述

不过这个功能并不完善,缺乏必要得有效性检查,如果想不出错,还是要把XML得规则搞清楚,我个人还是比较喜欢手工写XML。




 使用oracheck进行系统巡检 

 
日常数据库巡检,是运维人员经常需要完成的工作之一。对应复杂的软硬件和系统环境,以及越来越多的系统数目,常规手段进行一次巡检的成本压力越来越大。综合性的巡检方面,自动化的执行和信息收集,才是未来巡检的一个发展方向。
Oracle Support内部的研发机构,会推出很多有用的小工具来辅助我们日常巡检诊断工具,比如OSWatcher、RDA、oratop。这些工具都从一定程度上解决了我们在使用Oracle数据库过程中遇到的管理和调优需求。本篇主要介绍oracheck,借助orachk,我们可以快速的进行系统巡检和故障排除。
 
1、从raccheck到oracheck
 
oracheck来源于Oracle为RAC环境准备的工具raccheck。最早的raccheck是用于自动化Oracle RAC环境巡检而开发的,之后不断推出新的版本和功能。这些新功能中,最有意义的要属于Oracle MAA(Oracle最大可用性体系架构)的引入。Oracle会将MAA的最佳实践策略,融入到raccheck检查项目里面,给用户提供更加全面的巡检项目。
目前,raccheck已经正式改名为oracheck,提供从单实例数据库实例到RAC、OGG等多个产品系列的巡检功能。
 
2、安装配置
 
oracheck是需要单独从MOS上下载的工具包。和其他Oracle产品不同,oracheck更新速度非常快,官方建议是90天就需要下载最新的oracheck版本。这样做的目的就是让用户可以获得最新的检查项目和建议,及时下载安装最新的安全补丁。
从MOS上下载的软件包很简单,就是一个zip包。上传到服务器上解压就可以使用。注意:目前oracheck只支持64bit系统,在32bit下不能使用。
创建专门目录,上传zip文件。
 
[root@CRSimpleLinux /]# mkdir /orachk
[root@CRSimpleLinux /]# cd /orachk/
[root@CRSimpleLinux orachk]# ls -l
total 5120
-rw-r--r-- 1 root root 5241976 May 20 08:44 orachk_224_beta2.zip
 
解压安装包。
 
[root@CRSimpleLinux orachk]# unzip orachk_224_beta2.zip 
Archive:  orachk_224_beta2.zip
  inflating: orachk                  
   creating: .cgrep/
  inflating: .cgrep/lcgreps9         
  inflating: .cgrep/CollectionManager_App.sql  
  inflating: .cgrep/asrexacheck      
  inflating: .cgrep/utlusts.sql      
(篇幅原因,有省略……)
 
检查脚本,是一系列的配置文件和oracheck执行文件。
 
[root@CRSimpleLinux orachk]# ls -l
total 28072
-rw-rw-r-- 1 root root 21200391 Feb 11 03:50 collections.dat
-rwxr-xr-x 1 root root  1407669 Feb 14 03:23 orachk
-rwxr-xr-x 1 root root  1423197 Feb 11 03:50 raccheck
-rw-r--r-- 1 root root     2541 Feb 11 03:50 readme.txt
-rw-rw-r-- 1 root root  4700572 Feb 11 03:50 rules.dat
-rw-r--r-- 1 root root      296 Feb 11 03:50 UserGuide.txt
 
额外授权给oracle用户,另外修改权限755。
 
[root@CRSimpleLinux /]# chown -R oracle:oinstall orachk/
[root@CRSimpleLinux /]# chmod -R 755 /orachk/
[root@CRSimpleLinux /]# cd /orachk/
[root@CRSimpleLinux orachk]# ls -l
total 28072
-rwxr-xr-x 1 oracle oinstall 21200391 Feb 11 03:50 collections.dat
-rwxr-xr-x 1 oracle oinstall  1407669 Feb 14 03:23 orachk
-rwxr-xr-x 1 oracle oinstall  1423197 Feb 11 03:50 raccheck
-rwxr-xr-x 1 oracle oinstall     2541 Feb 11 03:50 readme.txt
-rwxr-xr-x 1 oracle oinstall  4700572 Feb 11 03:50 rules.dat
-rwxr-xr-x 1 oracle oinstall      296 Feb 11 03:50 UserGuide.txt
 
注意:在执行oracheck用户上,根据不同的情况可以选择root或者oracle owner对象。在一些检查项目中,是需要root权限进行操作的。一种比较推荐的方式是使用owner用户执行,在需要root权限的时候按照提示输入root密码。
 
3、oracheck使用
 
oracheck脚本有默认的行为方式,通过参数可以控制执行行为。例如-v可以显示版本信息。
 
[oracle@CRSimpleLinux orachk]$ ./orachk -v
ORACHK  VERSION: 2.2.4(BETA)_20140210
 
通常情况下,使用默认的profile配置,就可以进行大部分检查项目。
 
[oracle@CRSimpleLinux orachk]$ ./orachk -v
 
ORACHK  VERSION: 2.2.4(BETA)_20140210
[oracle@CRSimpleLinux orachk]$ ./orachk 
This computer is for [S]ingle instance database or part of a [C]luster to run RAC database [S|C] [C]:S
 
 
orachk did not find the RDBMS binaries on crsimplelinux from environment.
 
Please set RAT_ORACLE_HOME to ORACLE_HOME in current shell to override and re-run it.
eg export RAT_ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
 
默认配置环境变量中,要求RAT_ORACLE_HOME配置为ORACLE_HOME。
 
[oracle@CRSimpleLinux orachk]$ export RAT_ORACLE_HOME=$ORACLE_HOME
[oracle@CRSimpleLinux orachk]$ env | grep RAT_ORACLE_HOME
RAT_ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
 
[oracle@CRSimpleLinux orachk]$ ./orachk 
This computer is for [S]ingle instance database or part of a [C]luster to run RAC database [S|C] [C]:S
(篇幅原因,有省略……)
 
Data collections completed. Checking best practices on crsimplelinux.
--------------------------------------------------------------------------------------
(发现问题列表……)
 WARNING => net.core.wmem_max Is NOT Configured According to Recommendation
 WARNING => net.core.rmem_max Is NOT Configured According to Recommendation
 WARNING => The number of async IO descriptors is too low (/proc/sys/fs/aio-max-nr)
 WARNING => kernel.shmmax parameter is NOT configured according to recommendation
 WARNING => OSWatcher is not running as is recommended.
 INFO =>    Consider increasing the COREDUMPSIZE>
 
Best Practice checking completed.Checking recommended patches on crsimplelinux.
---------------------------------------------------------------------------------
              RDBMS homes patches summary report
---------------------------------------------------------------------------------
Total patches  Applied on RDBMS Applied on ASM ORACLE_HOME    
--------------------------------------------------------------------------------- 
Detailed report (html) -/orachk/orachk_crsimplelinux_052014_172942/orachk_crsimplelinux_052014_172942.html –结果报告文件
UPLOAD(if required) - /orachk/orachk_crsimplelinux_052014_172942.zip
 
在目录中,包括了一个zip文件和文件夹,包括了巡检结果报告。
 
[oracle@CRSimpleLinux orachk]$ ls -l
total 28228
-rwxr-xr-x 1 oracle oinstall 21200391 Feb 11 03:50 collections.dat
-rwxr-xr-x 1 oracle oinstall  1407669 Feb 14 03:23 orachk
drwxr-xr-x 6 oracle oinstall    12288 May 20 17:30 orachk_crsimplelinux_052014_172942
-rw-r--r-- 1 oracle oinstall   145482 May 20 17:30 orachk_crsimplelinux_052014_172942.zip
-rwxr-xr-x 1 oracle oinstall  1423197 Feb 11 03:50 raccheck
-rwxr-xr-x 1 oracle oinstall     2541 Feb 11 03:50 readme.txt
-rwxr-xr-x 1 oracle oinstall  4700572 Feb 11 03:50 rules.dat
-rwxr-xr-x 1 oracle oinstall      296 Feb 11 03:50 UserGuide.txt
 
4、报告解析
 
打开html文件,可以看到报告。报告头是oracheck对于系统情况的一个评分,下面显示的是得到了87分。summary环节中包括了数据库基本信息情况。
 
 
 
首先是对于数据库需要关注问题,oracheck都给与特别的显示。在级别上,也有对应不同的类型。目前oracheck支持fail、warning、error和info几个类型。
 
 
 
后面包括Passed的检查项目。对于提醒的问题内容,我们点击Details,就可以跳转到详细信息部分进行解释检查。
 
 
 
上面提示的内容比较清楚。这个错误是针对内核kernal.shmmax参数确定的。在Oracle DBMS中,配置这个参数的原则是按照物理内存一般大小进行配置就可以。检查中发现实际大小:2147483648,建议大小是4088072192。并且提示了详细解析的MOS文章编号。
oracheck报告内容是结合了Oracle最佳实践内容而确定的,我们下面可以根据实际情况进行修改。
 
5、重新运行报告
 
按照提示信息将问题修改之后(修改过程详见后续文章),最好重新运行oracheck判断问题是否解决。
 
[oracle@CRSimpleLinux ~]$ cd /orachk/
[oracle@CRSimpleLinux orachk]$ export RAT_ORACLE_HOME=$ORACLE_HOME
[oracle@CRSimpleLinux orachk]$ ./orachk
This computer is for [S]ingle instance database or part of a [C]luster to run RAC database [S|C] [C]:
 
Collecting - Patches for RDBMS Home 
Collecting - number of semaphore operations per semop system call
 
 
Data collections completed. Checking best practices on crsimplelinux.
--------------------------------------------------------------------------------------
 WARNING => OSWatcher is not running as is recommended.
 INFO =>    Consider increasing the COREDUMPSIZE>
(篇幅原因,有省略……)
--------------------------------------------------------------------------------- 
Detailed report (html) - /orachk/orachk_crsimplelinux_052014_180024/orachk_crsimplelinux_052014_180024.html
UPLOAD(if required) - /orachk/orachk_crsimplelinux_052014_180024.zip
 
生成新的报告文件。
 
[oracle@CRSimpleLinux orachk]$ ls -l
total 28380
-rwxr-xr-x 1 oracle oinstall 21200391 Feb 11 03:50 collections.dat
-rwxr-xr-x 1 oracle oinstall  1407669 Feb 14 03:23 orachk
drwxr-xr-x 6 oracle oinstall    12288 May 20 17:30 orachk_crsimplelinux_052014_172942
-rw-r--r-- 1 oracle oinstall   145482 May 20 17:30 orachk_crsimplelinux_052014_172942.zip
drwxr-xr-x 6 oracle oinstall    12288 May 20 18:01 orachk_crsimplelinux_052014_180024
-rw-r--r-- 1 oracle oinstall   143227 May 20 18:01 orachk_crsimplelinux_052014_180024.zip
-rwxr-xr-x 1 oracle oinstall  1423197 Feb 11 03:50 raccheck
-rwxr-xr-x 1 oracle oinstall     2541 Feb 11 03:50 readme.txt
 
打开报告,可以看到检验得分已经提升。
 
 
 
6、报告对比功能
 
oracheck另一项重要功能是报告对比。一个报告可以提供和之前报告情况的对比,及时发现问题变化因素。
 
 
[oracle@CRSimpleLinux orachk]$ ./orachk -diff orachk_crsimplelinux_052014_172942 orachk_crsimplelinux_052014_180024
Summary 
Total   : 23
Missing : 0
New     : 0
Changed : 4
Same    : 19
File comparison is complete. The comparison report can be viewed in: /orachk/orachk_052014172942_052014180024_diff.html
 
报告文件中,可以看到对比情况和变化提示。
 
 
 
7、结论
 
oracheck来源于raccheck,从使用方式和功能上没有过多的变化。oracheck对于Oracle产品、操作系统的支持是比较广泛的。如果配合自动执行功能,完全可以支持多数据库服务器的日常自动化巡检工作。


About Me


...............................................................................................................................

● 本文整理自网络,注:orachk脚本下载地址参考我的云盘

● 本文在itpub(http://blog.itpub.net/26736162)、博客园(http://www.cnblogs.com/lhrbest)和个人微信公众号(xiaomaimiaolhr)上有同步更新

● 本文itpub地址:http://blog.itpub.net/26736162/abstract/1/

● 本文博客园地址:http://www.cnblogs.com/lhrbest

● 本文pdf版及小麦苗云盘地址:http://blog.itpub.net/26736162/viewspace-1624453/

● 数据库笔试面试题库及解答:http://blog.itpub.net/26736162/viewspace-2134706/

● QQ群:230161599     微信群:私聊

● 联系我请加QQ好友(646634621),注明添加缘由

● 于 2017-07-01 09:00 ~ 2017-07-31 22:00 在魔都完成

● 文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解

● 版权所有,欢迎分享本文,转载请保留出处

...............................................................................................................................

拿起手机使用微信客户端扫描下边的左边图片来关注小麦苗的微信公众号:xiaomaimiaolhr,扫描右边的二维码加入小麦苗的QQ群,学习最实用的数据库技术。

时间: 2024-07-30 08:45:17

ORAchk-数据库健康检查的相关文章

磨刀不误砍柴工,ORAchk健康检查好帮手

ORAchk 之前被称为RACcheck,后来它的检查范围进行了扩展,改名为了ORAchk,它是在数据库系统进行健康检查的一个专用工具,这个工具主要用来检查软件的配置是否符合要求以及一些最佳实践是否被应用了.通过这个工具,用户可以很方便地.自动化地对自己的系统进行健康检查和评估.   目录   ORAchk 基本情况介绍 如何下载和安装ORAchk 如何执行orachk ORAchk生成的报告 ORAchk 升级检查功能 什么时候适宜运行ORAchk 一. ORAchk 基本情况介绍 ORAch

Oracle健康监控及健康检查(Health Monitor)

一.Oracle健康监控及健康检查 Oracle数据库包括一个名为Health Monitor的框架,用于运行诊断检查数据库的各种组件.Oracle健康监视器检查各种组件数据库,包括文件,内存,事务完整性,元数据和进程使用.在检查器运行后,它生成一个包含有关检查器发现的信息的报告,包括优先事项(低,高或关键),调查结果及其后果的描述,和关于执行的基本统计. Health Monitor使用XML生成报表并存储ADR报告.可以使用V$ HM_RUN,DBMS_HM,ADRCI或企业管理器查看相应的

我的oracle健康检查报告

       最近一直想用sql来生成oracle的健康检查报告,这样看起来一目了然,经过网上搜资料加自己整理终于算是成型了,部分结果如下图所示, 具体参考附件,恳请广大网友看看是否还有需要添加的地方. DB_healthcheck_by_lhr_ORADG11G_20150826160539.zip ORADG11G 数据库巡检报告 Copyright (c) 2015-2100 (http://blog.itpub.net/26736162) lhrbest. All rights rese

我的oracle健康检查报告(三)

       之前分别在http://blog.itpub.net/26736162/viewspace-1783297/ 和 http://blog.itpub.net/26736162/viewspace-1805156/ 中发布了我的健康检查报告(oracle巡检报告)第一版和第二版本的预览版,经过最近一段时间的改造,从界面到内容上又有了新的突破,具体参考附件,恳请广大网友看看是否还有需要添加的地方,以便更加完善这个报告内容,该脚本也耗费了我巨大精力,请大家注意版权,所有与此相似的请注明出

阿里云SLB健康检查的日志特殊处理

SLB健康检查的频率比较高,每秒都有好几个.日积月累就带来了大量web service的日志.一来浪费存储空间,二来消耗磁盘性能.除了官方建议的降低健康检查频率外,或许有一些变通的思维 1.如果对HTTP或者TCP转发协议不挑剔,换成TCP转发并不开启http健康检查就OK了. 优势:方便,控制台操作下就好了. 劣势:只是这样也失去了应用层异常的发现能力. 2.为健康检查单独建立一个没有开启日志的virtualhost,通过不同的端口或者hostname,让健康检查请求不会请求到业务host.

数据库性能检查指导方案 - Part I

数据|数据库|性能 数据库性能检查指导方案   Author: Kamus Date:2004-9   在系统稳定之后,应该按照本指导方案每个月检查一次产品数据库. 该指导方案适用于Oracle9i数据库,因为有些脚本在9i中才可以运行. 检查方式均为以sysdba身份登录数据库以后在SQLPLUS中执行命令脚本(每小节的"检查方法"部分有详细的命令脚本). 登陆数据库的命令: sqlplus "sys/password as sysdba"   一.内存性能评估

SLB配置健康检查/会话保持

  现在,您已经定义好了一个SLB实例的名称.服务协议及服务端口号.接下来进行健康检查及会话保持的相关配置.整个负载均衡服务将依照您的配置自动运行,并对作为负载均衡服务的云服务器进行健康检查.如果某一云服务器出现故障,它会自动将该云服务器从您的负载均衡服务中移除,而当该云服务器恢复正常运行时,健康检查服务会将其自动加入您的负载均衡服务.为了为了保证用户会话能转发到固定的云服务上,您可以开启会话保持功能,负载均衡服务将会把来自同一客户端的访问请求分发到同一台云服务器上进行处理. HTTP协议配置

【业务不裸奔系列】10秒创建本地健康检查(支持VPC环境)

应用场景 定期探测本地指定路径或端口是否正常响应,当出现响应超时或状态码错误时,发送报警通知.快速发现进程存活但不再正常响应的情况. 偷偷告诉你对进程挂掉.不响应假死特别有效果. 使用步骤 首先要按照业务创建应用分组哦,这样可以快速将散乱的资源有序管理起来.友情传送>>如何创建应用分组? 进入云监控应用分组的"可用性监控"页面, 点击页面右上角的新建配置按钮,进入编辑页面.选择HTTP请求填写探测路径或者选择Telnet请求填写端口号. 点击确认保存任务,探测不通发生报警时

Docker 容器健康检查机制

在分布式系统中,经常需要利用健康检查机制来检查服务的可用性,防止其他服务调用时出现异常. 对于容器而言,最简单的健康检查是进程级的健康检查,即检验进程是否存活.Docker Daemon会自动监控容器中的PID1进程,如果docker run命令中指明了restart policy,可以根据策略自动重启已结束的容器.在很多实际场景下,仅使用进程级健康检查机制还远远不够.比如,容器进程虽然依旧运行却由于应用死锁无法继续响应用户请求,这样的问题是无法通过进程监控发现的. 在Kubernetes提供了