Oracle11g ADG环境实施文档-1204
Oracle11g adg 环境搭建实施手册-1204
2017年8月30日
9:16
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.4 单机数据库,db_unique_name=fpyj,数据文件存放在文件系统
备库:11.2.0.4 单机数据库,db_unique_name=fpyj,数据文件存放在文件系统
Data Guard保护模式(Protection mode)采用最大性能模式(MAXIMIZE PERFORMANCE)redo log传输采用LGWR进程的异步传输方式
##########################################################################
安装前环境检查
【要求】
1. 主库和备库必须是相同版本及位数并且为企业版(Enterprise Edition Release)
2. 主库和备库所在的操作系统最好是相同平台,相同操作系统版本,必须是相同 ENDIAN_FORMAT 的平台
3. 主库、备库必须开启归档模式
4.主库、备库 必须启用force logging功能
- 检查主库和备库数据库软件版本
SYS(125_9)@fpyj> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
- 检查操作系统平台是否兼容
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
- 检查主库是否开启归档
SYS(125_9)@fpyj> select name,log_mode,force_logging from v$database;
NAME LOG_MODE FOR
--------- ------------ ---
FPYJ ARCHIVELOG NO
##########################################################################
安装前环境准备
##########################################################################
- 启用主库 的 force logging模式:
SYS(125_9)@fpyj> ALTER DATABASE FORCE LOGGING;
查看主库当前是否为force logging:
SYS(125_9)@fpyj> select force_logging from v$database;
FOR
---
YES
2. 修改主库的初始化参数如下:
LOG_ARCHIVE_CONFIG='DG_CONFIG=(fpyj,fpyjbak)' --此处的 fpyj、fpyjbak 为 本地tnsnames.ora文件中配置好的 fpyj、fpyjbak --这是本地的归档目录 LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/oradata/arch_dir/fpyj VALID_FOR=(online_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=fpyjbak' –同上 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='fpyj' set log_archive_dest_1='location=/oradata/fpyj/logfile valid_for=(all_logfiles,all_roles) db_unique_name=fpyj' set log_archive_dest_2='service=fpyj197 sync lgwr valid_for=(online_logfiles,primary_role) db_unique_name=fpyj' set standby_file_management='auto' #set service_name='fpyj' set fal_server='fpyj197' set fal_client='fpyj26' set control_files='/oradata/fpyj/controlfile/control01.ctl' #set memory_target='4400m' set sga_max_size='8053063680' set diagnostic_dest='/u01/app/oracle' set audit_file_dest='/u01/app/oracle/admin/fpyj/adump' set DB_FILE_NAME_CONVERT='/oradata/fpyj/datafile','/oradata/fpyj/datafile' set LOG_FILE_NAME_CONVERT='/oradata/fpyj/logfile','/oradata/fpyj/logfile'; |
4. 在备库创建 adump 路径,与参数audit_file_dest的路径一致
$ mkdir -p /u01/app/oracle/admin/fpyjbak/adump |
5. 在备库创建init参数文件$ORACLE_HOME/dbs/initfpyjbak.ora',
有了这个临时的init参数文件,我们就可以在duplicate命令运行前将备库的AUXILIARY实例启动到nomount状态,这也是运行duplicate命令的一个必要条件。 initfpyj.ora文件只有一行信息: DB_NAME=fpyj |
6. 将密码文件从主库服务器拷贝到备库服务器,并且重命名:
[oracle@ora11204 scripts]$ cp orapwfpyj IP:$oracle_home/dbs/orapwfpyjbak |
7. 在主库服务器和备库服务器, 编辑添加下面信息到$ORACLE_HOME/network/tnsnames.ora
fpyj = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = fpyj) ) ) fpyjbak = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = fpyjbak) ) ) |
8. 在备库服务器, 添加静态注册信息到 $ORACLE_HOME/network/admin/listener.ora文件,
这主要是由于AUXILIARY实例启动到nomount状态时,listener无法注册AUXILIARY实例,listener会标志Auxiliary实例为'blocked'状态,因此duplicate命令就无法通过TNS的方式连接到Auxiliary实例,为了解决这个问题,需要先手动静态注册数据库实例到listener上。
当Data Guard配置完成后,就可以删除静态注册的配置信息。
(本测试使用ASM,因此需要安装GRID,有效的listener.ora文件是在GRID_HOME下面)
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = fpyj) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) ) (SID_DESC = (SID_NAME =fpyjbak) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (GLOBAL_DBNAME=fpyjbak) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1)) (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) ) ) |
9. 在备库服务器,启动AUXILIARY实例到 nomount 状态:
[oracle@ora11204 scripts]$ export ORACLE_SID=fpyjbak [oracle@ora11204 scripts]$ sqlplus / as sysdba SYS(125_9)@fpyj> startup nomount; |
10. 在备库测试与AUXILIARY实例的连接和与主库的连接,如果连接成功,继续执行下面的步骤,
很多时候duplicate命令失败都是由于连接失败导致的。
[oracle@ora11204 scripts]$ sqlplus sys/oracle@fpyj as sysdba [oracle@ora11204 scripts]$ sqlplus sys/oracle@fpyjbak as sysdba |
Duplicate.sql 如下:
duplicate target database for standby nofilenamecheck from active database dorecover spfile set db_unique_name='fpyj' set log_archive_dest_1='location=/oradata/fpyj/logfile valid_for=(all_logfiles,all_roles) db_unique_name=fpyj' set log_archive_dest_2='service=fpyj197 sync lgwr valid_for=(online_logfiles,primary_role) db_unique_name=fpyj' set standby_file_management='auto' #set service_name='fpyj' set fal_server='fpyj197' set fal_client='fpyj26' set control_files='/oradata/fpyj/controlfile/control01.ctl' #set memory_target='4400m' set sga_max_size='8053063680' set diagnostic_dest='/u01/app/oracle' set audit_file_dest='/u01/app/oracle/admin/fpyj/adump' set DB_FILE_NAME_CONVERT='/oradata/fpyj/datafile','/oradata/fpyj/datafile' set LOG_FILE_NAME_CONVERT='/oradata/fpyj/logfile','/oradata/fpyj/logfile'; |
11. 创建备库
在duplicate命令中指定关键字'FOR STANDBY'和'FROM ACTIVE DATABASE'表示从一个active的数据库来复制创建物理备库 参数'DORECOVER'表示duplicate命令会执行recover动作,否则duplicate命令只执行restore, 备库与主库不同的初始化参数,需要在duplicate命令中特殊指定,这样创建备库的spfile时就会用指定的值替换主库的参数值, 主库与备库的数据文件的路径不同,因此设置参数'DB_FILE_NAME_CONVERT' % rman target sys/oracle@fpyj auxiliary SYS/oracle@fpyjbak cmdfile=/home/oracle/scripts/duplicate.sql log=/home/oracle/scripts/duplicate.log |
以下是duplicate standby database过程中的log信息 Recovery Manager: Release 11.2.0.1.0 - Production on Mon Dec 4 09:56:11 2017 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connected to target database: FPYJ (DBID=2203137797) connected to auxiliary database: FPYJ (not mounted) RMAN> duplicate target database for standby nofilenamecheck 2> from active database 3> dorecover 4> spfile 5> set db_unique_name='fpyj' 6> set log_archive_dest_1='location=/u01/oradata/fpyjbak/logfile 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 service_name='fpyj' 10> set fal_server='fpyj' 11> set fal_client='fpyjbak' 12> set control_files='/u01/oradata/fpyjbak/controlfile/control01.ctl' 13> #set memory_target='4400m' 14> set sga_max_size='205306368' 15> set diagnostic_dest='/u01/app/oracle' 16> set audit_file_dest='/u01/app/oracle/admin/fpyjbak/adump' 17> set DB_FILE_NAME_CONVERT='/oradata/fpyj/datafile','/u01/oradata/fpyjbak/datafile/' 18> set LOG_FILE_NAME_CONVERT='/oradata/fpyj/logfile','/u01/oradata/fpyjbak/logfile'; 19> 20> 21> Starting Duplicate Db at 04-DEC-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/orapwfpyj' 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/spfilefpyj.ora' ; sql clone "alter system set spfile= ''/u01/app/oracle/product/11.2.0/db_1/dbs/spfilefpyj.ora''"; } executing Memory Script Starting backup at 04-DEC-17 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=37 device type=DISK Finished backup at 04-DEC-17 sql statement: alter system set spfile= ''/u01/app/oracle/product/11.2.0/db_1/dbs/spfilefpyj.ora'' contents of Memory Script: { sql clone "alter system set db_unique_name = ''fpyj'' comment= '''' scope=spfile"; sql clone "alter system set log_archive_dest_1 = ''location=/u01/oradata/fpyjbak/logfile 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/oradata/fpyjbak/controlfile/control01.ctl'' comment= '''' scope=spfile"; sql clone "alter system set sga_max_size = 205306368 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 = ''/oradata/fpyj/datafile'', ''/u01/oradata/fpyjbak/datafile/'' comment= '''' scope=spfile"; sql clone "alter system set LOG_FILE_NAME_CONVERT = ''/oradata/fpyj/logfile'', ''/u01/oradata/fpyjbak/logfile'' comment= '''' scope=spfile"; shutdown clone immediate; startup clone nomount; } executing Memory Script sql statement: alter system set db_unique_name = ''fpyj'' comment= '''' scope=spfile sql statement: alter system set log_archive_dest_1 = ''location=/u01/oradata/fpyjbak/logfile 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/oradata/fpyjbak/controlfile/control01.ctl'' comment= '''' scope=spfile sql statement: alter system set sga_max_size = 205306368 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 = ''/oradata/fpyj/datafile'', ''/u01/oradata/fpyjbak/datafile/'' comment= '''' scope=spfile sql statement: alter system set LOG_FILE_NAME_CONVERT = ''/oradata/fpyj/logfile'', ''/u01/oradata/fpyjbak/logfile'' comment= '''' scope=spfile Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 204591104 bytes Fixed Size 2211888 bytes Variable Size 130027472 bytes Database Buffers 67108864 bytes Redo Buffers 5242880 bytes contents of Memory Script: { backup as copy current controlfile for standby auxiliary format '/u01/oradata/fpyjbak/controlfile/control01.ctl'; } executing Memory Script Starting backup at 04-DEC-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=TAG20171204T095618 RECID=8 STAMP=961840580 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 Finished backup at 04-DEC-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/oradata/fpyjbak/datafile/system01.dbf for datafile 1 with checkpoint SCN of 1164570 Using previous duplicated file /u01/oradata/fpyjbak/datafile/sysaux01.dbf for datafile 2 with checkpoint SCN of 1164586 Using previous duplicated file /u01/oradata/fpyjbak/datafile/undotbs01.dbf for datafile 3 with checkpoint SCN of 1164599 Using previous duplicated file /u01/oradata/fpyjbak/datafile/users01.dbf for datafile 4 with checkpoint SCN of 1164601 contents of Memory Script: { set newname for tempfile 1 to "/u01/oradata/fpyjbak/datafile//temp01.dbf"; switch clone tempfile all; sql 'alter system archive log current'; } executing Memory Script executing command: SET NEWNAME renamed tempfile 1 to /u01/oradata/fpyjbak/datafile//temp01.dbf in control file sql statement: alter system archive log current contents of Memory Script: { backup as copy reuse archivelog like "/u01/arch/1_152_961433862.dbf" auxiliary format "/u01/oradata/fpyjbak/logfile/1_152_961433862.dbf" archivelog like "/u01/arch/1_151_961433862.dbf" auxiliary format "/u01/oradata/fpyjbak/logfile/1_151_961433862.dbf" archivelog like "/u01/arch/1_153_961433862.dbf" auxiliary format "/u01/oradata/fpyjbak/logfile/1_153_961433862.dbf" archivelog like "/u01/arch/1_154_961433862.dbf" auxiliary format "/u01/oradata/fpyjbak/logfile/1_154_961433862.dbf" ; catalog clone archivelog "/u01/oradata/fpyjbak/logfile/1_152_961433862.dbf"; catalog clone archivelog "/u01/oradata/fpyjbak/logfile/1_151_961433862.dbf"; catalog clone archivelog "/u01/oradata/fpyjbak/logfile/1_153_961433862.dbf"; catalog clone archivelog "/u01/oradata/fpyjbak/logfile/1_154_961433862.dbf"; catalog clone datafilecopy "/u01/oradata/fpyjbak/datafile/system01.dbf", "/u01/oradata/fpyjbak/datafile/sysaux01.dbf", "/u01/oradata/fpyjbak/datafile/undotbs01.dbf", "/u01/oradata/fpyjbak/datafile/users01.dbf"; switch clone datafile 1 to datafilecopy "/u01/oradata/fpyjbak/datafile/system01.dbf"; switch clone datafile 2 to datafilecopy "/u01/oradata/fpyjbak/datafile/sysaux01.dbf"; switch clone datafile 3 to datafilecopy "/u01/oradata/fpyjbak/datafile/undotbs01.dbf"; switch clone datafile 4 to datafilecopy "/u01/oradata/fpyjbak/datafile/users01.dbf"; } executing Memory Script Starting backup at 04-DEC-17 using channel ORA_DISK_1 channel ORA_DISK_1: starting archived log copy input archived log thread=1 sequence=152 RECID=169 STAMP=961840429 output file name=/u01/oradata/fpyjbak/logfile/1_152_961433862.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=151 RECID=170 STAMP=961840430 output file name=/u01/oradata/fpyjbak/logfile/1_151_961433862.dbf RECID=0 STAMP=0 channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting archived log copy input archived log thread=1 sequence=153 RECID=171 STAMP=961840587 output file name=/u01/oradata/fpyjbak/logfile/1_153_961433862.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=154 RECID=172 STAMP=961840587 output file name=/u01/oradata/fpyjbak/logfile/1_154_961433862.dbf RECID=0 STAMP=0 channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01 Finished backup at 04-DEC-17 cataloged archived log archived log file name=/u01/oradata/fpyjbak/logfile/1_152_961433862.dbf RECID=1 STAMP=961840594 cataloged archived log archived log file name=/u01/oradata/fpyjbak/logfile/1_151_961433862.dbf RECID=2 STAMP=961840594 cataloged archived log archived log file name=/u01/oradata/fpyjbak/logfile/1_153_961433862.dbf RECID=3 STAMP=961840594 cataloged archived log archived log file name=/u01/oradata/fpyjbak/logfile/1_154_961433862.dbf RECID=4 STAMP=961840594 cataloged datafile copy datafile copy file name=/u01/oradata/fpyjbak/datafile/system01.dbf RECID=8 STAMP=961840594 cataloged datafile copy datafile copy file name=/u01/oradata/fpyjbak/datafile/sysaux01.dbf RECID=9 STAMP=961840594 cataloged datafile copy datafile copy file name=/u01/oradata/fpyjbak/datafile/undotbs01.dbf RECID=10 STAMP=961840594 cataloged datafile copy datafile copy file name=/u01/oradata/fpyjbak/datafile/users01.dbf RECID=11 STAMP=961840594 datafile 1 switched to datafile copy input datafile copy RECID=8 STAMP=961840594 file name=/u01/oradata/fpyjbak/datafile/system01.dbf datafile 2 switched to datafile copy input datafile copy RECID=9 STAMP=961840594 file name=/u01/oradata/fpyjbak/datafile/sysaux01.dbf datafile 3 switched to datafile copy input datafile copy RECID=10 STAMP=961840594 file name=/u01/oradata/fpyjbak/datafile/undotbs01.dbf datafile 4 switched to datafile copy input datafile copy RECID=11 STAMP=961840594 file name=/u01/oradata/fpyjbak/datafile/users01.dbf contents of Memory Script: { set until scn 1165711; recover standby clone database delete archivelog ; } executing Memory Script
executing command: SET until clause
Starting recover at 04-DEC-17 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=18 device type=DISK
starting media recovery
archived log for thread 1 with sequence 151 is already on disk as file /u01/oradata/fpyjbak/logfile/1_151_961433862.dbf archived log for thread 1 with sequence 152 is already on disk as file /u01/oradata/fpyjbak/logfile/1_152_961433862.dbf archived log for thread 1 with sequence 153 is already on disk as file /u01/oradata/fpyjbak/logfile/1_153_961433862.dbf archived log for thread 1 with sequence 154 is already on disk as file /u01/oradata/fpyjbak/logfile/1_154_961433862.dbf archived log file name=/u01/oradata/fpyjbak/logfile/1_151_961433862.dbf thread=1 sequence=151 archived log file name=/u01/oradata/fpyjbak/logfile/1_152_961433862.dbf thread=1 sequence=152 archived log file name=/u01/oradata/fpyjbak/logfile/1_153_961433862.dbf thread=1 sequence=153 archived log file name=/u01/oradata/fpyjbak/logfile/1_154_961433862.dbf thread=1 sequence=154 media recovery complete, elapsed time: 00:00:03 Finished recover at 04-DEC-17 Finished Duplicate Db at 04-DEC-17 Recovery Manager complete. |
以上创建完成了物理standby数据库(最后的错误警告信息可以忽略,我们在后面的附录1详细解释这个错误信息)。但是备库数据库还没有开始应用redo log。
12. 备库创建standby redo log,standby redo log大小等于主库online redo log大小,注 备库的standby log 应比主库的online 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. SYS(125_13)@fpyjbak> set linesize 1000 SYS(125_13)@fpyjbak> set pagesize 1000 SYS(125_13)@fpyjbak> set long 100 SYS(125_13)@fpyjbak> col archived for a10 SQL> select sequence#,used,archived,status from v$standby_log; SEQUENCE# USED ARCHIVED STATUS ---------- ---------- ---------- ---------- 0 0 YES UNASSIGNED 0 0 YES UNASSIGNED 0 0 YES UNASSIGNED 0 0 YES UNASSIGNED |
13. 运行下面的命令开始应用redo log:
SYS(14_17)@fpyjbak> alter database recover managed standby database using current logfile disconnect from session; alter database recover managed standby database using current logfile disconnect from session; * ERROR at line 1: ORA-01153: an incompatible media recovery is active SYS(14_17)@fpyjbak> alter database recover managed standby database cancel; Database altered. 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参数:
SYS(125_9)@fpyj> shutdown immediate;
SYS(125_9)@fpyj> startup mount;
SYS(125_9)@fpyj> ALTER DATABASE ADD LOGFILE GROUP 4 ('+DATA/redo01.log') SIZE 52428800;
SYS(125_9)@fpyj> ALTER DATABASE ADD LOGFILE GROUP 5 ('+DATA/redo02.log') SIZE 52428800;
SYS(125_9)@fpyj> ALTER DATABASE ADD LOGFILE GROUP 6 ('+DATA/redo03.log') SIZE 52428800;
SYS(125_9)@fpyj> alter system set log_file_name_convert='/home/oracle/app/oradata/orcl','+data' scope=spfile;
SYS(125_9)@fpyj> shutdown immediate;
SYS(125_9)@fpyj> startup mount;
SYS(125_9)@fpyj> 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)@fpyj> 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
- 1. 验证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 a10
SYS(125_9)@fpyjbak> 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)@fpyj> 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)@fpyj> col name for a30
SYS(14_17)@fpyj> col value for a30
SYS(14_17)@fpyj> col datum_time for a30
SYS(14_17)@fpyj> col TIME_COMPUTED for a20
SYS(14_17)@fpyj> set line 160
SYS(14_17)@fpyj> 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)@fpyjbak> select thread#,sequence#,applied from v$archived_log;
THREAD# SEQUENCE# APPLIED
---------- ---------- ---------
1 50 YES
Oracle11g ADG环境实施文档-1204的更多相关文章
- Oracle 11g 单实例到单实例OGG同步实施文档-OGG initial load
Oracle 11g 单实例到单实例OGG同步实施文档-OGG initial load 2018-06-07 00:514730原创GoldenGate 作者: leo 本文链接:https://w ...
- Oracle 11g 单实例到单实例OGG同步实施文档-RMAN 初始化
Oracle 11g 单实例到单实例OGG同步实施文档-RMAN 初始化 2018-06-07 13:455170原创GoldenGate 作者: leo 本文链接:https://www.cndba ...
- Oracle 11g 单实例到单实例OGG同步实施文档-EXPDP初始化
Oracle 11g 单实例到单实例OGG同步实施文档-EXPDP初始化 2018-06-07 00:446470原创GoldenGate 作者: leo 本文链接:https://www.cndba ...
- PROD异机全备份恢复验证实施文档
PROD异机全备份恢复验证实施文档 ******利用10月25日的全量备份.10月26日当天的归档日志及当前redo日志,恢复数据库到故障前数据库状态****** 准备工作:source 源库:PRO ...
- python3.6环境部署文档
python3.6环境部署文档 内容 Linux部署Python3.6环境 Mac部署Python3.6环境 Window10部署Python3.6环境 Pycharm安装 1. Linux部署P ...
- DATAGUARD实施文档
DATAGUARD实施文档 一.前期准备及备机安装: 通过获取到的主机信息规划备机数据库安装基础信息:(注:在安装备机时需要尽量保障与主机库信息一致,以下表格中的备机信息为根据主机信息规划的安装信息. ...
- CentOS6.5下安装JDK1.7+MYSQL5.5+TOMCAT7+nginx1.7.5环境安装文档
----------------CentOS6.5下安装JDK1.7+MYSQL5.5+TOMCAT7+nginx1.7.5环境安装文档----------------------- [JDK1.7安 ...
- VUE CLI环境搭建文档
VUE CLI环境搭建文档 1.安装Node.js 下载地址 https://nodejs.org/zh-cn/download/ 2.全局安装VUE CLI win+R键打开运行cmd窗口输入一下代 ...
- 环境安装文档(for Ubuntu)
这个文档的目标是:各位小伙伴通过这个文档,可以在一台全新的 Ubuntu 电脑上搭建平常开发使用的环境,主要包含 Node.js, git 和 编辑器部分. 这是针对 Ubuntu 系统的安装文档,W ...
随机推荐
- ZOJ 2112 Dynamic Rankings(树状数组+主席树)
题意 \(n\) 个数,\(m\) 个操作,每次操作修改某个数,或者询问某个区间的第 \(K\) 小值. \(1 \leq n \leq 50000\) \(1 \leq m \leq 10000\) ...
- 利用C#实现AOP常见的几种方法详解
利用C#实现AOP常见的几种方法详解 AOP面向切面编程(Aspect Oriented Programming) 是通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术. 下面这篇文章主要 ...
- Python学习 day01打卡
1.Python : 是一门解释型 弱类型 高级开发编程语言. 2.第一个Python程序的编写: print ("hell,world") 3.变量:把程序运行过程中的值储存起来 ...
- MVC ---- 怎删改查
using Modelsop; using System; using System.Collections.Generic; using System.Linq; using System.Web; ...
- File操作-将数据库里的数据写入到指定路径的txt文件里
package com.Cristin.File;//将数据库里的数据写入到指定路径的txt文件里 import java.io.File;import java.io.FileOutputStrea ...
- 如何查找CpG Islands, CpG shores等 --转载
转载自: http://blog.sciencenet.cn/blog-306699-1033567.html 在homo species物种,随着研究的深入,注释信息不断丰富 针对CpG Islan ...
- rm
rm [选项]... 目录... 删除指定的<文件>(即解除链接). -d --directory 删除可能仍有数据的目录 (只限超级用户)-f --force ...
- image以最小边为标准填满正方形父级元素
需求: 上传图片并实现预览, 图片以最小边为标准填满正方形的父级div,且不变形,且点击可以预览大图. 有两种实现方式: 1.div+img标签, 利用object-fit:cover,据说兼容性不好 ...
- 关于repaint和reflow的笔记
repaint(重绘) ,repaint发生更改时,元素的外观被改变,且在没有改变布局的情况下发生,如改变outline,visibility,background color,box-shadow不 ...
- 《剑指offer》第五十六题(数组中只出现一次的两个数字)
// 面试题56(一):数组中只出现一次的两个数字 // 题目:一个整型数组里除了两个数字之外,其他的数字都出现了两次.请写程序 // 找出这两个只出现一次的数字.要求时间复杂度是O(n),空间复杂度 ...