oracle RAC——歸檔日志的開啟方法
創(chuàng)新互聯(lián)公司專注于張灣網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供張灣營銷型網(wǎng)站建設(shè),張灣網(wǎng)站制作、張灣網(wǎng)頁設(shè)計、張灣網(wǎng)站官網(wǎng)定制、微信小程序服務(wù),打造張灣網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供張灣網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
==================================
g R ? 要修改cluster_database參數(shù)? G R 和以后的版本就不需要了
例子( g R 或之前) srvctl stop database d RAC節(jié)點 sqlstartup mount SQL alter system set log_archive_dest_ = location=/racdb _arch scope=spfile sid= RAC SQL alter system set log_archive_dest_ = location=/racdb _arch scope=spfile sid= RAC SQL alter system set log_archive_dest_ = service=rac scope=spfile sid= RAC SQL alter system set log_archive_dest_ = service=rac scope=spfile sid= RAC SQL alter system set? standby_archive_dest= /racdb _arch scope=spfile sid= RAC SQL alter system set? standby_archive_dest= /racdb _arch scope=spfile sid= RAC sqlalter system set cluster_database=false scope=spfile sqlshutdown immediate sqlstartup mount sqlalter database archivelog sqlalter database open sqlalter system set cluster_database=true scope=spfile sqlshutdown immediate srvctl start database d RAC
例子( g R 或之后) 節(jié)點 SQLstartup mount SQL alter system set log_archive_dest_ = location=/racdb _arch scope=spfile sid= RAC SQL alter system set log_archive_dest_ = location=/racdb _arch scope=spfile sid= RAC SQL alter system set log_archive_dest_ = service=rac scope=spfile sid= RAC SQL alter system set log_archive_dest_ = service=rac scope=spfile sid= RAC SQL alter system set? standby_archive_dest= /racdb _arch scope=spfile sid= RAC SQL alter system set? standby_archive_dest= /racdb _arch scope=spfile sid= RAC srvctl stop database d RAC節(jié)點 SQL startup mount SQL alter database archivelog srvctl start database d RAC
測試歸檔日志的切換
節(jié)點一 二上分別執(zhí)行切換日志操作如下 SQL alter system switch logfile 操作執(zhí)行這條語句 次
節(jié)點一查詢 SQL !ls l /racdb* /racdb _arch total rw r—— oracle oinstall? Oct? _ _ dbf rw r—— oracle oinstall Oct? _ _ dbf rw r—— oracle oinstall?? Oct? _ _ dbf rw r—— oracle oinstall?? Oct? _ _ dbf rw r—— oracle oinstall?? Oct? _ _ dbf /racdb _arch total rw rw—— oracle oinstall Oct? _ _ dbf rw rw—— oracle oinstall Oct? _ _ dbf rw rw—— oracle oinstall?? Oct? _ _ dbf rw rw—— oracle oinstall?? Oct? _ _ dbf rw rw—— oracle oinstall?? Oct? _ _ dbf
節(jié)點二查詢
SQL !ls l /racdb* /racdb _arch total rw rw—— oracle oinstall? Oct? _ _ dbf rw rw—— oracle oinstall Oct? _ _ dbf rw rw—— oracle oinstall?? Oct? _ _ dbf rw rw—— oracle oinstall?? Oct? _ _ dbf rw rw—— oracle oinstall?? Oct? _ _ dbf /racdb _arch total rw r—— oracle oinstall Oct? _ _ dbf rw r—— oracle oinstall Oct? _ _ dbf rw r—— oracle oinstall?? Oct? _ _ dbf rw r—— oracle oinstall?? Oct? _ _ dbf rw r—— oracle oinstall?? Oct? _ _ dbf
節(jié)點一 SQL show parameter archive_dest NAME???????????????????????????????? TYPE??????? VALUE
log_archive_dest???????????????????? string log_archive_dest_ ?????????????????? string????? location=/racdb _arch log_archive_dest_ ????????????????? string log_archive_dest_ ?????????????????? string????? service=rac log_archive_dest_ ?????????????????? string log_archive_dest_ ?????????????????? string log_archive_dest_ ?????????????????? string log_archive_dest_ ?????????????????? string log_archive_dest_ ?????????????????? string log_archive_dest_ ?????????????????? string log_archive_dest_ ?????????????????? string log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ??????????? string????? enable log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ???????????? string????? enable standby_archive_dest???????????????? string????? /racdb _arch
節(jié)點二
SQL show parameter archive_dest NAME???????????????????????????????? TYPE??????? VALUE
log_archive_dest???????????????????? string log_archive_dest_ ?????????????????? string????? location=/racdb _arch log_archive_dest_ ????????????????? string log_archive_dest_ ?????????????????? string????? service=rac log_archive_dest_ ?????????????????? string log_archive_dest_ ?????????????????? string log_archive_dest_ ?????????????????? string log_archive_dest_ ?????????????????? string log_archive_dest_ ?????????????????? string log_archive_dest_ ?????????????????? string log_archive_dest_ ?????????????????? string log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ??????????? string????? enable log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ???????????? string????? enable log_archive_dest_state_ ???????????? string????? enable standby_archive_dest???????????????? string????? /racdb _arch
lishixinzhi/Article/program/Oracle/201311/18379
1,首先刪除歸檔日志物理文件,歸檔日志一般都是位于archive目錄下,AIX系統(tǒng)下文件格式為“1_17884_667758186.dbf”,建議操作前先對數(shù)據(jù)庫進行備份,刪除時至少保留最近幾天的日志用于數(shù)據(jù)庫恢復(fù)。
2,把歸檔日志的物理文件刪除后,我們就可以正常登入ORACLE了,但是還沒完全把歸檔日志刪除干凈,ORACLE的controlfile中仍然記錄著這些archivelog的信息,在oracle的OEM管理器中有可視化的日志展現(xiàn)出,當我們手工清除archive目錄下的文件后,這些記錄并沒有被我們從controlfile中清除掉,接下去我們要做的就是這個工作。
利用RMAN進行刪除操作,操作步驟如下:(window客戶端系統(tǒng)為例):
1.指定數(shù)據(jù)庫實例
C:/Documents and Settings/AdministratorSET ORACLE_SID =orcl
2.連接數(shù)據(jù)庫
C:/Documents and Settings/AdministratorRMAN TARGET SYS/sysadmin@orcl
3.查看歸檔日志的狀態(tài)
RMAN list archivelog all;
4.手工刪除歸檔日志文件
RMAN DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-7';
5.退出rman.
一 設(shè)置為歸檔方式
Sql代碼
sql archive log list; #查看是不是歸檔方式sql alter system set log_archive_start=true scope=spfile; #啟用主動歸檔sql alter system set log_archive_dest=''location=/oracle/ora9/oradata/arch'' scope=spfile;#設(shè)置歸檔路徑sql alter system set log_archive_dest_1=''location=/oracle/ora9/oradata/arch1'' scope=spfile;sql alter system set log_archive_dest_2=''location=/oracle/ora9/oradata/arch2'' scope=spfile;#如果歸檔到兩個位置,則可以通過上邊方法實現(xiàn)sql alter system set log_archive_format=''arch_%d_%t_%r_%s.log'' #設(shè)置歸檔日記款式sql shutdown immediate;
sql startup mount; #打開控制文件,不打開數(shù)據(jù)文件sql alter database archivelog; #將數(shù)據(jù)庫切換為歸檔模式sql alter database open; #將數(shù)據(jù)文件打開sql archive log list; #查看此時是否處于歸檔模式查詢以確定數(shù)據(jù)庫位于archivelog模式中且歸檔過程正在運行sql select log_mode from v$database;
sql select archiver from v$instance;
Sql代碼
日志切換
sql alter system switch logfile;
這次日志切換將歸檔寫到兩個目標地,
即上邊的/oracle/ora9/oradata/arch1和/oracle/ora9/oradata/arch1,要是要對目錄確認
在oracle情況中運行如下查詢:
sql select name from v$archived_log;
而后在操作系統(tǒng)中確認查詢所列出的文件
二 設(shè)置非歸檔方式
Sql代碼
sql archive log list; #查看是否是歸檔方式sql alter system set log_archive_start=false scope=spfile;#禁用自動歸檔
sql shutdown immediate;
sql startup mount; #打開控制文件,不打開數(shù)據(jù)文件sql alter database noarchivelog; #將數(shù)據(jù)庫切換為非歸檔模式sql alter database open; #將數(shù)據(jù)文件打開sql archive log list; #查看此時便處于非歸檔模式三 歸檔相關(guān)命令
Sql代碼
archive log stop;
archive log start;
archive log list;
show parameters;
show parameters log_archive_start;
show parameters log_archive_max_process; #歸檔進程數(shù)alter system set log_archive_max_process=5; #將歸檔進程數(shù)改為5select * from v$bgprocess; #檢察后臺進程
顯示歸檔日志信息
1,使用ARCHIVE LOG LIST命令可以顯示日志操作模式,歸檔位置,自動歸檔機器要歸檔的日志序列號等信息.
2顯示日志操作模式
SELECT name,log_mode FROM v$database;
3,顯示Oracle歸歸檔日志信息.
Col name format a46
Select name, swquence#, first_change# FROM v$archived_log;
Name用于表示Oracle歸歸檔日志文件名,sequence#用于表示歸檔日志對應(yīng)的日志序列號,firs_change#用于標識歸檔日志的起始SCN值.
4、執(zhí)行介質(zhì) 恢復(fù) 時,需要使用歸檔日志文件,此四必須準確定位歸檔日志的存放位置.通過查詢動態(tài)性能視圖v$archive_dest可以取得歸檔日志所在目錄.
SELECT destination FROM v$archive dest;
5,顯示日志歷史信息
SELECT * FROM v$loghist;
THREAD#用于標識重做線程號,SEQUNCE#用于標識日志序列號,FIRST_CHANGE#用于標識日志序列號對應(yīng)的起始SCN值,FIRST_TIME用于標識起始SCN的發(fā)生時間.SWICTH_CHANGE#用于標識日志切換的SCN值.
6.顯示歸檔進程信息.
進行日志切換時,ARCH進程會自動將重做日志內(nèi)容復(fù)制到Oracle歸歸檔日志中,為了加快歸檔速度,應(yīng)該啟用多個ARCH進程.通過查詢動態(tài)性能視圖V$ARCHIVE_PROCESSES可以顯示所有歸檔進程的信息!
SELECT * FROM v$archive_processes;
Porcess用于標識ARCH進程的編號,status用于標識ARCH進程的狀態(tài)(ACTIVE:活動,STOPPED:未啟動),log_sequence用于標識正在進行歸檔的日志序列號,state用于標識ARCH進程的工作狀態(tài)