日期:2014-05-16  浏览次数:20615 次

更改standby库的数据文件路径

更改standby库的数据文件路径

[oracle@bldc02 ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.3.0 Production on Mon Aug 26 10:44:57 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

SQL> conn /as sysdba
Connected.

--查看standby_file_management参数
SQL> show parameter standby_file_management;

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
standby_file_management       string  AUTO

--standby_file_management参数值为AUTO,首先要将该参数置为MANUAL,才能更改数据文件路径,否则会出现
ERROR at line 1:
ORA-01511: error in renaming log/data files
ORA-01275: Operation RENAME is not allowed if standby file management is automatic.
这个信息

SQL> alter system set standby_file_management='MANUAL';

System altered.

SQL> shutdown immediate;

将数据文件复制至新目录
cp /u02/oradata/orcl01.dbf /oradata/orcl01.dbf

删除旧的数据文件

SQL> startup mount;

SQL> alter database rename file '/u02/oradata/orcl01.dbf' to '/oradata/orcl01.dbf'

SQL> alter database open;

查看数据文件是否更改到相应的文件目录下

SQL> select name from v$datafile;

SQL> create pfile='/home/oracle/initorcl.ora' from spfile;

更改pfile文件(initorcl.ora)
将standby_file_management由manual设置为auto
添加或修改db_file_name_convert='/u02/oradata/','/oradata/'

SQL> shutdown immediate;

SQL> create spfile from pfile='/home/oracle/initorcl.ora'

SQL> startup momount;

SQL> alter database mount standby database;

SQL> alter database open read only;

--应用归档日志
SQL> alter database recover managed standby database disconnect from session;