oracle Trace File Analyzer (TFA)使用方法(含BUG解决)一

12C自带了一个很好用的日志分析工具,TFA可以帮您快速分析当前数据库日志。迅速定位和分析日志,是DBA很好的帮手

一、安装

在安装12C的程序的最后一步执行root脚本的时候,会有如下提示

Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Do you want to setup Oracle Trace File Analyzer (TFA) now ? yes|[no] : 


Oracle Trace File Analyzer (TFA - User Mode) is available at :
    /u01/app/oracle/product/12.2.0/dbhome_1/suptools/tfa/release/tfa_home/bin/tfactl
OR
Oracle Trace File Analyzer (TFA - Daemon Mode) can be installed by running this script :
    /u01/app/oracle/product/12.2.0/dbhome_1/suptools/tfa/release/tfa_home/install/roottfa.sh

如果选择no,那就不会安装该工具,默认是no,如果未在安装时选择安装该工具,也可以用,文中提示的两种方式启动TFA,一种是直接到

/u01/app/oracle/product/12.2.0/dbhome_1/suptools/tfa/release/tfa_home/bin/tfactl目录下执行命令操作,另一种方式是安装到系统

使用root执行该脚本,将可以直接使用tfa命令读取日志内容

/u01/app/oracle/product/12.2.0/dbhome_1/suptools/tfa/release/tfa_home/install/roottfa.sh,执行完毕会有如下提示

    /u01/app/oracle/product/12.2.0/dbhome_1/suptools/tfa/release/tfa_home/install/roottfa.sh
Installing Oracle Trace File Analyzer (TFA).
Log File: /u01/app/oracle/product/12.2.0/dbhome_1/install/root_12cr2.yudean.com_2017-03-14_15-53-55.log
Finished installing Oracle Trace File Analyzer (TFA)

二、使用

安装好tfa后设置好环境变量,我们看下tfa支持哪些命令,首先是tfactl 我们用help看下有哪些我们可以使用。

[oracle@12cr2 ~]$ . oraenv
ORACLE_SID = [PROD] ? PROD1
The Oracle base has been changed from /home/oracle to /u01/app/oracle
[oracle@12cr2 ~]$ tfactl
tfactl> help                                                                  

Usage : /u01/app/oracle/tfa/bin/tfactl  [options]
    commands:diagcollect|collection|analyze|ips|run|start|stop|print|directory|toolstatus
For detailed help on each command use:
  /u01/app/oracle/tfa/bin/tfactl  -help

1、启动和关闭

命令tfactl start 和tfactl stop

2、查看当前哪些用户可以使用tfactl

该命令一般使用TFA admin权限的用户,使用安装TFA的用户执行,这里是root用户

tfactl> access lsusers                                                        

.---------------------------------.
|        TFA Users in 12cr2       |
+-----------+-----------+---------+
| User Name | User Type | Status  |
+-----------+-----------+---------+
| oracle    | USER      | Allowed |
'-----------+-----------+---------'

3、查看当前TFA主机的状态

当前我们只有一个节点,相关节点的信息如下

tfactl> print status                                                          

.--------------------------------------------------------------------------------------------.
| Host  | Status of TFA | PID | Port  | Version    | Build ID             | Inventory Status |
+-------+---------------+-----+-------+------------+----------------------+------------------+
| 12cr2 | RUNNING       | 912 | 48978 | 12.2.1.0.0 | 12210020161122170355 | COMPLETE         |
'-------+---------------+-----+-------+------------+----------------------+------------------'

4、列出当前TFA的配置信息

tfactl> print config                                                          
.------------------------------------------------------------------------------------.
|                                        12cr2                                       |
+-----------------------------------------------------------------------+------------+
| Configuration Parameter                                               | Value      |
+-----------------------------------------------------------------------+------------+
| TFA Version                                                           | 12.2.1.0.0 |
| Java Version                                                          | 1.8        |
| Public IP Network                                                     | false      |
| Automatic Diagnostic Collection                                       | true       |
| Alert Log Scan                                                        | true       |
| Disk Usage Monitor                                                    | true       |
| Managelogs Auto Purge                                                 | false      |
| Trimming of files during diagcollection                               | true       |
| Inventory Trace level                                                 | 1          |
| Collection Trace level                                                | 1          |
| Scan Trace level                                                      | 1          |
| Other Trace level                                                     | 1          |
| Repository current size (MB)                                          | 19         |
| Repository maximum size (MB)                                          | 10240      |
| Max Size of TFA Log (MB)                                              | 50         |
| Max Number of TFA Logs                                                | 10         |
| Max Size of Core File (MB)                                            | 20         |
| Max Collection Size of Core Files (MB)                                | 200        |
| Minimum Free Space to enable Alert Log Scan (MB)                      | 500        |
| Time interval between consecutive Disk Usage Snapshot(minutes)        | 60         |
| Time interval between consecutive Managelogs Auto Purge(minutes)      | 60         |
| Logs older than the time period will be auto purged(days[d]|hours[h]) | 30d        |
| Automatic Purging                                                     | true       |
| Age of Purging Collections (Hours)                                    | 12         |
| TFA IPS Pool Size                                                     | 5          |
'-----------------------------------------------------------------------+------------'
我们可以用tfactl host add /remove host 增加或者删除grid节点,也就是可以同时收集多个数据库的tfa信息。


