MSCBSC 移動通信論壇
搜索
登錄注冊
網(wǎng)絡(luò)優(yōu)化工程師招聘專欄 4G/LTE通信工程師最新職位列表 通信實習(xí)生/應(yīng)屆生招聘職位

  • 閱讀:3973
  • 回復(fù):0
[交流] alter system switch logfile
kimmy257
銀牌會員
鎵嬫満鍙風(fēng)爜宸查獙璇? style=


 發(fā)短消息    關(guān)注Ta 

積分 3937
帖子 470
威望 11733 個
禮品券 10 個
專家指數(shù) 18
注冊 2009-7-14
專業(yè)方向  Oracle DBA
回答問題數(shù) 0
回答被采納數(shù) 0
回答采納率 0%
 
發(fā)表于 2013-04-21 23:17:03  只看樓主 
alter system switch logfile

此語句的作用是強制系統(tǒng)進行日志切換

SQL> show parameter log_archive
NAMETYPEVALUE
------------------------------------ ----------- ------------------------------
log_archive_config string
log_archive_deststring
log_archive_dest_1 string
log_archive_dest_10string
log_archive_dest_2 string
log_archive_dest_3 string
log_archive_dest_4 string
log_archive_dest_5 string
log_archive_dest_6 string
log_archive_dest_7 string
log_archive_dest_8 string
主要區(qū)別:

ALTER SYSTEM SWITCH LOGFILE 對單實例數(shù)據(jù)庫或RAC中的當(dāng)前實例執(zhí)行日志切換。
ALTER SYSTEM ARCHIVE LOG CURRENT 會對數(shù)據(jù)庫中的所有實例執(zhí)行日志切換。


詳細解釋:

-------------------------

我們都知道在自動歸檔的數(shù)據(jù)庫中,這兩個命令幾乎產(chǎn)生的結(jié)果是一樣的。來看看oracle的解釋:
本帖最后由 YingYing 于 2010-2-28 04:39 編輯

主要區(qū)別:

ALTER SYSTEM SWITCH LOGFILE 對單實例數(shù)據(jù)庫或RAC中的當(dāng)前實例執(zhí)行日志切換。
ALTER SYSTEM ARCHIVE LOG CURRENT 會對數(shù)據(jù)庫中的所有實例執(zhí)行日志切換。


詳細解釋:

-------------------------

我們都知道在自動歸檔的數(shù)據(jù)庫中,這兩個命令幾乎產(chǎn)生的結(jié)果是一樣的。來看看oracle的解釋:

ALTER SYSTEM SWITCH LOGFILE ;
SWITCH LOGFILE Clause
The SWITCH LOGFILE clause lets you explicitly force Oracle to begin writing to a new redo log file group, regardless of whether the files in the current redo log file group are full. When you force a log switch, Oracle begins to perform a checkpoint but returns control to you immediately rather than when the checkpoint is complete. To use this clause, your instance must have the database open.
ALTER SYSTEM ARCHIVE LOG CURRENT ;
CURRENT Clause
Specify CURRENT to manually archive the current redo log file group of the specified thread, forcing a log switch. If you omit the THREAD parameter, then Oracle archives all redo log file groups from all enabled threads, including logs previous to current logs. You can specify CURRENT only when the database is open.
ALTER SYSTEM ARCHIVE LOG CURRENT NOSWITCH;
NOSWITCH
Specify NOSWITCH if you want to manually archive the current redo log file group without forcing a log switch. This setting is used primarily with standby databases to prevent data divergence when the primary database shuts down. Divergence implies the possibility of data loss in case of primary database failure.
You can use the NOSWITCH clause only when your instance has the database mounted but not open. If the database is open, then this operation closes the database automatically. You must then manually shut down the database before you can reopen it

