db2 rollforward的練習

來源:互聯網
上載者:User

db2 rollforward的練習

--rollforward的練習--開啟歸檔日誌db2 update db cfg using LOGARCHMETH1 DISK:/home/db2inst1/archlog1/--備份資料庫db2 backup database mydb1 online to ~/backup/ compress/*Backup successful. The timestamp for this backup image is : 20120725232200*/db2 connect to mydb1db2 "create table tb1 (id integer generated always as identity(start with 1, increment by 1), name varchar(50))"db2 "insert into tb1(name) values('a')"--記錄時間戳記db2 "select current timestamp from sysibm.sysdummy1"/*1--------------------------2012-07-25-23.22.53.757978  1 record(s) selected.*/--插入後續資料db2 "insert into tb1(name) values('b')"--db2 connect reset--強制重新整理歸檔日誌,如果沒有重新整理的話無法通過歸檔日誌來進行還原db2 archive log for db mydb1--還原完整備份db2 restore database mydb1 from ~/backup/ taken at 20120725232200--前滾到上面登記的時間戳記,並完成前滾db2 rollforward database mydb1 to 2012-07-25-23.22.53.757978 using local time and stop--請留意這裡的Last committed transaction的時間會將原來的歸檔路徑上的記錄檔時間覆蓋掉,導致這次還原後無法再次還原到該時間後的資料。/*                                 Rollforward Status Input database alias                   = mydb1 Number of nodes have returned status   = 1 Node number                            = 0 Rollforward status                     = DB  working Next log file to be read               = S0000017.LOG Log files processed                    = S0000016.LOG - S0000016.LOG Last committed transaction             = 2012-07-25-23.22.45.000000 Local*/--db2 connect to mydb1--驗證還原後的時間單是否正確。查看資料剛好是在a插入後的時間db2 "select * from tb1"/*ID          NAME----------- --------------------------------------------------          1 a  1 record(s) selected.*/--特別注意:如果還原了一次資料庫後因為歸檔日誌位置相同的原因會導致產生了該時間點新的歸檔日誌,覆蓋了最後事務提交時間。所以無法再重新還原並前滾到最後前滾時間(上面例子中的時間2012-07-25-23.22.45.000000 Local)之前,這個需要特別注意。所以建議可以將歸檔日誌複製到其他位置後再進行還原作業

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.