5、列出对哪些目录进行了统计

可以看到不仅收集数据库、监听还有安装和操作系统的相关日志,看来功能很强大。

tfactl> print directories                                                                      
.------------------------------------------------------------------------------------------------------------------.
|                                                       12cr2                                                      |
+------------------------------------+-----------------------------------------------------+------------+----------+
| Trace Directory                    | Component                                           | Permission | Added By |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oraInventory/ContentsXML  | [INSTALL]                                           | public     | root     |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oraInventory/logs         | [INSTALL]                                           | public     | root     |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/cfgtoollogs        | [CFGTOOLS]                                          | public     | root     |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/diag               | [RDBMS]                                             | public     | root     |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/diag/rdbms/orcl/or | [RDBMS]{RDBMS|database=orcl, RDBMS|instance=orcl}   | public     | root     |
| cl/cdump                           |                                                     |            |          |
| Collection policy : No Exclusions  |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/diag/rdbms/orcl/or | [RDBMS]{RDBMS|database=orcl, RDBMS|instance=orcl}   | public     | root     |
| cl/trace                           |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/diag/rdbms/prod1/P | [RDBMS]{RDBMS|database=prod1, RDBMS|instance=PROD1} | public     | root     |
| ROD1/cdump                         |                                                     |            |          |
| Collection policy : No Exclusions  |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/diag/rdbms/prod1/P | [RDBMS]{RDBMS|database=prod1, RDBMS|instance=PROD1} | public     | root     |
| ROD1/trace                         |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/diag/tnslsnr/12cr2 | [TNS]                                               | public     | root     |
| /listener/cdump                    |                                                     |            |          |
| Collection policy : No Exclusions  |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/diag/tnslsnr/12cr2 | [TNS]                                               | public     | root     |
| /listener/trace                    |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/product/12.2.0/dbh | [CFGTOOLS]                                          | public     | root     |
| ome_1/cfgtoollogs                  |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/product/12.2.0/dbh | [INSTALL]                                           | public     | root     |
| ome_1/install                      |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/product/12.2.0/dbh | [RDBMS]                                             | public     | root     |
| ome_1/rdbms/log                    |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/tfa/repository/sup | [RDBMS]{RDBMS|database=orcl, RDBMS|instance=orcl}   | public     | root     |
| tools/ips/user_oracle/201703151143 |                                                     |            |          |
| 09ipscoll_12cr2/diag/rdbms/orcl/or |                                                     |            |          |
| cl/trace                           |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/tfa/repository/sup | [RDBMS]{RDBMS|database=prod1, RDBMS|instance=PROD1} | public     | root     |
| tools/ips/user_oracle/201703151143 |                                                     |            |          |
| 09ipscoll_12cr2/diag/rdbms/prod1/P |                                                     |            |          |
| ROD1/trace                         |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/tfa/repository/sup | [RDBMS]{RDBMS|database=orcl, RDBMS|instance=orcl}   | public     | root     |
| tools/ips/user_oracle/201703151144 |                                                     |            |          |
| 52ipscoll_12cr2/diag/rdbms/orcl/or |                                                     |            |          |
| cl/trace                           |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/tfa/repository/sup | [RDBMS]{RDBMS|database=prod1, RDBMS|instance=PROD1} | public     | root     |
| tools/ips/user_oracle/201703151144 |                                                     |            |          |
| 52ipscoll_12cr2/diag/rdbms/prod1/P |                                                     |            |          |
| ROD1/trace                         |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/tfa/repository/sup | [RDBMS]{RDBMS|database=orcl, RDBMS|instance=orcl}   | public     | root     |
| tools/ips/user_oracle/201703201505 |                                                     |            |          |
| 49ipscoll_12cr2/diag/rdbms/orcl/or |                                                     |            |          |
| cl/trace                           |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/tfa/repository/sup | [RDBMS]{RDBMS|database=prod1, RDBMS|instance=PROD1} | public     | root     |
| tools/ips/user_oracle/201703201505 |                                                     |            |          |
| 49ipscoll_12cr2/diag/rdbms/prod1/P |                                                     |            |          |
| ROD1/trace                         |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/tfa/repository/sup | [RDBMS]{RDBMS|database=orcl, RDBMS|instance=orcl}   | public     | root     |
| tools/ips/user_oracle/201703201519 |                                                     |            |          |
| 20ipscoll_12cr2/diag/rdbms/orcl/or |                                                     |            |          |
| cl/trace                           |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/tfa/repository/sup | [RDBMS]{RDBMS|database=prod1, RDBMS|instance=PROD1} | public     | root     |
| tools/ips/user_oracle/201703201519 |                                                     |            |          |
| 20ipscoll_12cr2/diag/rdbms/prod1/P |                                                     |            |          |
| ROD1/trace                         |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/tfa/repository/sup | [RDBMS]{RDBMS|database=orcl, RDBMS|instance=orcl}   | public     | root     |
| tools/ips/user_root/20170320155302 |                                                     |            |          |
| ipscoll_12cr2/user_root/diag/rdbms |                                                     |            |          |
| /orcl/orcl/trace                   |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /u01/app/oracle/tfa/repository/sup | [RDBMS]{RDBMS|database=prod1, RDBMS|instance=PROD1} | public     | root     |
| tools/ips/user_root/20170320155302 |                                                     |            |          |
| ipscoll_12cr2/user_root/diag/rdbms |                                                     |            |          |
| /prod1/PROD1/trace                 |                                                     |            |          |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /var/adm                           | [OS]                                                | public     | root     |
| Collection policy : Exclusions     |                                                     |            |          |
+------------------------------------+-----------------------------------------------------+------------+----------+
| /var/log                           | [OS:RACDBCLOUD]                                     | public     | root     |
| Collection policy : Exclusions     |                                                     |            |          |
'------------------------------------+-----------------------------------------------------+------------+----------'
当让您也可以增加或者删除目录,命令如下