我們首先要明白兩個事實:
一個就是在logfile switch的時候會觸發(fā)arch進程,即通知歸檔進程說那個日志可以歸檔了。
另一個是logfile switch的時候會觸發(fā)ckpt進程。而ckpt進程又會觸發(fā)dbwr進程。dbwr進程會把上一個redo中保護的儲藏在buffer cache中的dirty buffer全部寫回磁盤。然后,ckpt進程紀(jì)錄scn到controlfile中,這時會把redo log的狀態(tài)由active 變成inactive。
由此我們可以看出處于inactive狀態(tài)的redo log對于instance recovery是沒有用處了。但是它可能對于meda recovery還有用處,因為處于inactive狀態(tài)的redo log可能已經(jīng)歸檔,也可能沒有歸檔。
出現(xiàn) checkpoint not complete,unable to allocate new redo log file的錯誤,是因為lgwr要覆蓋一個其上檢查點過程沒有結(jié)束的日志文件,lgwr會等待dbwr完成,同時出現(xiàn)此錯誤。出現(xiàn)這個錯誤的原因,大概有幾點,一個是dbwr寫出速度太慢,一個是buffer cache中的臟數(shù)據(jù)太多。即事務(wù)太頻繁,另一個也可能是日志太小,或日志組太少導(dǎo)致的。
備份恢復(fù)中用到的幾個操作:

alter system checkpoint;
alter system archive log all;
alter system archive log current
alter system switch logfile;

1:alter system checkpoint;

Specify CHECKPOINT to explicitly force Oracle to perform a checkpoint, ensuring that all changes made by committed transactions are written to datafiles on disk. You can specify this clause only when your instance has the database open. Oracle does not return control to you until the checkpoint is complete.

強迫oracle進行以次檢查點,確保所有提交的事務(wù)的改變都被寫到磁盤數(shù)據(jù)文件上。但此時數(shù)據(jù)庫必須是打開的狀態(tài)。

2: alter system archive log all;

手工歸檔所有的日志文件組

3:alter system archive log current

手工歸檔活動的日志文件組。
4: alter system switch logfile;
The SWITCH LOGFILE clause lets you explicitly force Oracle to begin writing to a new redo log file group, regardless of whether the files in the current redo log file group are full. When you force a log switch, Oracle begins to perform a checkpoint but returns control to you immediately rather than when the checkpoint is complete. To use this clause, your instance must have the database open.
開始寫新的日志文件組。不管當(dāng)前日志文件組是否滿了。
掃碼關(guān)注5G通信官方公眾號,免費領(lǐng)取以下5G精品資料
  • 1、回復(fù)“YD5GAI”免費領(lǐng)取《中國移動:5G網(wǎng)絡(luò)AI應(yīng)用典型場景技術(shù)解決方案白皮書
  • 2、回復(fù)“5G6G”免費領(lǐng)取《5G_6G毫米波測試技術(shù)白皮書-2022_03-21
  • 3、回復(fù)“YD6G”免費領(lǐng)取《中國移動:6G至簡無線接入網(wǎng)白皮書
  • 4、回復(fù)“LTBPS”免費領(lǐng)取《《中國聯(lián)通5G終端白皮書》
  • 5、回復(fù)“ZGDX”免費領(lǐng)取《中國電信5G NTN技術(shù)白皮書
  • 6、回復(fù)“TXSB”免費領(lǐng)取《通信設(shè)備安裝工程施工工藝圖解
  • 7、回復(fù)“YDSL”免費領(lǐng)取《中國移動算力并網(wǎng)白皮書
  • 8、回復(fù)“5GX3”免費領(lǐng)取《 R16 23501-g60 5G的系統(tǒng)架構(gòu)1
  • 對本帖內(nèi)容的看法? 我要點評

     
    [充值威望,立即自動到帳] [VIP貴賓權(quán)限+威望套餐] 另有大量優(yōu)惠贈送活動,請光臨充值中心
    充值擁有大量的威望和最高的下載權(quán)限,下載站內(nèi)資料無憂

    快速回復(fù)主題    
    標(biāo)題 [交流] alter system switch logfile" tabindex="1">
    內(nèi)容
     上傳資料請點左側(cè)【添加附件】

    當(dāng)前時區(qū) GMT+8, 現(xiàn)在時間是 2025-02-23 21:05:41
    渝ICP備11001752號  Copyright @ 2006-2016 mscbsc.com  本站統(tǒng)一服務(wù)郵箱:mscbsc@163.com

    Processed in 0.403985 second(s), 11 queries , Gzip enabled
    TOP
    清除 Cookies - 聯(lián)系我們 - 移動通信網(wǎng) - 移動通信論壇 - 通信招聘網(wǎng) - Archiver