Thứ Sáu, 26 tháng 2, 2021

Khắc phục sự cố database khi mất điện đột ngột của máy chủ down

Khi thực hiện recovery database từ sự cố mất điện đột ngột của máy chủ down làm lỗi phần lớn datafile hoặc header datafile. 

Sau đây là cách xử lý để khôi phục về gần thời điểm hiện tại nhất, mất mát ít dữ liệu nhất.

Cách xử lý:

SQL> startup mount;

--Tìm được SCN 521651 (trường first_change#)
SQL> select group#, first_change#, status, archived from v$log;
run {
      restore database;
      recover database until scn 521651;
      }
Xảy ra lỗi:
ORA-01245: offline file 1 will be lost if resetlogs is done
ORA-01111: name for data file 1 is unknown - rename to correct file
ORA-01110: data file 1: '/u01/oracle/product/10.2.0/db_1/dbs/SYSTEM01.dbf'

Cause: Khi OPEN RESETLOGS thì file 1 sẽ bị mất. File này sẽ bị mất vì file đó offline. File này không offline với tuỳ chọn FOR DROP

Action: Chuyển file online và recover nó hoặc offline FOR DROP

Bước 1: 
SQL> alter  database datafile 1 offline;
Database altered.

Bươc 2:
run {
      restore database;
      recover database until scn 521651;
      }

ORA-01245: offline file 1 will be lost if resetlogs is done
ORA-01111: name for data file 1 is unknown - rename to correct file
ORA-01110: data file 1: '/u01/oracle/product/10.2.0/db_1/dbs/SYSTEM01.dbf'

Bước 3:
[oracle@localhost ~]$ rman target /
RMAN> restore datafile 1;
RMAN> recover database until scn 521651;
<.....output trimmed ...........>
<.....output trimmed ...........>
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get
error below
ORA-01245: offline file 1 will be lost if RESETLOGS is done
ORA-01110: data file 1: '/u01/oracle/product/10.2.0/db_1/dbs/SYSTEM01.dbf'

Bước 4:

SQL> alter  database datafile 1 online;
Database altered.
 
Bước 5:
SQL>alter  database open resetlogs;
Database altered.
 
SQL> select max(create_date) from  log_transaction;
        ID
----------
         25/02/2021 17:01:02

=============================
* KHOÁ HỌC ORACLE DATABASE A-Z ENTERPRISE trực tiếp từ tôi giúp bạn bước đầu trở thành những chuyên gia DBA, đủ kinh nghiệm đi thi chứng chỉ OA/OCP, đặc biệt là rất nhiều kinh nghiệm, bí kíp thực chiến trên các hệ thống Core tại VN chỉ sau 1 khoá học.
* CÁCH ĐĂNG KÝ: Gõ (.) hoặc để lại số điện thoại hoặc inbox https://m.me/tranvanbinh.vn hoặc Hotline/Zalo 090.29.12.888
* Chi tiết tham khảo:
https://bit.ly/oaz_w
hoặc
https://bit.ly/oaz_fp
=============================
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile: 0902912888
⚡️ Skype: tranbinh48ca
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: http://bit.ly/ytb_binhoraclemaster
👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhoracle
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội

=============================
học oracle database
Các tìm kiếm liên quan đến học oracle
database
Tự học Oracle
Tài liệu Oracle 12c tiếng Việt
Hướng dẫn sử dụng Oracle Database
Oracle SQL cơ bản
Oracle SQL là gì
Khóa học Oracle Hà Nội
Học chứng chỉ Oracle ở đầu
Khóa học Oracle online
khóa học pl/sql
học dba
học dba ở việt nam
khóa học dba
khóa học dba sql
tài liệu học dba oracle
Khóa học Oracle online
học oracle sql
học oracle ở đâu tphcm
học oracle bắt đầu từ đâu
học oracle ở hà nội
oracle database tutorial
oracle database 12c
oracle database là gì
oracle database 11g
oracle download
oracle database 19c
oracle dba tutorial
oracle tunning
sql tunning
oracle 12c
oracle dataguard
oracle goldengate
oracle weblogic
oracle exadata
hoc solaris
hoc linux
hoc aix

ĐỌC NHIỀU

Trần Văn Bình - Oracle Database Master