增加目录 

tfactl directory add dir [ -public ] 
[ -exclusions | -noexclusions | -collectall ] 
[ -node all | n1,n2,... ]

删除目录 tfactl directory remove dir [ -node all | n1,n2,... ]

6、收集日志信息

如果您使用了中文字符集也就是LANG=zh_CN.UTF-8的话接下来就会出现BUG ,Illegal parameter passed to diagcollection -z

[root@12cr2 ~]# echo $LANG
zh_CN.UTF-8
[root@12cr2 ~]# tfactl diagcollect -database PROD1

Collecting data for the last 12 hours for this component ...
Collecting data for all nodes

Collection Id : 2017032116573212cr2

Detailed Logging at : /u01/app/oracle/tfa/repository/collection_二_3月_21_16_57_32_CST_2017_node_all/diagcollect_20170321165732_12cr2.log
Illegal parameter passed to diagcollection -z

FAILED


这个错误原因找了很久,找不到这个logging 的日志,度娘是找不到相关信息的,最终猜想应该是文件中包含了中文名称导致收集失败,试着将字符集换成英文,结果成功了

[root@12cr2 ~]# export LANG=en_US
[root@12cr2 ~]# echo $LANG
en_US
[root@12cr2 ~]# tfactl diagcollect -database PROD1

Collecting data for the last 12 hours for this component ...
Collecting data for all nodes

Collection Id : 2017032117030312cr2

Detailed Logging at : /u01/app/oracle/tfa/repository/collection_Tue_Mar_21_17_03_03_CST_2017_node_all/diagcollect_20170321170303_12cr2.log
2017/03/21 17:03:07 CST : Collection Name : tfa_Tue_Mar_21_17_03_03_CST_2017.zip
2017/03/21 17:03:07 CST : Collecting diagnostics from hosts : [12cr2]
2017/03/21 17:03:07 CST : Scanning of files for Collection in progress...
2017/03/21 17:03:07 CST : Collecting additional diagnostic information...
2017/03/21 17:03:12 CST : Getting list of files satisfying time range [03/21/2017 05:03:07 CST, 03/21/2017 17:03:12 CST]
2017/03/21 17:03:13 CST : Collecting ADR incident files...
2017/03/21 17:03:29 CST : Completed collection of additional diagnostic information...
2017/03/21 17:03:33 CST : Completed Local Collection
.---------------------------------.
|        Collection Summary       |
+-------+-----------+------+------+
| Host  | Status    | Size | Time |
+-------+-----------+------+------+
| 12cr2 | Completed | 63kB |  26s |
'-------+-----------+------+------'

Logs are being collected to: /u01/app/oracle/tfa/repository/collection_Tue_Mar_21_17_03_03_CST_2017_node_all
/u01/app/oracle/tfa/repository/collection_Tue_Mar_21_17_03_03_CST_2017_node_all/12cr2.tfa_Tue_Mar_21_17_03_03_CST_2017.zip


顺利收集成功,TFA作为新出来的工具,在一些细节方面可能支持不太好,本章先到收集,下一章讲演示,查询剪切后日志信息。





你可能感兴趣的:(oracle,知识分享)