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 <command> [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 <command> -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