11g adg 环境搭建实施手册-0824
Posted ORACLE-fans
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了11g adg 环境搭建实施手册-0824相关的知识,希望对你有一定的参考价值。
11g adg 环境搭建实施手册-0824
2017年8月24日
10:18
################################################################
简介
从11g 开始oracle提供了一个新功能Active Database Duplication for A standby database来创建配置物理standby 数据库。
Active Database Duplication for A standby database这个功能主要从一个正在运行的数据库复制数据文件,控制文件等到一个物理备库(physical standby database)。
这个功能简化了创建standby database过程中在主库备份和备库恢复的环节,实现了自动拷贝主库的控制文件,数据文件等到备库,对比基于备份集的创建standby database
过程中需要手动在主库备份,然后将备份集拷贝到备库再手动恢复来说,减少了dba的大量工作。
创建物理standby database过程中的其他环节,如打开主库的force logging,主库init参数的修改等,以及备库开始应用redo log这些环节还需手动来完成的,与以往的创建配置物理standby database 是相同的。
备库的init参数需要在duplicate命令中指定,没有特殊指定的,就会默认使用主库的init参数值。
测试环境
-----------------------------------
主库:11.2.0.1 单机数据库,db_unique_name=fpyj,数据文件存放在文件系统
备库:11.2.0.1 单机数据库,db_unique_name=fpyjbak,数据文件存放在文件系统
Data Guard保护模式(Protection mode)采用最大性能模式(MAXIMIZE PERFORMANCE)
redo log传输采用LGWR进程的异步传输方式
##########################################################################
安装前环境检查
【要求】
1. 主库和备库必须是相同版本及位数并且为企业版(Enterprise Edition Release) 2. 主库和备库所在的操作系统最好是相同平台,相同操作系统版本,必须是相同 ENDIAN_FORMAT 的平台 3. 主库、备库必须开启归档模式 4.主库、备库 必须启用force logging功能 |
1. 检查主库和备库数据库软件版本
SYS(125_9)@fpyj> select * from v$version;
BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNS for Linux: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production |
2. 检查操作系统平台是否兼容
SYS(125_9)@fpyj> select * from v$transportable_platform order by endian_format,platform_name;
PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT ----------- ---------------------------------------- -------------- 6 AIX-Based Systems (64-bit) Big 16 Apple Mac OS Big 3 HP-UX (64-bit) Big 4 HP-UX IA (64-bit) Big 18 IBM Power Based Linux Big 9 IBM zSeries Based Linux Big 1 Solaris[tm] OE (32-bit) Big 2 Solaris[tm] OE (64-bit) Big 21 Apple Mac OS (x86-64) Little 19 HP IA Open VMS Little 15 HP Open VMS Little 5 HP Tru64 UNIX Little 10 Linux IA (32-bit) Little 11 Linux IA (64-bit) Little 13 Linux x86 64-bit Little 7 Microsoft Windows IA (32-bit) Little 8 Microsoft Windows IA (64-bit) Little 12 Microsoft Windows x86 64-bit Little 17 Solaris Operating System (x86) Little 20 Solaris Operating System (x86-64) Little |
3. 检查主库是否开启数据库归档
SYS(125_9)@fpyj> select name,log_mode,force_logging from v$database;
NAME LOG_MODE FOR --------- ------------ --- FPYJ ARCHIVELOG YES |
##########################################################################
安装前环境准备
##########################################################################
1. 打开主库force logging:
SQL> ALTER DATABASE FORCE LOGGING;
查看主库当前是否为force logging: SQL> select force_logging from v$database; FOR --- YES |
2. 修改主库的初始化参数如下:
LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(fpyj,fpyjbak)‘ --这是本地的归档目录 LOG_ARCHIVE_DEST_1=‘LOCATION=/home/oracle/arch_dir/fpyj VALID_FOR=(all_logfiles,all_roles) db_unique_name=fpyj‘ --这是接收远程的归档目录 注意 service、db_unique_name LOG_ARCHIVE_DEST_2=‘SERVICE=fpyjbak LGWR SYNC VALID_FOR=(all_logfiles,all_roles) DB_UNIQUE_NAME=fpyj123‘ LOG_ARCHIVE_DEST_STATE_1=ENABLE LOG_ARCHIVE_DEST_STATE_2=ENABLE REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE LOG_ARCHIVE_MAX_PROCESSES=10 |
- 3. 为简化 rman窗口中的输入,因此把相应的操作放入 duplicate.sql文件中。然后执行该文件。
duplicate target database for standby nofilenamecheck from active database dorecover spfile set db_unique_name=‘fpyjbak‘ set log_archive_dest_1=‘location=/home/oracle/arch_dir/fpyjbak valid_for=(all_logfiles,all_roles) db_unique_name=fpyjbak‘ set log_archive_dest_2=‘service=fpyj sync lgwr valid_for=(online_logfiles,primary_role) db_unique_name=fpyj‘ set standby_file_management=‘auto‘ set fal_server=‘fpyj‘ set fal_client=‘fpyjbak‘ set control_files=‘/u01/app/oracle/oradata/fpyjbak/control01.ctl‘ #set memory_target=‘500m‘ set sga_max_size=‘400m‘ set diagnostic_dest=‘/u01/app/oracle‘ set audit_file_dest=‘/u01/app/oracle/admin/fpyjbak/adump‘ set DB_FILE_NAME_CONVERT=‘/oradata02/fpyj/1107‘,‘/u01/app/oracle/oradata/fpyjbak‘ set LOG_FILE_NAME_CONVERT=‘/oradata02/fpyj‘,‘/u01/app/oracle/oradata/fpyjbak‘ |
4. 在备库创建 adump 路径,与参数audit_file_dest的路径一致
$ mkdir -p /u01/app/oracle/admin/fpyjbak/adump |
5. 在备库创建init参数文件$ORACLE_HOME/dbs/initfpyj123.ora‘,
有了这个临时的init参数文件,我们就可以在duplicate命令运行前将备库的AUXILIARY实例启动到nomount状态,这也是运行duplicate命令的一个必要条件。
initfpyjbak.ora文件只有一行信息: DB_NAME=fpyj |
6. 将密码文件从主库服务器拷贝到备库服务器,并且重命名:
$ cp orapwfpyj orapwfpyj123 |
7. 在主库服务器和备库服务器, 编辑添加下面信息到$ORACLE_HOME/network/tnsnames.ora
FPYJ = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = Oracle11g)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = fpyj) ) )
FPYJ123 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = Oracle11g)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = fpyj123) ) ) |
8. 在备库服务器, 添加静态注册信息到 $ORACLE_HOME/network/listener.ora文件,
这主要是由于AUXILIARY实例启动到nomount状态时,listener无法注册AUXILIARY实例,listener会标志Auxiliary实例为‘blocked‘状态,因此duplicate命令就无法通过TNS的方式连接到Auxiliary实例,为了解决这个问题,需要先手动静态注册数据库实例到listener上。 当Data Guard配置完成后,就可以删除静态注册的配置信息。 (本测试使用ASM,因此需要安装GRID,有效的listener.ora文件是在GRID_HOME下面)
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = ANYTHING)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.113)(PORT = 1521)) ) )
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = fpyjbak) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (SID_NAME = fpyjbak) ) ) |
9. 在备库服务器,执行duplicate命令前,先启动AUXILIARY实例到 nomount 状态:
$ export ORACLE_SID=fpyjbak $ sqlplus / as sysdba SQL> startup nomount; |
10. 在备库测试与AUXILIARY实例的连接和与主库的连接,如果连接成功,继续执行下面的步骤,
很多时候duplicate命令失败都是由于连接失败导致的。 $ sqlplus sys/[email protected] as sysdba $ sqlplus sys/[email protected] as sysdba |
Duplicate.sql 如下:
duplicate target database for standby nofilenamecheck from active database dorecover spfile set db_unique_name=‘fpyjbak‘ set log_archive_dest_1=‘location=/home/oracle/arch_dir/fpyjbak valid_for=(all_logfiles,all_roles) db_unique_name=fpyjbak‘ set log_archive_dest_2=‘service=fpyj sync lgwr valid_for=(online_logfiles,primary_role) db_unique_name=fpyj‘ set standby_file_management=‘auto‘ set fal_server=‘fpyj‘ set fal_client=‘fpyjbak‘ set control_files=‘/u01/app/oracle/oradata/fpyjbak/control01.ctl‘ set memory_target=‘500m‘ set sga_max_size=‘400m‘ set diagnostic_dest=‘/u01/app/oracle‘ set audit_file_dest=‘/u01/app/oracle/admin/fpyjbak/adump‘ set DB_FILE_NAME_CONVERT=‘/oradata02/fpyj/1107‘,‘/u01/app/oracle/oradata/fpyjbak‘ set LOG_FILE_NAME_CONVERT=‘/oradata02/fpyj‘,‘/u01/app/oracle/oradata/fpyjbak‘ |
11. 创建备库
在duplicate命令中指定关键字‘FOR STANDBY‘和‘FROM ACTIVE DATABASE‘表示从一个active的数据库来复制创建物理备库 参数‘DORECOVER‘表示duplicate命令会执行recover动作,否则duplicate命令只执行restore, 备库与主库不同的初始化参数,需要在duplicate命令中特殊指定,这样创建备库的spfile时就会用指定的值替换主库的参数值, 主库与备库的数据文件的路径不同,因此设置参数‘DB_FILE_NAME_CONVERT‘
% rman target sys/[email protected] AUXILIARY SYS/[email protected] cmdfile=/home/oracle/scripts/duplicate.sql log=/home/oracle/scripts/duplicate.log |
以下是duplicate standby database过程中屏幕的log信息 RMAN> duplicate target database for standby nofilenamecheck 2> from active database 3> dorecover 4> spfile 5> set db_unique_name=‘fpyjbak‘ 6> set log_archive_dest_1=‘location=/home/oracle/arch_dir/fpyjbak valid_for=(all_logfiles,all_roles) db_unique_name=fpyjbak‘ 7> set log_archive_dest_2=‘service=fpyj sync lgwr valid_for=(online_logfiles,primary_role) db_unique_name=fpyj‘ 8> set standby_file_management=‘auto‘ 9> set fal_server=‘fpyj‘ 10> set fal_client=‘fpyjbak‘ 11> set control_files=‘/u01/app/oracle/oradata/fpyjbak/control01.ctl‘ 12> set memory_target=‘500m‘ 13> set sga_max_size=‘400m‘ 14> set diagnostic_dest=‘/u01/app/oracle‘ 15> set audit_file_dest=‘/u01/app/oracle/admin/fpyjbak/adump‘ 16> set DB_FILE_NAME_CONVERT=‘/oradata02/fpyj/1107‘,‘/u01/app/oracle/oradata/fpyjbak‘ 17> set LOG_FILE_NAME_CONVERT=‘/oradata02/fpyj/1107‘,‘/u01/app/oracle/oradata/fpyjbak‘ 18> ; 19> Starting Duplicate Db at 28-AUG-17 using target database control file instead of recovery catalog allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=20 device type=DISK
contents of Memory Script: { backup as copy reuse targetfile ‘/u01/app/oracle/product/11.2.0/db_1/dbs/orapwfpyj‘ auxiliary format ‘/u01/app/oracle/product/11.2.0/db_1/dbs/orapwfpyjbak‘ targetfile ‘/u01/app/oracle/product/11.2.0/db_1/dbs/spfilefpyj.ora‘ auxiliary format ‘/u01/app/oracle/product/11.2.0/db_1/dbs/spfilefpyjbak.ora‘ ; sql clone "alter system set spfile= ‘‘/u01/app/oracle/product/11.2.0/db_1/dbs/spfilefpyjbak.ora‘‘"; } executing Memory Script
Starting backup at 28-AUG-17 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=145 device type=DISK Finished backup at 28-AUG-17
sql statement: alter system set spfile= ‘‘/u01/app/oracle/product/11.2.0/db_1/dbs/spfilefpyjbak.ora‘‘
contents of Memory Script: { sql clone "alter system set db_unique_name = ‘‘fpyjbak‘‘ comment= ‘‘‘‘ scope=spfile"; sql clone "alter system set log_archive_dest_1 = ‘‘location=/home/oracle/arch_dir/fpyjbak valid_for=(all_logfiles,all_roles) db_unique_name=fpyjbak‘‘ comment= ‘‘‘‘ scope=spfile"; sql clone "alter system set log_archive_dest_2 = ‘‘service=fpyj sync lgwr valid_for=(online_logfiles,primary_role) db_unique_name=fpyj‘‘ comment= ‘‘‘‘ scope=spfile"; sql clone "alter system set standby_file_management = ‘‘auto‘‘ comment= ‘‘‘‘ scope=spfile"; sql clone "alter system set fal_server = ‘‘fpyj‘‘ comment= ‘‘‘‘ scope=spfile"; sql clone "alter system set fal_client = ‘‘fpyjbak‘‘ comment= ‘‘‘‘ scope=spfile"; sql clone "alter system set control_files = ‘‘/u01/app/oracle/oradata/fpyjbak/control01.ctl‘‘ comment= ‘‘‘‘ scope=spfile"; sql clone "alter system set memory_target = 500m comment= ‘‘‘‘ scope=spfile"; sql clone "alter system set sga_max_size = 400m comment= ‘‘‘‘ scope=spfile"; sql clone "alter system set diagnostic_dest = ‘‘/u01/app/oracle‘‘ comment= ‘‘‘‘ scope=spfile"; sql clone "alter system set audit_file_dest = ‘‘/u01/app/oracle/admin/fpyjbak/adump‘‘ comment= ‘‘‘‘ scope=spfile"; sql clone "alter system set db_file_name_convert = ‘‘/oradata02/fpyj/1107‘‘, ‘‘/u01/app/oracle/oradata/fpyjbak‘‘ comment= ‘‘‘‘ scope=spfile"; sql clone "alter system set LOG_FILE_NAME_CONVERT = ‘‘/oradata02/fpyj/1107‘‘, ‘‘/u01/app/oracle/oradata/fpyjbak‘‘ comment= ‘‘‘‘ scope=spfile"; shutdown clone immediate; startup clone nomount; } executing Memory Script
sql statement: alter system set db_unique_name = ‘‘fpyjbak‘‘ comment= ‘‘‘‘ scope=spfile
sql statement: alter system set log_archive_dest_1 = ‘‘location=/home/oracle/arch_dir/fpyjbak valid_for=(all_logfiles,all_roles) db_unique_name=fpyjbak‘‘ comment= ‘‘‘‘ scope=spfile
sql statement: alter system set log_archive_dest_2 = ‘‘service=fpyj sync lgwr valid_for=(online_logfiles,primary_role) db_unique_name=fpyj‘‘ comment= ‘‘‘‘ scope=spfile
sql statement: alter system set standby_file_management = ‘‘auto‘‘ comment= ‘‘‘‘ scope=spfile
sql statement: alter system set fal_server = ‘‘fpyj‘‘ comment= ‘‘‘‘ scope=spfile
sql statement: alter system set fal_client = ‘‘fpyjbak‘‘ comment= ‘‘‘‘ scope=spfile
sql statement: alter system set control_files = ‘‘/u01/app/oracle/oradata/fpyjbak/control01.ctl‘‘ comment= ‘‘‘‘ scope=spfile
sql statement: alter system set memory_target = 500m comment= ‘‘‘‘ scope=spfile
sql statement: alter system set sga_max_size = 400m comment= ‘‘‘‘ scope=spfile
sql statement: alter system set diagnostic_dest = ‘‘/u01/app/oracle‘‘ comment= ‘‘‘‘ scope=spfile
sql statement: alter system set audit_file_dest = ‘‘/u01/app/oracle/admin/fpyjbak/adump‘‘ comment= ‘‘‘‘ scope=spfile
sql statement: alter system set db_file_name_convert = ‘‘/oradata02/fpyj/1107‘‘, ‘‘/u01/app/oracle/oradata/fpyjbak‘‘ comment= ‘‘‘‘ scope=spfile
sql statement: alter system set LOG_FILE_NAME_CONVERT = ‘‘/oradata02/fpyj/1107‘‘, ‘‘/u01/app/oracle/oradata/fpyjbak‘‘ comment= ‘‘‘‘ scope=spfile
Oracle instance shut down
connected to auxiliary database (not started) Oracle instance started
Total System Global Area 417546240 bytes
Fixed Size 2213936 bytes Variable Size 209717200 bytes Database Buffers 201326592 bytes Redo Buffers 4288512 bytes
contents of Memory Script: { backup as copy current controlfile for standby auxiliary format ‘/u01/app/oracle/oradata/fpyjbak/control01.ctl‘; } executing Memory Script
Starting backup at 28-AUG-17 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy copying standby control file output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_fpyj.f tag=TAG20170828T160822 RECID=27 STAMP=953222903 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 Finished backup at 28-AUG-17
contents of Memory Script: { sql clone ‘alter database mount standby database‘; } executing Memory Script
sql statement: alter database mount standby database Using previous duplicated file /u01/app/oracle/oradata/fpyjbak/system01.dbf for datafile 1 with checkpoint SCN of 1785948 Using previous duplicated file /u01/app/oracle/oradata/fpyjbak/sysaux01.dbf for datafile 2 with checkpoint SCN of 1785992 Using previous duplicated file /u01/app/oracle/oradata/fpyjbak/undotbs01.dbf for datafile 3 with checkpoint SCN of 1786037 Using previous duplicated file /u01/app/oracle/oradata/fpyjbak/users01.dbf for datafile 4 with checkpoint SCN of 1786044 Using previous duplicated file /u01/app/oracle/oradata/fpyjbak/fpyj01.dbf for datafile 5 with checkpoint SCN of 1786030
contents of Memory Script: { set newname for tempfile 1 to "/u01/app/oracle/oradata/fpyjbak/temp01.dbf"; switch clone tempfile all; sql ‘alter system archive log current‘; } executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/fpyjbak/temp01.dbf in control file
sql statement: alter system archive log current
contents of Memory Script: { backup as copy reuse archivelog like "/home/oracle/arch_dir/fpyj/1_109_927291116.dbf" auxiliary format "/home/oracle/arch_dir/fpyjbak/1_109_927291116.dbf" archivelog like "/home/oracle/arch_dir/fpyj/1_110_927291116.dbf" auxiliary format "/home/oracle/arch_dir/fpyjbak/1_110_927291116.dbf" archivelog like "/home/oracle/arch_dir/fpyj/1_111_927291116.dbf" auxiliary format "/home/oracle/arch_dir/fpyjbak/1_111_927291116.dbf" ; catalog clone archivelog "/home/oracle/arch_dir/fpyjbak/1_109_927291116.dbf"; catalog clone archivelog "/home/oracle/arch_dir/fpyjbak/1_110_927291116.dbf"; catalog clone archivelog "/home/oracle/arch_dir/fpyjbak/1_111_927291116.dbf"; catalog clone datafilecopy "/u01/app/oracle/oradata/fpyjbak/system01.dbf", "/u01/app/oracle/oradata/fpyjbak/sysaux01.dbf", "/u01/app/oracle/oradata/fpyjbak/undotbs01.dbf", "/u01/app/oracle/oradata/fpyjbak/users01.dbf", "/u01/app/oracle/oradata/fpyjbak/fpyj01.dbf"; switch clone datafile 1 to datafilecopy "/u01/app/oracle/oradata/fpyjbak/system01.dbf"; switch clone datafile 2 to datafilecopy "/u01/app/oracle/oradata/fpyjbak/sysaux01.dbf"; switch clone datafile 3 to datafilecopy "/u01/app/oracle/oradata/fpyjbak/undotbs01.dbf"; switch clone datafile 4 to datafilecopy "/u01/app/oracle/oradata/fpyjbak/users01.dbf"; switch clone datafile 5 to datafilecopy "/u01/app/oracle/oradata/fpyjbak/fpyj01.dbf"; } executing Memory Script
Starting backup at 28-AUG-17 using channel ORA_DISK_1 channel ORA_DISK_1: starting archived log copy input archived log thread=1 sequence=109 RECID=153 STAMP=953222648 output file name=/home/oracle/arch_dir/fpyjbak/1_109_927291116.dbf RECID=0 STAMP=0 channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting archived log copy input archived log thread=1 sequence=110 RECID=154 STAMP=953222649 output file name=/home/oracle/arch_dir/fpyjbak/1_110_927291116.dbf RECID=0 STAMP=0 channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting archived log copy input archived log thread=1 sequence=111 RECID=155 STAMP=953222909 output file name=/home/oracle/arch_dir/fpyjbak/1_111_927291116.dbf RECID=0 STAMP=0 channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01 Finished backup at 28-AUG-17
cataloged archived log archived log file name=/home/oracle/arch_dir/fpyjbak/1_109_927291116.dbf RECID=1 STAMP=953222905
cataloged archived log archived log file name=/home/oracle/arch_dir/fpyjbak/1_110_927291116.dbf RECID=2 STAMP=953222905
cataloged archived log archived log file name=/home/oracle/arch_dir/fpyjbak/1_111_927291116.dbf RECID=3 STAMP=953222905
cataloged datafile copy datafile copy file name=/u01/app/oracle/oradata/fpyjbak/system01.dbf RECID=27 STAMP=953222905 cataloged datafile copy datafile copy file name=/u01/app/oracle/oradata/fpyjbak/sysaux01.dbf RECID=28 STAMP=953222905 cataloged datafile copy datafile copy file name=/u01/app/oracle/oradata/fpyjbak/undotbs01.dbf RECID=29 STAMP=953222905 cataloged datafile copy datafile copy file name=/u01/app/oracle/oradata/fpyjbak/users01.dbf RECID=30 STAMP=953222905 cataloged datafile copy datafile copy file name=/u01/app/oracle/oradata/fpyjbak/fpyj01.dbf RECID=31 STAMP=953222905
datafile 1 switched to datafile copy input datafile copy RECID=27 STAMP=953222905 file name=/u01/app/oracle/oradata/fpyjbak/system01.dbf
datafile 2 switched to datafile copy input datafile copy RECID=28 STAMP=953222905 file name=/u01/app/oracle/oradata/fpyjbak/sysaux01.dbf
datafile 3 switched to datafile copy input datafile copy RECID=29 STAMP=953222905 file name=/u01/app/oracle/oradata/fpyjbak/undotbs01.dbf
datafile 4 switched to datafile copy input datafile copy RECID=30 STAMP=953222905 file name=/u01/app/oracle/oradata/fpyjbak/users01.dbf
datafile 5 switched to datafile copy input datafile copy RECID=31 STAMP=953222905 file name=/u01/app/oracle/oradata/fpyjbak/fpyj01.dbf
contents of Memory Script: { set until scn 1788149; recover standby clone database delete archivelog ; } executing Memory Script
executing command: SET until clause
Starting recover at 28-AUG-17 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=1 device type=DISK
starting media recovery
archived log for thread 1 with sequence 109 is already on disk as file /home/oracle/arch_dir/fpyjbak/1_109_927291116.dbf archived log for thread 1 with sequence 110 is already on disk as file /home/oracle/arch_dir/fpyjbak/1_110_927291116.dbf archived log for thread 1 with sequence 111 is already on disk as file /home/oracle/arch_dir/fpyjbak/1_111_927291116.dbf archived log file name=/home/oracle/arch_dir/fpyjbak/1_109_927291116.dbf thread=1 sequence=109 archived log file name=/home/oracle/arch_dir/fpyjbak/1_110_927291116.dbf thread=1 sequence=110 archived log file name=/home/oracle/arch_dir/fpyjbak/1_111_927291116.dbf thread=1 sequence=111 media recovery complete, elapsed time: 00:00:01 Finished recover at 28-AUG-17 Finished Duplicate Db at 28-AUG-17
Recovery Manager complete. |
以上创建完成了物理standby数据库(最后的错误警告信息可以忽略,我们在后面的附录1详细解释这个错误信息)。但是备库数据库还没有开始应用redo log。
12. 创建standby redo log,standby redo log大小等于主库online redo log大小:
SYS(125_13)@fpyjbak> alter database open;
Database altered.
SYS(125_13)@fpyjbak> ALTER DATABASE ADD STANDBY LOGFILE ‘srl1.f‘ SIZE 52428800;
Database altered.
SYS(125_13)@fpyjbak> ALTER DATABASE ADD STANDBY LOGFILE ‘srl2.f‘ SIZE 52428800;
Database altered.
SYS(125_13)@fpyjbak> ALTER DATABASE ADD STANDBY LOGFILE ‘srl3.f‘ SIZE 52428800;
Database altered.
SYS(125_13)@fpyjbak> ALTER DATABASE ADD STANDBY LOGFILE ‘srl4.f‘ SIZE 52428800;
Database altered. |
13. 运行下面的命令开始应用redo log:
SYS(14_17)@fpyjbak> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
Database altered. |
以上的全部步骤就配置完成了物理standby数据库,并且开始应用redo log。
附录1
----------
在创建备库时最后报出的错误警告信息ORA-19527和在MRP开始应用redo log时,alert log中报出下面的错误信息:
Errors in file /u01/app/diag/rdbms/orabak/orabak/trace/orabak_mrp0_7644.trc: ORA-00313: open failed for members of log group 1 of thread 1 ORA-00312: online log 1 thread 1: ‘/home/oracle/app/oradata/orcl/redo01.log‘ ORA-27037: unable to obtain file status Linux Error: 2: No such file or directory ..... Errors in file /u01/app/diag/rdbms/orabak/orabak/trace/orabak_mrp0_7644.trc: ORA-19527: physical standby redo log must be renamed ORA-00312: online log 1 thread 1: ‘/home/oracle/app/oradata/orcl/redo01.log‘
以上错误的原因: oracle为了加快备库与主库switchover的速度,从10.2开始增加了一个增强的功能,就是当MRP启动时会去清理备库上online redo log。造成以上2个错误有2个原因,第一个是备库没有创建online redo log,第二个是备库没有设置log_file_name_convert参数。
解决方法: 方法#1:如果不考虑switchover(备库上不创建online reod log),那么可以忽略这个错误,因为这个错只是一个提示性的信息,不会影响备库的MRP的工作。 方法#2:如果考虑switchover,在备库上创建online reod log,并且设置log_file_name_convert参数: SQL> shutdown immediate; SQL> startup mount; SQL> ALTER DATABASE ADD LOGFILE GROUP 4 (‘+DATA/redo01.log‘) SIZE 52428800; SQL> ALTER DATABASE ADD LOGFILE GROUP 5 (‘+DATA/redo02.log‘) SIZE 52428800; SQL> ALTER DATABASE ADD LOGFILE GROUP 6 (‘+DATA/redo03.log‘) SIZE 52428800; SQL> alter system set log_file_name_convert=‘/home/oracle/app/oradata/orcl‘,‘+data‘ scope=spfile; SQL> shutdown immediate; SQL> startup mount; SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
按照上面方法搭建的dataguard,应用日志 open read only后,alert中出现如下内容
Error 12154 received logging on to the standby FAL[client, MRP0]: Error 12154 connecting to host for fetching gap sequence
原因分析 这是由于备库没有设置 fal_client参数原因造成
解决方法 设置备库的fal_client参数,例如本示例中 主库db_unique_name orcl 备库 db_unique_name orabak 那么将备库的fal_client设置为orabak即可 Alter system set fal_client=‘orabak‘ scope=both;
主备库可用以下SQL检测log sequence是否一致: SYS(125_15)@fpyjbak> select name,replace(database_role,‘ ‘,‘‘) as database_role,thread,seq from v$database,(select max(sequence#) seq,THREAD# thread from v$log_history group by THREAD#);
NAME DATABASE_ROLE THREAD SEQ --------- ---------------- ---------- ---------- FPYJ PHYSICALSTANDBY 1 100 |
- 验证dataguard
验证日志是否从主库传输过来,最后一个栏位为yes表示日志已经传输过来
SYS(14_17)@fpyjbak> set linesize 1000 SYS(14_17)@fpyjbak> set pagesize 1000 SYS(14_17)@fpyjbak> col archived for a10 SYS(14_17)@fpyjbak> col status for 10
SQL> select resetlogs_id,thread#,sequence#,status,archived,applied from v$archived_log;
RESETLOGS_ID THREAD# SEQUENCE# S ARC APPLIED ------------ ---------- ---------- - --- --------- 927291116 1 109 A YES YES 927291116 1 110 A YES YES 927291116 1 111 A YES YES 927291116 1 112 A YES YES 927291116 1 113 A YES YES 927291116 1 114 A YES YES 927291116 1 115 A YES YES 927291116 1 116 A YES YES 927291116 1 117 A YES YES 927291116 1 118 A YES IN-MEMORY |
如果日志传输失败,请用以下命令查看主备库日志传输路径是否valid的
set linesize 160 col dest_name for a20 col error for a50 SYS(14_17)@fpyjbak> SELECT RESETLOGS_ID,THREAD#,SEQUENCE#,STATUS,ARCHIVED,APPLIED FROM V$ARCHIVED_LOG;
RESETLOGS_ID THREAD# SEQUENCE# STATUS ARCHIVED APPLIED ------------ ---------- ---------- ---------- ---------- --------- 927291116 1 50 A YES YES |
如果status为其他,则查看是什么原因导致无法归档到备库,调整完后用以下命令重启远程归档进程
alter system set log_archive_dest_state_2 = ‘defer‘; alter system set log_archive_dest_state_2 = ‘enable‘; |
备库查看lag 延时,正常所有lag应该接近0或者为0
SYS(14_17)@fpyjbak> col name for a30 SYS(14_17)@fpyjbak> col value for a30 SYS(14_17)@fpyjbak> col datum_time for a30 SYS(14_17)@fpyjbak> col TIME_COMPUTED for a20 SYS(14_17)@fpyjbak> set line 160 SYS(14_17)@fpyjbak> select name, value, datum_time, time_computed from v$dataguard_stats;
NAME VALUE DATUM_TIME TIME_COMPUTED ------------------------------ ------------------------------ ------------------------------ -------------------- transport lag 08/24/2017 13:58:32 apply lag 08/24/2017 13:58:32 apply finish time 08/24/2017 13:58:32 estimated startup time 10 08/24/2017 13:58:32 |
查看DataGuard message
SYS(14_17)@fpyjbak> set linesize 1000 SYS(14_17)@fpyjbak> set pagesize 1000 SYS(14_17)@fpyjbak> col time1 for a15 SYS(14_17)@fpyjbak> select to_char(timestamp,‘yyyy-mm-dd hh24:mi:ss‘) time1,message from v$dataguard_status order by time1 asc;
TIME1 MESSAGE ------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------2017-08-24 13:30:42 ARC0: Archival started 2017-08-24 13:30:42 ARC1: Archival started 2017-08-24 13:30:42 ARC2: Archival started 2017-08-24 13:30:42 ARC1: Becoming the ‘no FAL‘ ARCH 2017-08-24 13:30:42 ARC2: Becoming the heartbeat ARCH 2017-08-24 13:30:43 ARC3: Archival started 2017-08-24 13:32:22 Managed Standby Recovery not using Real Time Apply 2017-08-24 13:32:22 Media Recovery Complete 2017-08-24 13:37:12 Attempt to start background Managed Standby Recovery process 2017-08-24 13:37:12 MRP0: Background Managed Standby Recovery process started 2017-08-24 13:37:17 Managed Standby Recovery starting Real Time Apply 2017-08-24 13:37:17 Media Recovery Waiting for thread 1 sequence 51 |
查看日志应用状态
SYS(14_17)@fpyj123> select thread#,sequence#,applied from v$archived_log;
THREAD# SEQUENCE# APPLIED ---------- ---------- --------- 1 50 YES |
以上是关于11g adg 环境搭建实施手册-0824的主要内容,如果未能解决你的问题,请参考以下文章
oracle 11g ADG实施手册(亲测,已成功部署多次)
Oracle 11G ADG 搭建 RAC to Single 详细教程(RMAN DUPLICATE)