oracle控制文件的恢复有备份、有控制文件创建脚本、都没有3
控制文件的恢复分两步: 1.从备份还原; 2.用重做日志恢复。 一、有备份的控制文件恢复 控制文件按备份的时间跨度分类: 1).在线镜像备份:当前控制文件,即control_files初始化参数所指向的除去损坏的控制文件以外的控制文件; 2).结构备份:控制文件备份后
控制文件的恢复分两步:
1.从备份还原;
2.用重做日志恢复。
一、有备份的控制文件恢复
控制文件按备份的时间跨度分类:
1).在线镜像备份:当前控制文件,即control_files初始化参数所指向的除去损坏的控制文件以外的控制文件;
2).结构备份:控制文件备份后,数据库的结构没发生变化(例如添加删除表空间、重做日志文件);
3).历史备份:控制文件备份后,数据库的结构发生了变化。
发现控制文件损坏后
1.SQL>shutdown abort
2.SQL>startup
提示错误ora-00205控制文件出错或ora-00227控制文件存在坏块,数据库启动到started状态
3.首先看是否存在在线镜像备份,若存在,则按以下步骤恢复:
1)查看警告日志,确定哪些控制文件损坏了;
2)将正确的控制文件复制到损坏了的控制文件的位置上;
3)SQL>alter database mount;
4)SQL>alter database open;
否则,看是否存在结构备份,若存在,按以下步骤恢复:
1)进入rman:rman target/
2)从备份中还原控制文件
RMAN>restore controlfile from autobackup;(自动备份)
或
RMAN>restore
controlfile from '手动备份的控制文件的位置';(手动备份)
3)设置数据库到mount状态
RMAN>alter database mount;
4)介质恢复
RMAN>recover database;
5)RMAN>alter database open resetlogs;
如果只有历史备份:
使用历史备份后会出现不一致,以下2种情况需要手动修复不一致:
1)备份控制文件中具有某个数据文件或表空间的信息,但实际不存在
2)备份中没有某个在线日志组的信息,但实际是存在的(在恢复时用recover database using backup controlfile在提示中输入相应的在线日志的路径)
A、对于自动修复不一致的情况,其恢复步骤与结构备份的手动备份相同
B、备份控制文件中具有某个数据文件或表空间的信息,但实际不存在
1)进入rman:rman target/
2)从备份中还原控制文件
RMAN>restore controlfile from '手动备份的控制文件的位置';(手动备份)
3)设置数据库到mount状态
RMAN>alter database mount;
4)此时不能直接回复数据库,而应使恢复操作不理睬这个丢失的数据文件或表空间
数据文件:
SQL>alter database datafile 文件号 offline;(数据文件)
恢复数据库
SQL>recover database using backup controlfile;
表空间(包括表空间内所有数据文件):
SQL>recover database skip tablespace 表空间名;
5)RMAN>alter database open resetlogs;
二、没有控制文件备份,但对控制文件做了追踪备份,即有创建控制文件的脚本
1.SQL>shutdown abort
2.SQL>startup
提示错误ora-00205控制文件出错或ora-00227控制文件存在坏块,数据库启动到started状态
3.找到备份的trace文件,并将其中创建控制文件的脚本提取出来createctl.sql
4.执行脚本createctl.sql
SQL>@createctl.sql
三、没有控制文件的备份和trace备份,此时需要手工创建控制文件
1.SQL>shutdown abort
2.SQL>startup
提示错误ora-00205控制文件出错或ora-00227控制文件存在坏块,数据库启动到started状态
3.手工创建控制文件SQL>create controlfile reuse(/set) database "数据库名" noresetlogs(/resetlogs 仅当online logs损坏的情况下才使用) noarchivelog
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 4672
LOGFILE
GROUP 1 '重做日志1的目录' SIZE 50M,
GROUP 2 '重做日志2的目录' SIZE 50M,
GROUP 3 '重做日志3的目录' SIZE 50M
DATAFILE
'数据文件目录/system01.dbf',
'数据文件目录/undotbs01.dbf',
'数据文件目录/sysaux01.dbf',
'数据文件目录/users01.dbf',
'数据文件目录/info01.dbf' (不包括temp文件)
CHARACTER SET ZHS16GBK
;
提示创建成功
4.介质恢复
sql>RECOVER DATABASE
sql>ALTER DATABASE OPEN;
sql>ALTER TABLESPACE TEMP ADD TEMPFILE 'temp文件目录/temp01.dbf'
SIZE 1244667904 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
最后恢复完成后记得备份控制文件
备份控制文件
ALTER DATABASE BACKUP CONTROLFILE TO 'F:\ORACLE\BACKUP\TEST.BAK';
alter database backup controlfile to trace as '目录';--生成创建控制文件的脚本,可通过show parameter user_dump_dest查看。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Oracle View Encryption allows you to encrypt data in the view, thereby enhancing the security of sensitive information. The steps include: 1) creating the master encryption key (MEk); 2) creating an encrypted view, specifying the view and MEk to be encrypted; 3) authorizing users to access the encrypted view. How encrypted views work: When a user querys for an encrypted view, Oracle uses MEk to decrypt data, ensuring that only authorized users can access readable data.

Deleting all data in Oracle requires the following steps: 1. Establish a connection; 2. Disable foreign key constraints; 3. Delete table data; 4. Submit transactions; 5. Enable foreign key constraints (optional). Be sure to back up the database before execution to prevent data loss.

Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

Oracle database paging uses ROWNUM pseudo-columns or FETCH statements to implement: ROWNUM pseudo-columns are used to filter results by row numbers and are suitable for complex queries. The FETCH statement is used to get the specified number of first rows and is suitable for simple queries.

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.
