DBA考題:你发现user表空间所在的硬盘(DISK1)已经快要满了,你想把它移到另一个I/O操作很少的硬盘上(DISK8)。请你写出操作的步骤。
類似解法:
採用offline的方式
第一步,將表空間offline
alter tablespace tablespace_name offline;
第二步,cp文件到新的目錄並rename修改控制文件
第三步,將相應表空間online
當然這種方式同樣會影響期間的表空間使用。
以下是簡單的示範步驟:
1.將表空間offline
[oracle@jumper oracle]$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.4.0 - Production on Sat Nov 12 18:14:21 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Enabled
Archive destination /opt/oracle/oradata/conner/archive
Oldest online log sequence 6
Current log sequence 9
SQL> select name from v$datafile;
NAME
---------------------------------------------------------
/opt/oracle/oradata/conner/system01.dbf
/opt/oracle/oradata/conner/undotbs01.dbf
/opt/oracle/oradata/conner/users01.dbf
SQL> alter tablespace users offline;
Tablespace altered.
2.拷貝相應的數據文件
SQL> ! cp /opt/oracle/oradata/conner/users01.dbf /opt/oracle/oradata/users01.dbf
(這裡也可以直接用copy到想要的地方 不一定要通過指令,移動到想要的地方後使用PWD看位置)
SQL> alter tablespace users rename datafile '/opt/oracle/oradata/conner/users01.dbf'
to '/opt/oracle/oradata/users01.dbf’;
Tablespace altered.
3.將表空間online
SQL> alter tablespace users online;
Tablespace altered.
SQL> select name from v$datafile;
NAME
------------------------------------------------------------------------
/opt/oracle/oradata/conner/system01.dbf
/opt/oracle/oradata/conner/undotbs01.dbf
/opt/oracle/oradata/users01.dbf
-----------------------------------------------------------------------------------------------------------
使用alter database 移動數據文件時,在執行完alter database rename <source file path> to <des file path>命令之後,再試圖打開:alter database open。報錯:
ORA-01113:文件7需要介質恢復
ORA-01110:數據文件7:’E:ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEST01.DBF’。
這是由於數據庫認爲這個數據文件遭到破壞了,需要使用命令通過、日誌信息來恢復。數據庫的備份恢復是個比較複雜的問題,但是這個實例的解決辦法還是比較簡單的。
執行命令:
recover datafile ’E:ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEST01.DBF’
提示完成介質恢復,再打開數據庫:alter database open。一切正常。
轉至:http://www.itkee.com/database/detail-1315.html
留言列表