Home Database Mysql Tutorial 用热备+归档恢复损坏的非系统表空间

用热备+归档恢复损坏的非系统表空间

Jun 07, 2016 pm 04:10 PM
Archive recover us space system

通常,我们都是用RMAN去还原数据文件,再利用归档做恢复,如果没有有效的备份集,但是有热备份生成的文件,那么一样可以进行恢复,这里演示的是非系统表空间对应的数据文件损坏后的恢复。 --首先获取热备份的语句 SQL select 'alter tablespace '||tablespace

通常,我们都是用RMAN去还原数据文件,再利用归档做恢复,如果没有有效的备份集,但是有热备份生成的文件,那么一样可以进行恢复,这里演示的是非系统表空间对应的数据文件损坏后的恢复。
--首先获取热备份的语句 SQL> select 'alter tablespace '||tablespace_name|| ' begin backup;'
2 ||chr(10) 3 ||'cp '||file_name||' /u01/' 4 ||chr(10) 5 ||'alter tablespace '||tablespace_name|| ' end backup;' as "script" 6 from dba_data_files where tablespace_name='ZLM';
script -------------------------------------------------------------------------------- alter tablespace ZLM begin backup; cp /u01/app/oracle/oradata/ora10g/zlm01.dbf /u01/ alter tablespace ZLM end backup;

SQL> alter tablespace ZLM begin backup;
SQL> ! [oracle@ora10g ~]$ cp /u01/app/oracle/oradata/ora10g/zlm01.dbf /u01/ [oracle@ora10g ~]$ exit exit
SQL> alter tablespace ZLM end backup;
--验证热备已经产生 SQL> select * from v$backup;
FILE# STATUS CHANGE# TIME ---------- ------------------ ---------- ---------- 1 NOT ACTIVE 0 2 NOT ACTIVE 0 3 NOT ACTIVE 0 4 NOT ACTIVE 0 5 NOT ACTIVE 0 6 NOT ACTIVE 1340174 2014-11-28
6 rows selected.
--连接到测试用户开始执行事务 SQL> conn zlm/zlm Connected. SQL> create table emp as select * from scott.emp;
Table created.
SQL> set lin 130 SQL> set pages 130 SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- ---------- ---------- ---------- ---------- 7369 SMITH CLERK 7902 1980-12-17 800 20 7499 ALLEN SALESMAN 7698 1981-02-20 1600 300 30 7521 WARD SALESMAN 7698 1981-02-22 1250 500 30 7566 JONES MANAGER 7839 1981-04-02 2975 20 7654 MARTIN SALESMAN 7698 1981-09-28 1250 1400 30 7698 BLAKE MANAGER 7839 1981-05-01 2850 30 7782 CLARK MANAGER 7839 1981-06-09 2450 10 7788 SCOTT ANALYST 7566 1987-04-19 3000 20 7839 KING PRESIDENT 1981-11-17 5000 10 7844 TURNER SALESMAN 7698 1981-09-08 1500 0 30 7876 ADAMS CLERK 7788 1987-05-23 1100 20 7900 JAMES CLERK 7698 1981-12-03 950 30 7902 FORD ANALYST 7566 1981-12-03 3000 20 7934 MILLER CLERK 7782 1982-01-23 1300 10
14 rows selected.
SQL> update emp set sal=sal+100;
14 rows updated.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> update emp set sal=sal+100;
14 rows updated.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> update emp set sal=sal+100;
14 rows updated.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> update emp set sal=sal+100;
14 rows updated.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
一共执行了4次update操作,并切换了4次日志
--查看当前的数据 SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- ---------- ---------- ---------- ---------- 7369 SMITH CLERK 7902 1980-12-17 1200 20 7499 ALLEN SALESMAN 7698 1981-02-20 2000 300 30 7521 WARD SALESMAN 7698 1981-02-22 1650 500 30 7566 JONES MANAGER 7839 1981-04-02 3375 20 7654 MARTIN SALESMAN 7698 1981-09-28 1650 1400 30 7698 BLAKE MANAGER 7839 1981-05-01 3250 30 7782 CLARK MANAGER 7839 1981-06-09 2850 10 7788 SCOTT ANALYST 7566 1987-04-19 3400 20 7839 KING PRESIDENT 1981-11-17 5400 10 7844 TURNER SALESMAN 7698 1981-09-08 1900 0 30 7876 ADAMS CLERK 7788 1987-05-23 1500 20 7900 JAMES CLERK 7698 1981-12-03 1350 30 7902 FORD ANALYST 7566 1981-12-03 3400 20 7934 MILLER CLERK 7782 1982-01-23 1700 10
14 rows selected.
--破坏数据文件 SQL> ! [oracle@ora10g ~]$ cat >> abc.txt abc > efg > hij > EOF [oracle@ora10g ~]$ cat abc.txt abc efg hij [oracle@ora10g ~]$ cp abc.txt /u01/app/oracle/oradata/ora10g/zlm01.dbf [oracle@ora10g ~]$ cat /u01/app/oracle/oradata/ora10g/zlm01.dbf abc efg hij [oracle@ora10g ~]$
--切换日志3次后继续执行查看 SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> select * from emp; select * from emp * ERROR at line 1: ORA-00376: file 6 cannot be read at this time ORA-01110: data file 6: '/u01/app/oracle/oradata/ora10g/zlm01.dbf'
SQL> ! [oracle@ora10g ~]$ cp /u01/zlm01.dbf /u01/app/oracle/oradata/ora10g/zlm01.dbf [oracle@ora10g ~]$ exit exit
SQL> select * from emp; select * from emp * ERROR at line 1: ORA-00376: file 6 cannot be read at this time ORA-01110: data file 6: '/u01/app/oracle/oradata/ora10g/zlm01.dbf'
把原来热备生成的文件替换掉损坏的6号文件,依然提示无法读取
--把故障文件offline后再online SQL> alter database datafile 6 offline;

