ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 修改文件路径让数据库起来

修改文件路径让数据库起来

原创 Linux操作系统 作者:oracleclub 时间:2012-01-03 00:17:35 0 删除 编辑
SQL> create tablespace app_data datafile '/u01/app/oracle/oradata/orcl/app_data.dbf' size 20m;

Tablespace created.

SQL> create user szhr identified by szhr
  2  default tablespace app_data
  3  temporary tablespace TEMP;

SQL> grant resource,connect to szhr;

Grant succeeded.

SQL> conn szhr/szhr;
Connected.
SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
EMP                            TABLE
A                              TABLE



情景:数据文件所在的磁盘坏了,DB起不来
1,shutdown 
2,cold backup  cp
3,把app_data的数据文件 ,删除
4,mount
5,重新转地址;alter database rename file '' to '';
6,alter database open;

1,
SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/example01.dbf
/u01/app/oracle/oradata/orcl/app_data.dbf

6 rows selected.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

2,
[oracle@samlee orcl]$ pwd
/u01/app/oracle/oradata/orcl
[oracle@samlee orcl]$ cp * /disk1

3,
[oracle@samlee orcl]$ ls
app_data.dbf   control03.ctl  redo02.log    system01.dbf   users01.dbf
control01.ctl  example01.dbf  redo03.log    temp01.dbf
control02.ctl  redo01.log     sysaux01.dbf  undotbs01.dbf
[oracle@samlee orcl]$ rm app_data.dbf 

SQL> startup
ORACLE instance started.

Total System Global Area  603979776 bytes
Fixed Size                  1220796 bytes
Variable Size             213913412 bytes
Database Buffers          381681664 bytes
Redo Buffers                7163904 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '/u01/app/oracle/oradata/orcl/app_data.dbf'

4,
SQL> alter database rename file '/u01/app/oracle/oradata/orcl/app_data.dbf' to '/disk1/app_data.dbf';

Database altered.

5,
SQL> alter database open;

Database altered.

SQL> select name from v$dbfile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/example01.dbf
/disk1/app_data.dbf

6 rows selected.



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26465805/viewspace-714362/,如需转载,请注明出处,否则将追究法律责任。

上一篇: IZ0_042_pdf
请登录后发表评论 登录
全部评论

注册时间:2011-11-22

  • 博文量
    61
  • 访问量
    82188