oracle 11g手工热备-表空间
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle 11g手工热备-表空间相关的知识,希望对你有一定的参考价值。
手工热备必须在归档模式下进行,只读表空间不能做热备,临时表空间不需要做热备。
[email protected]> archive log list;——开启了归档
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1
[email protected]>
[email protected]> create table t8(id number) tablespace users;——创建表并插入数据提交
Table created.
[email protected]> insert into t8 values(88);
1 row created.
[email protected]> commit;
Commit complete.
[email protected]> select * from t8;
ID
----------
88
[email protected]> alter tablespace users begin backup;——开始热备users表空间
Tablespace altered.
[[email protected] ~]$ cp users01.dbf /home/oracle/——备份用户表空间数据文件
[email protected]> alter tablespace users end backup; ——结束备份users表空间
Tablespace altered.
关闭数据库,删除users数据文件,然后再启动数据库
[email protected]> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
删除users数据文件
[[email protected] PROD]$ rm -rf users01.dbf
[email protected]> startup
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 536874064 bytes
Database Buffers 289406976 bytes
Redo Buffers 6565888 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: ‘/u01/app/oracle/oradata/PROD/users01.dbf‘——报错,找不到数据文件
拷贝备份好的users数据文件到数据库原目录
mv /home/oracle/users01.dbf /u01/app/oracle/oradata/PROD ——拷贝数据文件
[email protected]> select open_mode from v$database;
OPEN_MODE
--------------------
MOUNTED
[email protected]> alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 4 needs media recovery
ORA-01110: data file 4: ‘/u01/app/oracle/oradata/PROD/users01.dbf‘
--------查询users数据文件的id为4-----------
select file_name,file_id,tablespace_name from dba_data_files where tablespace_name=‘USERS‘;
FILE_NAME FILE_ID TABLESPACE_NAME
-------------------------------------------------- ---------- ------------------------------
/u01/app/oracle/oradata/PROD/users01.dbf 4 USERS
[email protected]> recover datafile 4;——恢复数据文件4号
Media recovery complete.
[email protected]> alter database open;——打开数据文件
Database altered.
[email protected]> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
[email protected]> select * from t8;
ID
----------
88
以上是关于oracle 11g手工热备-表空间的主要内容,如果未能解决你的问题,请参考以下文章
oracle11g,18存储结构:暂时表,手工条带化,表/索引迁移表空间,删除表,外部表