oracleTraceFileAnalyzer(TFA)使用方法(含BUG解决)一

oracletracefileanalyzer(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作为新出来的工具,在一些细节方面可能支持不太好,本章先到收集,下一章讲演示,查询剪切后日志信息。

(0)
上一篇 2022年3月22日
下一篇 2022年3月22日

相关推荐