系統級alias vs Oracle ADR功能(r5筆記第35天)
Oracle在11g中推出的新特性ADR,即Automatic Diagnostic Repository
個人理解這個工具就是能夠高效的把一些日誌檔案輕鬆管理起來。比如檢視資料庫alert日誌就不必麻煩去到對應的路徑下去找一圈,直接使用show alert即可,比如檢視現在資料庫中出現了哪些錯誤,直接通過show problem命令即可。
命令的使用也很方便。直接輸入adrci就開啟了專門的視窗來使用。如果不知道該使用哪些命令,直接使用help即可。
$ adrci
ADRCI: Release 11.2.0.1.0 - Production on Wed May 13 22:10:14 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
ADR base = "/u02/dg11g"
adrci> help
HELP [topic]
Available Topics:
CREATE REPORT
ECHO
EXIT
HELP
HOST
IPS
PURGE
RUN
SET BASE
SET BROWSER
SET CONTROL
SET ECHO
SET EDITOR
SET HOMES | HOME | HOMEPATH
SET TERMOUT
SHOW ALERT
SHOW BASE
SHOW CONTROL
SHOW HM_RUN
SHOW HOMES | HOME | HOMEPATH
SHOW INCDIR
SHOW INCIDENT
SHOW PROBLEM
SHOW REPORT
SHOW TRACEFILE
SPOOL
There are other commands intended to be used directly by Oracle, type
"HELP EXTENDED" to see the list
TAB_OWNER=`sqlplus -silent / as sysdba <<END
set pagesize 0 feedback off verify off heading on echo off
col owner_name format a20
col table_name format a30
select value from v\$parameter where name='background_dump_dest';
exit;
END`
if [ -z "$TAB_OWNER" ]; then
echo "no object exists, please check again"
exit 0
else
echo $TAB_OWNER
fi
alias cdt='cd `ksh ~/cdt.sh` '
$ pwd
/home/ora11g
$ cdt
$ pwd
/u02/dg11g/diag/rdbms/dg11g/DG11G/trace
這個時候可以檢視相關的trace日誌,alert日誌
再來幾個使用的別名,
比如需要到引數檔案的路徑下。我們可以這麼定義別名。
alias cdp='cd $ORACLE_HOME/dbs'
$ pwd
/home/ora11g
$ cdp
$ pwd
/u01/app/ora11g/product/11.2.0/dbhome_1/dbs
比如檢視資料庫錯誤,可以這麼定義,我們可以更加靈活地把指定錯誤日誌的前後幾行內容。
alias showerr='grep -A3 -B3 ORA- `ksh ~/cdt.sh`/alert*|tail -50 '
顯示內容如下,這樣是不是也顯示得挺清晰的。
[ora11g@oel1 ~]$ showerr
License high water mark = 2
All dispatchers and shared servers shutdown
ALTER DATABASE CLOSE NORMAL
ORA-1507 signalled during: ALTER DATABASE CLOSE NORMAL...
ARCH: Archival disabled due to shutdown: 1089
Shutting down archive processes
Archiving is disabled
--
space available in the underlying filesystem or ASM diskgroup.
Error 1034 received logging on to the standby
Errors in file /u02/ora11g/diag/rdbms/test11g/TEST11G/trace/TEST11G_arc1_31285.trc:
ORA-01034: ORACLE not available
PING[ARC1]: Heartbeat failed to connect to standby 'DG11G'. Error is 1034.
Wed May 13 15:06:01 2015
Starting background process CJQ0
--
所以綜上所述,其實很多功能我們也可以自己試一試,沒準也能更加方便我們的工作,不管怎麼樣,使用方便和快捷是我們的目標。