DG_数据文件转换参数测试

时间:2023-03-08 15:56:03
DG_数据文件转换参数测试

本篇博客流程图:

一、测试需求及参数说明

二、测试环境进行相关测试

三、问题总结

一、测试需求及参数说明

1.1测试需求说明


DG切换


切换前,数据库版本12.2.0.1,主库rac两节点,备一rac两节点,备二single单实例。


需求,更换主机,使用dg进行迁移;


切换后,新主库rac两节点,新备一rac两节点,新备二single单实例。


切换后,由于对convert参数理解不够,dg正常切换成功,但是convert参数在新的备库未修改,留坑,本次出于学习目的,进行测试参数。



1.2切换中遇到的问题进行总结:


1.主库两个实例,应用停业务后,在主库第二个实例kill LOCAL=NO远程进程后,主库存活的实例一,查询数据库切换状态异常,Alert日志发现为主库像远程备库传输的进程被kill,通过手工切换归档重置进程连接;
2.主库查询切换状态异常,发现dest远程传输归档进程异常,发现存在一个远程归档传输参数指向一个废弃的dg(已于客户确认),后对该参数设置null后,主库切换状态恢复正常;
3.在切换前,对RAC环境备库(切换后新主库),配置远程归档参数,使用scope=spfile,DG备库环境切换过程中无重启动作,最终导致切换后DG连通性不正常,重新配置参数后恢复正常;
(对于主库来说,DG切换角色为物理备库,主库会shutdown,但是对于备库环境,不受影响)
4.在切换后,新的备库环境rac,配置db convert转换参数,设置错误,参数设置不当,导致db nomount无法启动;
解决方式:create pfile='/tmp/pfile.ora' from spfile;
vi 编辑pfile,配置正确的参数后;
create spfile=' 修改前spfile完整路径.123213123' from pfile='/tmp/pfile.ora';报错
RAC环境,生成最新的spfile文件,不要加后缀数字;
create spfile='+DATA/xxx/spfile.ora' from pfile='/tmp/pfile.ora'; 即可
5)在修改db convert参数完毕后,重启备库open,需要介质恢复,金华姐说这是正常现象,mount状态打开media recovery ,后面再重新启动到open就可以了。#此处自己留坑#


1.3参数说明
standby_file_management
db_create_file_dest
DB_FILE_NAME_CONVERT和LOG_FILE_NAME_CONVERT standby_file_management
STANDBY_FILE_MANAGEMENT = { MANUAL | AUTO }
启用自动备用文件管理后,将在备用数据库上复制主数据库上的操作系统文件添加和删除。STANDBY_FILE_MANAGEMENT仅适用于物理备用数据库。
如果备用数据库与主数据库位于同一系统上,请确保主系统和备用系统不指向相同的文件。 db_create_file_dest
DB_CREATE_FILE_DEST = directory | disk group
如果将文件系统目录指定为默认位置,则该目录必须已存在; Oracle不会创建它。该目录必须具有允许Oracle在其中创建文件的适当权限。Oracle为文件生成唯一的名称,因此创建的文件是Oracle托管文件。 DB_FILE_NAME_CONVERT
对于创建重复数据库以进行恢复非常有用。它将主数据库上的新数据文件的文件名转换为备用数据库上的文件名。
DB_FILE_NAME_CONVERT = 'string1' , 'string2' , 'string3' , 'string4' , ...
主,备,主,备
如果将数据文件添加到主数据库,则必须将相应的文件添加到备用数据库。更新备用数据库时,此参数将主数据库上的数据文件名转换为备用数据库上的数据文件名。备用数据库上的文件必须存在且可写,否则恢复过程将因错误而停止。

二、测试环境进行相关测试

