[Oracle工程师手记]如何收集 RMAN 工作时的 10046 trace
有的时候,我需要收集 RMAN 执行时的 10046 trace ,我应该怎么作呢? RMAN 可以执行 sql 语句,例如:
RMAN>sql "alter system swtich logfile";
所以,我可以用这种方式设置 10046 trace ,让RMAN的运行获得 10046 trace。
首先,在OS上设置环境变量 NLS_DATE_FORMAT:
Windows: C:> set NLS_DATE_FORMAT=DD-MON-YYYY.HH24:MI:SS Linux/Unix Bash shell: $ export NLS_DATE_FORMAT="DD-MON-YYYY.HH24:MI:SS" Linux /Unix K Shell: $ NLS_DATE_FORMAT="DD-MON-YYYY.HH24:MI:SS" ; export NLS_DATE_FORMAT Linux /Unix C Shell: % setenv NLS_DATE_FORMAT "DD-MON-YYYY.HH24:MI:SS"
然后,在 RMAN 执行时,指定 10046:
RMAN> sql "alter session set tracefile_identifier=''rman_10046''"; RMAN> sql "alter session set events ''10046 trace name context forever,level 12''"; RMAN> run-your-commands; RMAN> exit;
执行的过程:
RMAN> sql "alter session set tracefile_identifier=''rman_10046''"; sql statement: alter session set tracefile_identifier=''rman_10046'' RMAN> sql "alter session set events ''10046 trace name context forever,level 12''"; sql statement: alter session set events ''10046 trace name context forever,level 12'' RMAN> backup database; Starting backup at 08-APR-21 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/myoraclehomeapp/12.2.0.1/oracle/oradata/orcl12201/system01.dbf input datafile file number=00003 name=/myoraclehomeapp/12.2.0.1/oracle/oradata/orcl12201/sysaux01.dbf input datafile file number=00004 name=/myoraclehomeapp/12.2.0.1/oracle/oradata/orcl12201/undotbs01.dbf input datafile file number=00007 name=/myoraclehomeapp/12.2.0.1/oracle/oradata/orcl12201/users01.dbf channel ORA_DISK_1: starting piece 1 at 08-APR-21 channel ORA_DISK_1: finished piece 1 at 08-APR-21 piece handle=/myoraclehomeapp/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/04vropou_1_1 tag=TAG20210408T070254 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:17 Finished backup at 08-APR-21 Starting Control File and SPFILE Autobackup at 08-APR-21 piece handle=/myoraclehomeapp/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/c-1362151495-20210408-01 comment=NONE Finished Control File and SPFILE Autobackup at 08-APR-21 RMAN> exit;
执行完毕后,在 $ORACLE_BASE/diag/rdbms/<db_name>/<oralce_sid>/trace 下,可以看到 文件名含有 10046 的 trace 文件被生成。
-rw-r----- 1 oracle oracle 701468 Apr 8 07:05 orcl12201_ora_3246_rman_10046.trm -rw-r----- 1 oracle oracle 4879024 Apr 8 07:05 orcl12201_ora_3246_rman_10046.trc