Database altered.
SQL> alter database datafile 6 online; alter database datafile 6 online * ERROR at line 1: ORA-01113: file 6 needs media recovery ORA-01110: data file 6: '/u01/app/oracle/oradata/ora10g/zlm01.dbf'
此时,会提示6号文件需要做介质恢复
SQL> col error for a10 SQL> select * from v$recover_file;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME ---------- ------- ------- ---------- ---------- ---------- 6 OFFLINE OFFLINE 1385889 2014-11-29
可以看到6号文件现在是offline状态,需要做恢复
SQL> select * from v$recovery_log;
THREAD# SEQUENCE# TIME ---------- ---------- ---------- ARCHIVE_NAME ---------------------------------------------------------------------------------------------------------------------------------- 1 58 2014-11-29 /u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_58_b7mbppk8_.arc
1 59 2014-11-29 /u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_59_b7mbsb96_.arc
1 60 2014-11-29 /u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_60_b7mbt18j_.arc
1 61 2014-11-29 /u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_61_b7mbtoy8_.arc
1 62 2014-11-29 /u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_62_b7mbw693_.arc
1 63 2014-11-29 /u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_63_b7mc54hm_.arc

6 rows selected.
v$recovery_log这个视图中查询到的,都是恢复需要用到的归档日志文件
SQL> recover datafile 6; ORA-00279: change 1385889 generated at 11/29/2014 18:46:26 needed for thread 1 ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_58_%u_.arc ORA-00280: change 1385889 for thread 1 is in sequence #58

Specify log: {=suggested | filename | AUTO | CANCEL} auto ORA-00279: change 1387492 generated at 11/29/2014 19:15:34 needed for thread 1 ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_59_%u_.arc ORA-00280: change 1387492 for thread 1 is in sequence #59 ORA-00278: log file '/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_58_b7mbppk8_.arc' no longer needed for this recovery

ORA-00279: change 1387536 generated at 11/29/2014 19:16:58 needed for thread 1 ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_60_%u_.arc ORA-00280: change 1387536 for thread 1 is in sequence #60 ORA-00278: log file '/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_59_b7mbsb96_.arc' no longer needed for this recovery

ORA-00279: change 1387553 generated at 11/29/2014 19:17:21 needed for thread 1 ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_61_%u_.arc ORA-00280: change 1387553 for thread 1 is in sequence #61 ORA-00278: log file '/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_60_b7mbt18j_.arc' no longer needed for this recovery

ORA-00279: change 1387562 generated at 11/29/2014 19:17:41 needed for thread 1 ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_62_%u_.arc ORA-00280: change 1387562 for thread 1 is in sequence #62 ORA-00278: log file '/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_61_b7mbtoy8_.arc' no longer needed for this recovery