测试一、备库未配置任何数据文件创建参数,主库创建数据文件
.主备同步,备库存在于主库完全相同的路径
.主库创建数据文件,切换日志
SQL> create tablespace t1 datafile '/picclife/app/oracle/oradata/orcla/t1.dbf' size 1m;
SQL> alter system switch logfile;
主库参数:
db_create_file_dest Null .查询备库应用情况
Errors in file /picclife/app/oracle/diag/rdbms/orclb/orclb/trace/orclb_m000_3879.trc:
ORA-: data file : '/picclife/app/oracle/product/12.2.0/db_1/dbs/UNNAMED00005'
ORA-: error in identifying file '/picclife/app/oracle/product/12.2.0/db_1/dbs/UNNAMED00005'
ORA-: unable to obtain file status
--17T03::44.412366-:
Errors in file /picclife/app/oracle/diag/rdbms/orclb/orclb/trace/orclb_mrp0_3575.trc:
ORA-: cannot add data file that was originally created as '/picclife/app/oracle/oradata/orcla/t1.dbf'
Recovery interrupted!
--17T03::44.758843-: 备库参数
db_create_file_dest Null
standby_file_management MANUAL
log_file_name_convert Null 备库处理
SQL> select name from v$datafile where name like '%UNNAME%'
NAME
-----------------------------------------------------------------
alter database create datafile '/picclife/app/oracle/product/12.2.0/db_1/dbs/UNNAMED00005'
as '/picclife/app/oracle/oradata/oracdg/t1.dbf';
recover managed standby database disconnect from session; .删除数据文件(测试)
主库
drop tablespace t1 including contents and datafiles;
备库,同样能删除数据文件记录,但无法级联删除操作系统中的数据文件
orclb:/picclife/app/oracle/oradata/oracdg$ ls -lrt
-rw-r----- oracle oinstall Mar : t1.dbf 测试二、备库配置standby_file_management=AUTO时,主库创建数据文件 2.1 备库有与主库一样的路径且有权限访问
备库:
SQL> alter system set standby_file_management=auto; 主库,创建数据文件,切换归档日志
SQL> create tablespace t1 datafile '/picclife/app/oracle/oradata/orcla/t1.dbf' size 1m;
SQL> alter system switch logfile; 备库,日志:
Existing file may be overwritten
Recovery created file /picclife/app/oracle/oradata/orcla/t1.dbf
Successfully added datafile to media recovery
Datafile #: '/picclife/app/oracle/oradata/orcla/t1.dbf'
--17T04::53.261481-: 备库,根据参数,自动创建数据文件,且与主库路径相同。
drop tablespace t1 including contents and datafiles;
alter system switch logfile; 2.2 备库有与主库路径不同
将备库与主库文件路径相同的目录,mv该名称
orclb:/picclife/app/oracle/oradata$ mv orcla orcla.bak
主库,创建数据文件,切换归档日志
SQL> create tablespace t1 datafile '/picclife/app/oracle/oradata/orcla/t1.dbf' size 1m;
SQL> alter system switch logfile;
备库
orclb:/picclife/app/oracle/oradata$ ls
oracdg orcla orcla.bak
orclb:/picclife/app/oracle/oradata$ cd orcla
orclb:/picclife/app/oracle/oradata/orcla$ ls -lrt
total
-rw-r----- oracle oinstall Mar : t1.dbf
数据文件还是正常创建了,并且oracle自动创建了该路径!!! 2.3 调整版本,将备库与主库相同的文件路径orcla路径属组修改为root:root
主库,还原测试环境
drop tablespace t1 including contents and datafiles;
alter system switch logfile;
备库修改文件属组:
[root@orclb oradata]# chown root.root orcla
主库,创建数据文件,切换归档日志
SQL> create tablespace t1 datafile '/picclife/app/oracle/oradata/orcla/t1.dbf' size 1m;
SQL> alter system switch logfile; 备库:报错信息复现
Errors in file /picclife/app/oracle/diag/rdbms/orclb/orclb/trace/orclb_m000_6001.trc:
ORA-: data file : '/picclife/app/oracle/product/12.2.0/db_1/dbs/UNNAMED00005'
ORA-: error in identifying file '/picclife/app/oracle/product/12.2.0/db_1/dbs/UNNAMED00005'
ORA-: unable to obtain file status
Linux-x86_64 Error: : No such file or directory
Additional information: 备库处理
SQL> alter system set standby_file_management=manual;
alter database create datafile '/picclife/app/oracle/product/12.2.0/db_1/dbs/UNNAMED00005'
as '/picclife/app/oracle/oradata/oracdg/t1.dbf';
SQL> alter system set standby_file_management=auto;
recover managed standby database disconnect from session;
主库,还原测试环境
drop tablespace t1 including contents and datafiles;
alter system switch logfile; 测试三、备库配置auto参数,且配置convert转换参数时
备库
SQL> alter system set db_file_name_convert='/picclife/app/oracle/oradata/orcla/','/picclife/app/oracle/oradata/oracdg/' scope=spfile;
SQL> startup mount;
recover managed standby database disconnect from session; 主库创建数据文件,切换日志
SQL> create tablespace t1 datafile '/picclife/app/oracle/oradata/orcla/t1.dbf' size 1m;
SQL> alter system switch logfile; 备库自动创建该文件:正常情况
SQL> select name from v$datafile;
NAME
------------------------------------------------------------------------------------------------------------------------
/picclife/app/oracle/oradata/oracdg/data2etsh9v3.dbf
/picclife/app/oracle/oradata/oracdg/data2gtsha10.dbf
/picclife/app/oracle/oradata/oracdg/data2ftsha07.dbf
/picclife/app/oracle/oradata/oracdg/data2htsha1q.dbf
/picclife/app/oracle/oradata/oracdg/t1.dbf 测试四、当dg切换后,修改convert参数后,dg能否保持正常转换。
切换前:主库orcla,一备orclb,二备orclc;
切换后:主库orclb,一备orcla,二备orclc; 切换前:
主库数据文件路径,及参数设置 SQL> select name from v$datafile union select name from v$tempfile;
NAME
----------------------------------------------------------------
/picclife/app/oracle/oradata/orcla/sysaux01.dbf db_unique_name orcla
db_file_name_convert Null
standby_file_management --全部设置为auto 备1
/picclife/app/oracle/oradata/oracdg/ db_unique_name orclb
db_file_name_convert
/picclife/app/oracle/oradata/orcla/, /picclife/app/oracle/oradata/oracdg/ 备2
/picclife/app/oracle/oradata/dg2/ db_unique_name orclc
/picclife/app/oracle/oradata/orcla/, /picclife/app/oracle/oradata/dg2/ 原主库
SQL> select dbid,name, database_role,open_mode,SWITCHOVER_STATUS,FLASHBACK_ON,PROTECTION_MODE,FORCE_LOGGING from v$database;
DBID NAME DATABASE_ROLE OPEN_MODE SWITCHOVER_STAT FLASH PROTECTION_MODE FORCE_LOGG
----------- ---------- ---------------------- ---------- --------------- ----- ---------------------------------------- ----------
ORCLA PRIMARY READ WRITE TO STANDBY NO MAXIMUM PERFORMANCE YES SQL> select dest_id,error from v$archive_dest; DEST_ID ERROR
---------- ----------------------------------------------------------------- 原主库:切换为物理备库
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
SQL> startup mount;
SQL> select dbid,name, database_role,open_mode,SWITCHOVER_STATUS,FLASHBACK_ON,PROTECTION_MODE,FORCE_LOGGING from v$database;
DBID NAME DATABASE_ROLE OPEN_MODE SWITCHOVER_STAT FLASH PROTECTION_MODE FORCE_LOGG
----------- ---------- ---------------------- ---------- --------------- ----- ---------------------------------------- ----------
ORCLA PHYSICAL STANDBY MOUNTED RECOVERY NEEDED NO MAXIMUM PERFORMANCE YES 备1/
SQL> select dbid,name, database_role,open_mode,SWITCHOVER_STATUS,FLASHBACK_ON,PROTECTION_MODE,FORCE_LOGGING from v$database; DBID NAME DATABASE_ROLE OPEN_MODE SWITCHOVER_STAT FLASH PROTECTION_MODE FORCE_LOGG
----------- ---------- ---------------------- ---------- --------------- ----- ---------------------------------------- ----------
ORCLA PHYSICAL STANDBY READ ONLY TO PRIMARY NO MAXIMUM PERFORMANCE YES
WITH APPLY 备1切换为主库
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY; 新主库修改远程归档参数:
alter system set log_archive_dest_2='SERVICE=primaryorcla LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcla';
alter system set log_archive_dest_3='SERVICE=adgc LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orclc';
SQL> alter database open;
SQL> alter system switch logfile; 新1备修改参数:
SQL> alter system set fal_client=primaryorcla;
SQL> alter system set fal_server=adgb;
SQL> recover managed standby database disconnect from session;
SQL> alter system set db_file_name_convert='/picclife/app/oracle/oradata/oracdg/','/picclife/app/oracle/oradata/orcla/' scope=spfile;
recover managed standby database disconnect from session; 重启库,无异常 新2备修改参数:
SQL> alter system set fal_server=adgb; db_file_name_convert /picclife/app/oracle/oradata/orcla/, /picclife/app/oracle/oradata/dg2/
SQL> alter system set db_file_name_convert='/picclife/app/oracle/oradata/oracdg/','/picclife/app/oracle/oradata/dg2/' scope=spfile;
SQL> select name from v$datafile; NAME
----------------------------------------------------------------
/picclife/app/oracle/oradata/dg2/system01.dbf
/picclife/app/oracle/oradata/dg2/sysaux01.dbf
/picclife/app/oracle/oradata/dg2/undotbs01.dbf
/picclife/app/oracle/oradata/dg2/users01.dbf
/picclife/app/oracle/oradata/dg2/t1.dbf
SQL> alter database open;
Database altered.
recover managed standby database disconnect from session; --
主库,还原测试环境
drop tablespace t1 including contents and datafiles;
alter system switch logfile;
主库创建数据文件,切换日志
SQL> create tablespace t1 datafile '/picclife/app/oracle/oradata/oracdg/t1.dbf' size 1m;
SQL> alter system switch logfile; 备库查询一切正常,未发现DG备库切换后,修改convert参数导致的数据文件目录不正确现象。

三、问题总结

总结:
.如果备库没有配置standby_file_management=auto参数,则主库创建数据文件,备库接受应用日志后会报错且mrp进程停止应用
.如果备库与主库路径不同,且备库无法创建与主库相同的路径存放文件,则报错且mrp进程停止应用
.配置正确的转换参数+auto参数,则主库创建数据文件,备库能相应进行转换
.dg切换后,配置正确的convert参数,无异常。
5.今后如果还存在dg切换,需要提前查询name路径,及配置正确的convert转换参数