RAC_单实例_DG 关于两端创建表空间数据文件路径不一致的问题注意点
主库
SYS@orcl1>show parameter db_file_name_convert
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
db_file_name_convert string /u01/app/oracle/oradata/orcl/,
+DATA/orcl/datafile/, /u01/ap
p/oracle/oradata/orcl/, +DATA/
orcl/tempfile/
SYS@orcl1>show parameter db_create_file_dest
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
db_create_file_dest string +DATA
SYS@orcl1>show parameter db_unique_name
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
db_unique_name string orcl
SYS@orcl1>show parameter db_name
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
db_name string orcl
SYS@orcl1>select instance_name from v$instance;
INSTANCE_NAME
------------------------------------------------
orcl1
备库
SYS@orcldg>show parameter db_file_name_convert
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
db_file_name_convert string +DATA/orcl/datafile/, /u01/app
/oracle/oradata/orcl/, +DATA/o
rcl/tempfile/, /u01/app/oracle
/oradata/orcl/
SYS@orcldg>show parameter db_create_file_dest
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
db_create_file_dest string /u01/app/oracle/oradata/
[oracle@8h02hisadg ~]$ echo $ORACLE_BASE
/u01/app/oracle
SYS@orcldg>show parameter db_unique_name
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
db_unique_name string orcldg
SYS@orcldg>show parameter db_name
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
db_name string orcl
SYS@orcldg>select instance_name from v$instance;
INSTANCE_NAME
------------------------------------------------
orcl
可见,两端的DB_UNIQUE_NAME,INSTANCE_NAME不同。
在这种DG配置下,主库新建表空间,备库数据恢复的目录未在db_file_name_convert指定的路径,而且数据文件的名字也是系统自定义的名字
主库
SYS@orcl1>select TABLESPACE_NAME,FILE_NAME from dba_data_files;
TABLESPACE_NAME FILE_NAME
-------------------- --------------------------------------------------
SYSTEM +DATA/orcl/datafile/system.281.1011526149
SYSAUX +DATA/orcl/datafile/sysaux.280.1011526153
UNDOTBS1 +DATA/orcl/datafile/undotbs1.279.1011526155
UNDOTBS2 +DATA/orcl/datafile/undotbs2.277.1011526161
USERS +DATA/orcl/datafile/users.276.1011526161
ELON +DATA/orcl/datafile/data_elon.dbf
备库
SYS@orcl>select TABLESPACE_NAME,FILE_NAME from dba_data_files;
TABLESPACE_NAME FILE_NAME
------------------------------ ----------------------------------------------------------------------
SYSTEM /u01/app/oracle/oradata/orcl/system.281.1011526149
SYSAUX /u01/app/oracle/oradata/orcl/sysaux.280.1011526153
UNDOTBS1 /u01/app/oracle/oradata/orcl/undotbs1.279.1011526155
UNDOTBS2 /u01/app/oracle/oradata/orcl/undotbs2.277.1011526161
USERS /u01/app/oracle/oradata/orcl/users.276.1011526161
ELON /u01/app/oracle/oradata/ORCLDG/datafile/o1_mf_elon5_gk4x0sbb_.dbf
此处ORACLE自动创建以DB_UNIQUE_NAME同名的目录,并在子目录datafile下创建了自定义的数据文件
接下来、修改备库db_create_file_dest。重新在主库创建一个新的表空间。
备库
SYS@orcldg>show parameter db_create_file_dest
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
db_create_file_dest string
主库
SYS@orcl1>create tablespace elontian datafile '+DATA/orcl/datafile/data_elontian01.dbf' size 10m autoextend on;
SYS@orcl1>alter system switch logfile;
SYS@orcl1>alter system switch logfile;
SYS@orcl1>select TABLESPACE_NAME,FILE_NAME from dba_data_files;
TABLESPACE_NAME FILE_NAME
-------------------- --------------------------------------------------
SYSTEM +DATA/orcl/datafile/system.281.1011526149
SYSAUX +DATA/orcl/datafile/sysaux.280.1011526153
UNDOTBS1 +DATA/orcl/datafile/undotbs1.279.1011526155
UNDOTBS2 +DATA/orcl/datafile/undotbs2.277.1011526161
USERS +DATA/orcl/datafile/users.276.1011526161
ELON +DATA/orcl/datafile/data_elon.dbf
ELONTIAN +DATA/orcl/datafile/data_elontian01.dbf
备库
SYS@orcldg>select TABLESPACE_NAME,FILE_NAME from dba_data_files;
TABLESPACE_NAME FILE_NAME
------------------------------ ----------------------------------------------------------------------
SYSTEM /u01/app/oracle/oradata/orcl/system.281.1011526149
SYSAUX /u01/app/oracle/oradata/orcl/sysaux.280.1011526153
UNDOTBS1 /u01/app/oracle/oradata/orcl/undotbs1.279.1011526155
UNDOTBS2 /u01/app/oracle/oradata/orcl/undotbs2.277.1011526161
USERS /u01/app/oracle/oradata/orcl/users.276.1011526161
ELON /u01/app/oracle/oradata/ORCLDG/datafile/o1_mf_elon5_gk4x0sbb_.dbf
ELONTIAN /u01/app/oracle/oradata/orcl/data_elontian01.dbf
此时,备库恢复数据文件的时候,按照预定的db_file_name_convert来创建新增的数据文件。
而且,另一个需要注意的地方。如果主备切换,旧主库的db_create_file_dest应该修改为alter system set db_create_file_dest='';