ORA-00279: change 1387587 generated at 11/29/2014 19:18:30 needed for thread 1 ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_63_%u_.arc ORA-00280: change 1387587 for thread 1 is in sequence #63 ORA-00278: log file '/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_11_29/o1_mf_1_62_b7mbw693_.arc' no longer needed for this recovery

Log applied. Media recovery complete.
当把v$recovery_log中列出的5个归档日志全部应用后,介质恢复完成
--再次把6号文件online SQL> alter database datafile 6 online;

Database altered.
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- ---------- ---------- ---------- ---------- 7369 SMITH CLERK 7902 1980-12-17 1200 20 7499 ALLEN SALESMAN 7698 1981-02-20 2000 300 30 7521 WARD SALESMAN 7698 1981-02-22 1650 500 30 7566 JONES MANAGER 7839 1981-04-02 3375 20 7654 MARTIN SALESMAN 7698 1981-09-28 1650 1400 30 7698 BLAKE MANAGER 7839 1981-05-01 3250 30 7782 CLARK MANAGER 7839 1981-06-09 2850 10 7788 SCOTT ANALYST 7566 1987-04-19 3400 20 7839 KING PRESIDENT 1981-11-17 5400 10 7844 TURNER SALESMAN 7698 1981-09-08 1900 0 30 7876 ADAMS CLERK 7788 1987-05-23 1500 20 7900 JAMES CLERK 7698 1981-12-03 1350 30 7902 FORD ANALYST 7566 1981-12-03 3400 20 7934 MILLER CLERK 7782 1982-01-23 1700 10
14 rows selected.
此时,表空间ZLM及对应的数据文件zlm01.dbf都已经顺利地恢复了





Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1663
14
PHP Tutorial
1264
29
C# Tutorial
1237
24
How to recover expired WeChat files? Can expired WeChat files be recovered? How to recover expired WeChat files? Can expired WeChat files be recovered? Feb 22, 2024 pm 02:46 PM

Open WeChat, select Settings in Me, select General and then select Storage Space, select Management in Storage Space, select the conversation in which you want to restore files and select the exclamation mark icon. Tutorial Applicable Model: iPhone13 System: iOS15.3 Version: WeChat 8.0.24 Analysis 1 First open WeChat and click the Settings option on the My page. 2 Then find and click General Options on the settings page. 3Then click Storage Space on the general page. 4 Next, click Manage on the storage space page. 5Finally, select the conversation in which you want to recover files and click the exclamation mark icon on the right. Supplement: WeChat files generally expire in a few days. If the file received by WeChat has not been clicked, the WeChat system will clear it after 72 hours. If the WeChat file has been viewed,

How to recover browsing history in incognito mode How to recover browsing history in incognito mode Feb 19, 2024 pm 04:22 PM

Private browsing is a very convenient way to browse and protect your privacy when surfing the Internet on your computer or mobile device. Private browsing mode usually prevents the browser from recording your visit history, saving cookies and cache files, and preventing the website you are browsing from leaving any traces in the browser. However, for some special cases, we may need to restore the browsing history of Incognito Browsing. First of all, we need to make it clear: the purpose of private browsing mode is to protect privacy and prevent others from obtaining the user’s online history from the browser. Therefore, incognito browsing

CUDA's universal matrix multiplication: from entry to proficiency! CUDA's universal matrix multiplication: from entry to proficiency! Mar 25, 2024 pm 12:30 PM

General Matrix Multiplication (GEMM) is a vital part of many applications and algorithms, and is also one of the important indicators for evaluating computer hardware performance. In-depth research and optimization of the implementation of GEMM can help us better understand high-performance computing and the relationship between software and hardware systems. In computer science, effective optimization of GEMM can increase computing speed and save resources, which is crucial to improving the overall performance of a computer system. An in-depth understanding of the working principle and optimization method of GEMM will help us better utilize the potential of modern computing hardware and provide more efficient solutions for various complex computing tasks. By optimizing the performance of GEMM

Huawei's Qiankun ADS3.0 intelligent driving system will be launched in August and will be launched on Xiangjie S9 for the first time Huawei's Qiankun ADS3.0 intelligent driving system will be launched in August and will be launched on Xiangjie S9 for the first time Jul 30, 2024 pm 02:17 PM

