Oracle DG 备库迁移数据文件存储目录

由于之前在搭建公司Oracle数据库的时候,部分实例主备库存储目前不统一,为了避免主备库切换后造成一些问题,我们对备库数据存储目录进行了迁移。本文将为大家介绍基本的迁移步骤:

1.查询当前数据文件和控制文件存储位置.

SQL> set linesize 200;

SQL> col file_name format a70;

SQL> col tablespace_name format a30;

SQL> select file_name,tablespace_name from dba_data_files;

SQL> select member from v$logfile;

SQL> select name from v$tempfile;

SQL> show parameter spfile;

SQL> show parameter control_files;

 

2.创建pfile文件.

SQL> create pfile from spfile;

 

3.关闭数据库实例.

SQL> alter database recover managed standby database cancel;
 SQL> shutdown immediate;
 $ lsnrctl stop

 

4.重新将存储挂载到新的目录下

查询当前挂载位置,卸载后并重新挂载到新的目录下

$ mount
/dev/sdb1 on /ssd/data1 type ext4 (rw)
/dev/sdc1 on /ssd/data2 type ext4 (rw)
/dev/sdd1 on /ssd/data3 type ext4 (rw)
/dev/sde1 on /ssd/data4 type ext4 (rw)
/dev/sdf1 on /ssd/data5 type ext4 (rw)
/dev/sdg1 on /ssd/data6 type ext4 (rw)
# mkdir /data1 /data2 /data3 /data4 /data5 /data6
# chown -R oracle:oinstall /data*
# umount /ssd/data1
# umount /ssd/data2
# umount /ssd/data3
# umount /ssd/data4
# umount /ssd/data5
# umount /ssd/data6
# mount /dev/sdb1 /data1
# mount /dev/sdc1 /data2
# mount /dev/sdd1 /data3
# mount /dev/sde1 /data4
# mount /dev/sdf1 /data5
# mount /dev/sdg1 /data6

 

5.修改参数文件

1. change control_files to new location。
2. remove db_file_name_convert
3. change log_archive_dest_1=’location=/data/oracle/oradata/arch’
4. remove log_file_name_convert=’/data/oracle/oradata/arch’,’/home/oracle/arch’
5. $ ln -s /home/oracle/arch /data/oracle/oradata/arch

6.启动数据库到mount状态

SQL> create spfile from pfile;

 

7.Rename数据文件在数据库中的位置.

 

SQL> alter system set standby_file_management=manual;
Rename datafile, for example:
SQL> alter database rename file ‘/ssd/data3/oracle/oradata/yhddb1/system.dbf’ to ‘/data3/oracle/oradata/yhddb1/system.dbf';
Rename redolog, for example:
alter database rename file ‘/ssd/data3/oracle/oradata/yhddb1/redo01.log’ to ‘/data3/oracle/oradata/yhddb1/redo01.log';

Rename tempfile, for example:

alter database rename file ‘/ssd/data3/oracle/oradata/yhddb1/temp01.dbf’ to ‘/data3/oracle/oradata/yhddb1/temp01.dbf';
SQL> alter system set standby_file_management=auto;

 

8.打开数据库.

$ lsnrctl start
SQL> alter database open;
SQL> alter database recover managed standby database disconnect;
SQL> alter database recover managed standby database cancel;
SQL> alter database recover managed standby database using current logfile disconnect;

 

共有 0 条评论

Top