ORAchk-数据库健康检查

简介: ORAchk-数据库健康检查  原文地址:ORAchk-数据库健康检查 作者:paulyibinyi ORAchk 之前被称为RACcheck,后来它的检查范围进行了扩展,改名为了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为例:

31c2000157a69aff25c6

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

请点击此处输入图片描述

2ee3000185f404b9bc63

请点击此处输入图片描述

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

2ee3000185f545ac79a3

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

请点击此处输入图片描述

31c6000159c2ab3cff96

Patch Recommendation 是补丁建议:

请点击此处输入图片描述

31c2000157a8ca645873

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

31c2000157a9ccd2cd80

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

请点击此处输入图片描述

请点击此处输入图片描述

31c100015b44859069db

另外最耗时的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服务器都是需要认证才能发邮件,所以要给出认证信息:

31c6000159c11fa1739c

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

请点击此处输入图片描述

31c100015b45b379f9b4

请点击此处输入图片描述

邮件样例

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

31c0000449035be75b9c

请点击此处输入图片描述

Collection Manager

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

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

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

31c100015b46bb550d74

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

请点击此处输入图片描述

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

31c000044902389a66e0

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

请点击此处输入图片描述

31c2000157a7ad0007f6

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

请点击此处输入图片描述

31c000044901c5e64578

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

请点击此处输入图片描述

31c6000159c384fbeddf

请点击此处输入图片描述

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

31c6000159c4f637adf0

请点击此处输入图片描述

另外这个应用还可以进行不同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

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

31c500015bb61386d3ca

请点击此处输入图片描述

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

31c100015b470dace32c

请点击此处输入图片描述

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

31c6000159c5ab4d95e4

请点击此处输入图片描述

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




 使用oracheck进行系统巡检 

 
日常数据库巡检,是运维人员经常需要完成的工作之一。对应复杂的软硬件和系统环境,以及越来越多的系统数目,常规手段进行一次巡检的成本压力越来越大。综合性的巡检方面,自动化的执行和信息收集,才是未来巡检的一个发展方向。
Oracle Support内部的研发机构,会推出很多有用的小工具来辅助我们日常巡检诊断工具,比如OSWatcherRDAoratop。这些工具都从一定程度上解决了我们在使用Oracle数据库过程中遇到的管理和调优需求。本篇主要介绍oracheck,借助orachk,我们可以快速的进行系统巡检和故障排除。
 
1、从raccheckoracheck
 
oracheck来源于OracleRAC环境准备的工具raccheck。最早的raccheck是用于自动化Oracle RAC环境巡检而开发的,之后不断推出新的版本和功能。这些新功能中,最有意义的要属于Oracle MAAOracle最大可用性体系架构)的引入。Oracle会将MAA的最佳实践策略,融入到raccheck检查项目里面,给用户提供更加全面的巡检项目。
目前,raccheck已经正式改名为oracheck,提供从单实例数据库实例到RACOGG等多个产品系列的巡检功能。
 
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密码。
 
3oracheck使用
 
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环节中包括了数据库基本信息情况。
 
001417ti5bzb08oel0odlr.jpg 
 
首先是对于数据库需要关注问题,oracheck都给与特别的显示。在级别上,也有对应不同的类型。目前oracheck支持failwarningerrorinfo几个类型。
 
001417dzcxsx36ci3cqvo3.jpg 
 
后面包括Passed的检查项目。对于提醒的问题内容,我们点击Details,就可以跳转到详细信息部分进行解释检查。
 
001418pqquqqoxu55ubzbd.jpg 
 
上面提示的内容比较清楚。这个错误是针对内核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
 
打开报告,可以看到检验得分已经提升。
 
001418yr7a191deq11i0mm.jpg 
 
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
 
报告文件中,可以看到对比情况和变化提示。
 
001418h1kc9t0t4hnat37f.jpg 
 
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群,学习最实用的数据库技术。

img_e3029f287d989cd04bd75432ecc1c172.png
DBA笔试面试讲解
欢迎与我联系

目录
相关文章
|
12月前
|
SQL Oracle 关系型数据库
Oracle 数据库日常健康检查脚本
检查数据库和online logfile的大小 —执行一下这3个SQL,把结果贴出来,看看数据库大小和log的切换频率。
188 0
|
Oracle 关系型数据库 Unix
|
1天前
|
关系型数据库 MySQL 数据库
docker MySQL删除数据库时的错误(errno: 39)
docker MySQL删除数据库时的错误(errno: 39)
|
1天前
|
关系型数据库 MySQL 数据库连接
用Navicat备份Mysql演示系统数据库的时候出:Too Many Connections
用Navicat备份Mysql演示系统数据库的时候出:Too Many Connections
|
2天前
|
存储 Oracle 关系型数据库
oracle 数据库 迁移 mysql数据库
将 Oracle 数据库迁移到 MySQL 是一项复杂的任务,因为这两种数据库管理系统具有不同的架构、语法和功能。
15 0
|
10天前
|
关系型数据库 MySQL Linux
【MySQL-10】数据库函数-案例演示【字符串/数值/日期/流程控制函数】(代码演示&可cv代码)
【MySQL-10】数据库函数-案例演示【字符串/数值/日期/流程控制函数】(代码演示&可cv代码)
【MySQL-10】数据库函数-案例演示【字符串/数值/日期/流程控制函数】(代码演示&可cv代码)
|
10天前
|
SQL 关系型数据库 MySQL
【MySQL-5】DDL的数据库操作:查询&创建&删除&使用(可cv代码+演示图)
【MySQL-5】DDL的数据库操作:查询&创建&删除&使用(可cv代码+演示图)
|
10天前
|
SQL 关系型数据库 MySQL
【MySQL-1】理解关系型数据库&数据的数据模型
【MySQL-1】理解关系型数据库&数据的数据模型
|
11天前
|
关系型数据库 MySQL 数据库
Docker数据库Mysql
Docker数据库Mysql
|
11天前
|
存储 SQL 关系型数据库
mysql查询数据库表大小怎么操作
mysql查询数据库表大小怎么操作