On July 29, at the roll-off ceremony of AITO Wenjie's 400,000th new car, Yu Chengdong, Huawei's Managing Director, Chairman of Terminal BG, and Chairman of Smart Car Solutions BU, attended and delivered a speech and announced that Wenjie series models will be launched this year In August, Huawei Qiankun ADS 3.0 version was launched, and it is planned to successively push upgrades from August to September. The Xiangjie S9, which will be released on August 6, will debut Huawei’s ADS3.0 intelligent driving system. With the assistance of lidar, Huawei Qiankun ADS3.0 version will greatly improve its intelligent driving capabilities, have end-to-end integrated capabilities, and adopt a new end-to-end architecture of GOD (general obstacle identification)/PDP (predictive decision-making and control) , providing the NCA function of smart driving from parking space to parking space, and upgrading CAS3.0

How to restore chat spark on TikTok How to restore chat spark on TikTok Mar 16, 2024 pm 01:25 PM

On Douyin, a short video platform full of creativity and vitality, we can not only enjoy a variety of exciting content, but also have in-depth communications with like-minded friends. Among them, chat sparks are an important indicator of the intensity of interaction between the two parties, and they often inadvertently ignite the emotional bonds between us and our friends. However, sometimes due to some reasons, the chat spark may be disconnected. So what should we do if we want to restore the chat spark? This tutorial guide will bring you a detailed introduction to the content strategy, hoping to help everyone. How to restore the spark of Douyin chat? 1. Open the Douyin message page and select a friend to chat. 2. Send messages and chat to each other. 3. If you send messages continuously for 3 days, you can get the spark logo. On a 3-day basis, send pictures or videos to each other

How to restore Xiaomi Cloud photo album to local How to restore Xiaomi Cloud photo album to local Feb 24, 2024 pm 03:28 PM

How to restore Xiaomi Cloud Photo Album to local? You can restore Xiaomi Cloud Photo Album to local in Xiaomi Cloud Photo Album APP, but most friends don’t know how to restore Xiaomi Cloud Photo Album to local. The next step is to restore Xiaomi Cloud Photo Album to local. Local method graphic tutorials, interested users come and take a look! How to restore Xiaomi cloud photo album to local 1. First open the settings function in Xiaomi phone and select [Personal Avatar] on the main interface; 2. Then enter the Xiaomi account interface and click the [Cloud Service] function; 3. Then jump to Xiaomi For the function of cloud service, select [Cloud Backup]; 4. Finally, in the interface as shown below, click [Cloud Album] to restore the album to local.

Always new! Huawei Mate60 series upgrades to HarmonyOS 4.2: AI cloud enhancement, Xiaoyi Dialect is so easy to use Always new! Huawei Mate60 series upgrades to HarmonyOS 4.2: AI cloud enhancement, Xiaoyi Dialect is so easy to use Jun 02, 2024 pm 02:58 PM

On April 11, Huawei officially announced the HarmonyOS 4.2 100-machine upgrade plan for the first time. This time, more than 180 devices will participate in the upgrade, covering mobile phones, tablets, watches, headphones, smart screens and other devices. In the past month, with the steady progress of the HarmonyOS4.2 100-machine upgrade plan, many popular models including Huawei Pocket2, Huawei MateX5 series, nova12 series, Huawei Pura series, etc. have also started to upgrade and adapt, which means that there will be More Huawei model users can enjoy the common and often new experience brought by HarmonyOS. Judging from user feedback, the experience of Huawei Mate60 series models has improved in all aspects after upgrading HarmonyOS4.2. Especially Huawei M

How to add swap space on Ubuntu 22.04 LTS How to add swap space on Ubuntu 22.04 LTS Feb 20, 2024 am 11:12 AM

Swap space plays an important role in Linux systems, especially when the system is low on memory. It acts as a backup memory storage space that helps the system run smoothly and maintain stability even under high load. This article provides you with a detailed guide to adding swap space on Ubuntu 22.04LTS to ensure that your system performance is optimized and can handle various workloads. Understanding Swap Space Swap space provides virtual memory that is used to supplement the system's physical RAM. When the system is low on RAM, the kernel swaps data to disk to prevent out-of-memory and system crashes. Linux systems commonly use swap space to handle this situation. Run multiple memory-intensive applications simultaneously to process very large files or data

See all articles