[20170215]再次理解flush redo.txt

简介: [20170215]再次理解flush redo.txt --链接: http://blog.itpub.net/267265/viewspace-1992583/ http://blog.itpub.net/267265/viewspace-1992840/ 在Oracle 11g里,Data Guard 切换多了一个新的功能:flush redo。

[20170215]再次理解flush redo.txt

--链接:
http://blog.itpub.net/267265/viewspace-1992583/
http://blog.itpub.net/267265/viewspace-1992840/

在Oracle 11g里,Data Guard 切换多了一个新的功能:flush redo。

flush redo就是出现问题时,Flush可以把没有发送的redo从主库传送到standby数据库。而只要主库能启动到mount状态,那么Flush 就可
以把没有发送的归档和current online redo 发送到备库。

Flush语法:

SQL> ALTER SYSTEM FLUSH REDO TO target_db_name;

这里的target_db_name 是我们在主库的db_unique_name 名称。 Flush 会将未发送的redo 从主库
传到备库,并且等待redo 在standby 库上apply 之后返回成功。 所以只要Flush成功,那么Failover 就没有主句丢失。

--//我前面的测试target_db_name必须加引号,只所以回头看文档主要春节前在解决一套容灾系统时,发现许多我不习惯的做法,
--//没有fal等参数,而且db_unique_name两边是一样的,感觉很不规范.我一直认为在dg中每个都应该分配一个不同的db_unique_name.

--//再仔细看这篇文件,使用的是db_unique_name.
--//顺便提一下oracle的name缺省很容易混淆,特别是概念不清晰的情况下.而且许多情况下都是一样的.

--//以后学习还是给认真看oracle 官方文档为准.
http://docs.oracle.com/cd/E11882_01/server.112/e41134/sql_stmts.htm#SBYDB5117
ALTER SYSTEM FLUSH REDO TO target_db_name [[NO] CONFIRM APPLY]
   
This statement flushes redo data from a primary database to a standby database and optionally waits for the flushed redo
data to be applied to a physical or logical standby database.

This statement must be issued on a mounted, but not open, primary database.

--//这里并没有指出target_db_name是什么?

http://docs.oracle.com/cd/E11882_01/server.112/e17766/e12700.htm
8.2.2 Performing a Failover to a Physical Standby Database

This section describes how to perform a failover to a physical standby database.

Step 1   Flush any unsent redo from the primary database to the target standby database.

If the primary database can be mounted, it may be possible to flush any unsent archived and current redo from the
primary database to the standby database. If this operation is successful, a zero data loss failover is possible even if
the primary database is not in a zero data loss data protection mode.

Ensure that Redo Apply is active at the target standby database.

Mount, but do not open the primary database. If the primary database cannot be mounted, go to Step 2.

Issue the following SQL statement at the primary database:

SQL> ALTER SYSTEM FLUSH REDO TO target_db_name;

For target_db_name, specify the DB_UNIQUE_NAME of the standby database that is to receive the redo flushed from the
primary database.

This statement flushes any unsent redo from the primary database to the standby database, and waits for that redo to be
applied to the standby database.

If this statement completes without any errors, go to Step 5. If the statement completes with any error, or if it must
be stopped because you cannot wait any longer for the statement to complete, continue with Step 2.

--//这里明确的指出是DB_UNIQUE_NAME,好了现在重复测试.
1.环境:
SYS@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

--//停止备库.
--//在主库执行:
alter system archive log current ;
alter system archive log current ;
alter system archive log current ;
alter system archive log current ;
alter system archive log current ;
alter system archive log current ;

SYS@book> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/archivelog/book
Oldest online log sequence     613
Next log sequence to archive   615
Current log sequence           615

--//当前seq=615.关闭主库.

2.测试flush redo前准备,主要配置不同的db_unique_name,验证target_db_name参数.
--//备库:
SYS@bookdg> startup nomount
ORACLE instance started.
Total System Global Area    634732544 bytes
Fixed Size                    2255792 bytes
Variable Size               197133392 bytes
Database Buffers            427819008 bytes
Redo Buffers                  7524352 bytes

SYS@bookdg> show parameter db_unique_name
NAME           TYPE   VALUE
-------------- ------ -------
db_unique_name string bookdg

--//修改db_unique_name为XXXX
SYS@bookdg> alter system set db_unique_name='XXXX' scope=spfile;
System altered.

SYS@bookdg> alter system set log_archive_config='DG_CONFIG=(book,bookdg,xxxx)';
System altered.

SYS@bookdg> alter system set log_archive_dest_1='LOCATION=/u01/app/oracle/archivelog/book MANDATORY VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=xxxx' scope=spfile;
System altered.

--//重启备库到mount:
SYS@bookdg> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.

SYS@bookdg> startup mount
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.

SYS@bookdg> show parameter db_unique_name
NAME           TYPE    VALUE
-------------- ------- -----
db_unique_name string  XXXX

--//主库有一些参数也要修改,因为备库的db_unique_name已经修改
--//主库:
SYS@book> startup nomount
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes

SYS@book> alter system set log_archive_config='DG_CONFIG=(book,bookdg,xxxx)';
System altered.

SYS@book> show parameter log_archive_dest_2
NAME               TYPE   VALUE
------------------ ------ ----------------------------------------------------------------------------------------------------
log_archive_dest_2 string SERVICE=bookdg LGWR ASYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=bookdg
--//这里也要修改为:
SYS@book> alter system set log_archive_dest_2='SERVICE=bookdg LGWR ASYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=xxxx' scope=spfile;
System altered.

--//关闭启动到mount状态.
SYS@book> shutdown immediate ;
ORA-01507: database not mounted
ORACLE instance shut down.

SYS@book> startup mount
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.

3.测试flush redo功能:
SYS@book> ALTER SYSTEM FLUSH REDO TO bookdg;
ALTER SYSTEM FLUSH REDO TO bookdg
                           *
ERROR at line 1:
ORA-00922: missing or invalid option


SYS@book> ALTER SYSTEM FLUSH REDO TO XXXX;
ALTER SYSTEM FLUSH REDO TO XXXX
                           *
ERROR at line 1:
ORA-00922: missing or invalid option
--//oracle 官方并没有提到这里要使用引号.^_^.我估计这里如果dg存在多个,应该这样写:ALTER SYSTEM FLUSH REDO TO 'dg1,dg2';

SYS@book> ALTER SYSTEM FLUSH REDO TO 'bookdg';
ALTER SYSTEM FLUSH REDO TO 'bookdg'
*
ERROR at line 1:
ORA-16053: DB_UNIQUE_NAME  is not in the Data Guard Configuration
=========================================
$ oerr ora 16053
16053, 00000, "DB_UNIQUE_NAME %s is not in the Data Guard Configuration"
// *Cause:  The specified DB_UNIQUE_NAME is not in the Data Guard
//          Configuration.
// *Action: If the DG_CONFIG attribute of the LOG_ARCHIVE_CONFIG parameter
//          is enabled, you must specify a valid DB_UNIQUE_NAME.  The list
//          of valid DB_UNIQUE_NAMEs can be seen with the V$DATAGUARD_CONFIG
//          view.  This problem can also occur when specifying a non-standby
//          destination with an DB_UNIQUE_NAME attribute that does not match
//          the DB_UNIQUE_NAME initialization parameter for the current
//          instance.
=========================================
--//因为找到合适的log_archive_dest_N,执行失败.

SYS@book> ALTER SYSTEM FLUSH REDO TO 'xxxx';
ALTER SYSTEM FLUSH REDO TO 'xxxx'
*
ERROR at line 1:
ORA-16447: Redo apply was not active at the target standby database

$ oerr ora 16447
16447, 00000, "Redo apply was not active at the target standby database"
// *Cause:  ALTER SYSTEM FLUSH REDO TO STANDBY failed because redo apply
//          is not active at the target database.
// *Action: Start redo apply at the standby database and reissue the
//          ALTER SYSTEM FLUSH REDO TO STANDBY statement, or reissue the
//          ALTER SYSTEM FLUSH REDO TO STANDBY statement with the
//          NO CONFIRM APPLY clause.

--//检查主库alert日志:
Wed Feb 15 15:33:34 2017
ALTER SYSTEM FLUSH REDO TO 'xxxx' CONFIRM APPLY
ALTER SYSTEM FLUSH REDO TO xxxx CONFIRM APPLY [Process Id: 28538] (book)
Flush redo: No wait for non-current ORLs to be archived
Waiting for all FAL entries to be archived...
All FAL entries have been archived.
Waiting for dest_id 2 to become synchronized...
Wed Feb 15 15:33:37 2017
ARC0: Standby redo logfile selected for thread 1 sequence 607 for destination LOG_ARCHIVE_DEST_2
Active, synchronized flush redo target has been identified
Recovery is not running at physical standby 'LOG_ARCHIVE_DEST_2'.
If this standby is the target, please startmanaged standby recovery at the target and re-issueFLUSH REDO command

--//检查备库日志
Wed Feb 15 15:33:37 2017
RFS[1]: Assigned to RFS process 19369
RFS[1]: Selected log 4 for thread 1 sequence 607 dbid 1337401710 branch 896605872
RFS[1]: Opened log for thread 1 sequence 608 dbid 1337401710 branch 896605872
Wed Feb 15 15:33:38 2017
Archived Log entry 445 added for thread 1 sequence 607 ID 0x4fb7d86e dest 1:
Archived Log entry 446 added for thread 1 sequence 608 rlc 896605872 ID 0x4fb7d86e dest 2:
RFS[1]: Opened log for thread 1 sequence 609 dbid 1337401710 branch 896605872
Archived Log entry 447 added for thread 1 sequence 609 rlc 896605872 ID 0x4fb7d86e dest 2:
RFS[1]: Opened log for thread 1 sequence 610 dbid 1337401710 branch 896605872
Archived Log entry 448 added for thread 1 sequence 610 rlc 896605872 ID 0x4fb7d86e dest 2:
RFS[1]: Opened log for thread 1 sequence 611 dbid 1337401710 branch 896605872
Archived Log entry 449 added for thread 1 sequence 611 rlc 896605872 ID 0x4fb7d86e dest 2:
RFS[1]: Opened log for thread 1 sequence 612 dbid 1337401710 branch 896605872
Archived Log entry 450 added for thread 1 sequence 612 rlc 896605872 ID 0x4fb7d86e dest 2:
RFS[1]: Opened log for thread 1 sequence 613 dbid 1337401710 branch 896605872
Archived Log entry 451 added for thread 1 sequence 613 rlc 896605872 ID 0x4fb7d86e dest 2:
RFS[1]: Opened log for thread 1 sequence 614 dbid 1337401710 branch 896605872
Archived Log entry 452 added for thread 1 sequence 614 rlc 896605872 ID 0x4fb7d86e dest 2:

--//说明:最后seq=614,归档的日志已经传输到备库.而online redo没有传输,从主库的alert提示看,没有打开传输设置.
--//备注:我以前的测试成功是因为使用dgmgrl管理dg.

--//在备库执行,打开传输与应用日志模式:
SYS@bookdg> alter database recover managed standby database using current logfile disconnect ;
Database altered.

--//检查备库日志
Wed Feb 15 15:37:45 2017
alter database recover managed standby database using current logfile disconnect
Attempt to start background Managed Standby Recovery process (bookdg)
Wed Feb 15 15:37:46 2017
MRP0 started with pid=24, OS id=19373
MRP0: Background Managed Standby Recovery process started (bookdg)
started logmerger process
Wed Feb 15 15:37:52 2017
Managed Standby Recovery starting Real Time Apply
Parallel Media Recovery started with 4 slaves
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Completed: alter database recover managed standby database using current logfile disconnect
Media Recovery Log /u01/app/oracle/archivelog/book/1_607_896605872.dbf
Media Recovery Log /u01/app/oracle/archivelog/book/1_608_896605872.dbf
Media Recovery Log /u01/app/oracle/archivelog/book/1_609_896605872.dbf
Media Recovery Log /u01/app/oracle/archivelog/book/1_610_896605872.dbf
Media Recovery Log /u01/app/oracle/archivelog/book/1_611_896605872.dbf
Media Recovery Log /u01/app/oracle/archivelog/book/1_612_896605872.dbf
Media Recovery Log /u01/app/oracle/archivelog/book/1_613_896605872.dbf
Media Recovery Log /u01/app/oracle/archivelog/book/1_614_896605872.dbf
Media Recovery Waiting for thread 1 sequence 615
--//等待主库传输seq=615.

--//在主库执行:
SYS@book> ALTER SYSTEM FLUSH REDO TO 'XXxX';
System altered.

--//注意:引号里面大小写混用,也是ok的,说明db_unique_name可以大小写混用的,虽然不提倡.

--//检查备库日志
Wed Feb 15 15:40:16 2017
RFS[2]: Assigned to RFS process 19393
RFS[2]: Selected log 4 for thread 1 sequence 615 dbid 1337401710 branch 896605872
Wed Feb 15 15:40:16 2017
Archived Log entry 453 added for thread 1 sequence 615 ID 0x4fb7d86e dest 1:
Wed Feb 15 15:40:17 2017
Media Recovery Log /u01/app/oracle/archivelog/book/1_615_896605872.dbf
Wed Feb 15 15:40:17 2017
Standby switchover readiness check: Checking whether recoveryapplied all redo..
Identified End-Of-Redo (move redo) for thread 1 sequence 615 at SCN 0x3.1756ba81
Database not available for switchover
  End-Of-REDO archived log file has not been recovered
  Incomplete recovery SCN:3:391538419 archive SCN:3:391559809
Physical Standby did not apply all the redo from the primary.
Resetting standby activation ID 1337448558 (0x4fb7d86e)
Media Recovery Waiting for thread 1 sequence 616
Wed Feb 15 15:40:19 2017
Standby switchover readiness check: Checking whether recoveryapplied all redo..
Physical Standby applied all the redo from the primary.

SYS@bookdg> @ &r/dg/dg
PROCESS       PID STATUS       CLIENT_P GROUP# THREAD#  SEQUENCE#     BLOCK#     BLOCKS DELAY_MINS
--------- ------- ------------ -------- ------ ------- ---------- ---------- ---------- ----------
RFS         19391 IDLE         ARCH     N/A          0          0          0          0          0
ARCH        19325 CLOSING      ARCH     4            1        615          1       1498          0
MRP0        19373 WAIT_FOR_LOG N/A      N/A          1        616          0          0          0

4.验证是否传输正确:
--//主库上执行:
SYS@book> set numw 12
SYS@book> @ &r/logfile ;
GROUP# STATUS     TYPE       MEMBER                           IS_ GROUP# THREAD# SEQUENCE#       BYTES BLOCKSIZE MEMBERS ARC STATUS     FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME
------ ---------- ---------- -------------------------------- --- ------ ------- --------- ----------- --------- ------- --- ---------- ------------- ------------------- ------------ -------------------
     1            ONLINE     /mnt/ramdisk/book/redo01.log     NO       1       1       614    52428800       512       1 YES INACTIVE     13276440300 2017-02-15 15:06:03  13276440307 2017-02-15 15:06:06
     2            ONLINE     /mnt/ramdisk/book/redo02.log     NO       2       1       615    52428800       512       1 YES CURRENT      13276440307 2017-02-15 15:06:06  13276461697 2017-02-15 15:40:15
     3            ONLINE     /mnt/ramdisk/book/redo03.log     NO       3       1       613    52428800       512       1 YES INACTIVE     13276440283 2017-02-15 15:05:50  13276440300 2017-02-15 15:06:03
     4            STANDBY    /mnt/ramdisk/book/redostb01.log  NO
     5            STANDBY    /mnt/ramdisk/book/redostb02.log  NO
     6            STANDBY    /mnt/ramdisk/book/redostb03.log  NO
     7            STANDBY    /mnt/ramdisk/book/redostb04.log  NO
7 rows selected.

SYS@book> alter system dump logfile '/mnt/ramdisk/book/redo02.log' validate;
System altered.

--//转储内容:
DUMP OF REDO FROM FILE '/mnt/ramdisk/book/redo02.log'
Opcodes *.*
RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff
SCNs: scn: 0x0000.00000000 thru scn: 0xffff.ffffffff
Times: creation thru eternity
VALIDATE ONLY
FILE HEADER:
    Compatibility Vsn = 186647552=0xb200400
    Db ID=1337401710=0x4fb7216e, Db Name='BOOK'
    Activation ID=1337448558=0x4fb7d86e
    Control Seq=33442=0x82a2, File size=102400=0x19000
    File Number=2, Blksiz=512, File Type=2 LOG
descrip:"Thread 0001, Seq# 0000000615, SCN 0x0003175666f3-0xffffffffffff"
thread: 1 nab: 0x5db seq: 0x00000267 hws: 0x4 eot: 3 dis: 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
resetlogs count: 0x35711eb0 scn: 0x0000.000e2006 (925702)
prev resetlogs count: 0x3121c97a scn: 0x0000.00000001 (1)
Low  scn: 0x0003.175666f3 (13276440307) 02/15/2017 15:06:06
Next scn: 0xffff.ffffffff 01/01/1988 00:00:00
Enabled scn: 0x0000.000e2006 (925702) 11/24/2015 09:11:12
Thread closed scn: 0x0003.17566c5e (13276441694) 02/15/2017 15:23:11
Disk cksum: 0x184 Calc cksum: 0x184
Terminal recovery stop scn: 0x0000.00000000
Terminal recovery  01/01/1988 00:00:00
Most recent redo scn: 0x0000.00000000
Largest LWN: 17 blocks
End-of-redo stream : Yes
Unprotected mode
Miscellaneous flags: 0x4800008
Thread internal enable indicator: thr: 0, seq: 0 scn: 0x0000.00000000
Zero blocks: 8
Format ID is 2
redo log key is a7f8a15237d6b5e7fe61cb4acdc6227b
redo log key flag is 5
Enabled redo threads: 1
END OF REDO DUMP
----- Redo read statistics for thread 1 -----
Read rate (SYNC): 748Kb in 0.01s => 73.10 Mb/sec
Total redo bytes: 748Kb Longest record: 2Kb, moves: 0/617 moved: 0Mb (0%)
Longest LWN: 8Kb, reads: 1192
Last redo scn: 0x0003.17566c5b (13276441691)
Change vector header moves = 103/1210 (8%)
----------------------------------------------

--//备库上执行:
SYS@bookdg> alter system dump logfile '/u01/app/oracle/archivelog/book/1_615_896605872.dbf' validate;
System altered.

--//转储内容:
DUMP OF REDO FROM FILE '/u01/app/oracle/archivelog/book/1_615_896605872.dbf'
Opcodes *.*
RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff
SCNs: scn: 0x0000.00000000 thru scn: 0xffff.ffffffff
Times: creation thru eternity
VALIDATE ONLY
FILE HEADER:
    Compatibility Vsn = 186647552=0xb200400
    Db ID=1337401710=0x4fb7216e, Db Name='BOOK'
    Activation ID=1337448558=0x4fb7d86e
    Control Seq=44808=0xaf08, File size=102400=0x19000
    File Number=4, Blksiz=512, File Type=2 LOG
descrip:"Thread 0001, Seq# 0000000615, SCN 0x0003175666f3-0x00031756ba81"
thread: 1 nab: 0x5db seq: 0x00000267 hws: 0x5 eot: 0 dis: 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
resetlogs count: 0x35711eb0 scn: 0x0000.000e2006 (925702)
prev resetlogs count: 0x3121c97a scn: 0x0000.00000001 (1)
Low  scn: 0x0003.175666f3 (13276440307) 02/15/2017 15:06:06
Next scn: 0x0003.1756ba81 (13276461697) 02/15/2017 15:40:15
Enabled scn: 0x0000.000e2006 (925702) 11/24/2015 09:11:12
Thread closed scn: 0x0003.17566c5e (13276441694) 02/15/2017 15:23:11
Disk cksum: 0x1f22 Calc cksum: 0x1f22
Terminal recovery stop scn: 0x0000.00000000
Terminal recovery  01/01/1988 00:00:00
Most recent redo scn: 0x0003.1756ba80 (13276461696)
Largest LWN: 17 blocks
End-of-redo stream : Yes
Unprotected mode
Miscellaneous flags: 0x48000b9
Thread internal enable indicator: thr: 0, seq: 0 scn: 0x0000.00000000
Zero blocks: 8
Format ID is 2
redo log key is a7f8a15237d6b5e7fe61cb4acdc6227b
redo log key flag is 5
Enabled redo threads: 1
END OF REDO DUMP
----- Redo read statistics for thread 1 -----
Read rate (SYNC): 748Kb in 0.01s => 73.10 Mb/sec
Total redo bytes: 748Kb Longest record: 2Kb, moves: 0/617 moved: 0Mb (0%)
Longest LWN: 8Kb, reads: 1192
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Last redo scn: 0x0003.17566c5b (13276441691)
Change vector header moves = 103/1210 (8%)
----------------------------------------------

--//因为主库还没有归档,从~内容看,应该没有问题.

5.总结:
1.写的有点长^_^.
2.ALTER SYSTEM FLUSH REDO TO target_db_name;中参数target_db_name里面是db_unique_name.并且要使用引号,另外我估计多个要写成类似
  ALTER SYSTEM FLUSH REDO TO 'xxxdg1,xxxdg2' 格式.
3.备库要设置在传输模式:
  alter database recover managed standby database using current logfile nt logfile disconnect ;
  或者
  alter database recover managed standby database disconnect from session ;
4.要好好看官方文档,比如fal*参数对应的是Oracle Net service name,开始不看文档我以为也是db_unique_name.
  http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams088.htm
  而参数LOG_ARCHIVE_CONFIG里面的DG_CONFIG实际上DB_UNIQUE_NAME
  Specifies a list of up to 30 unique database names (defined with the DB_UNIQUE_NAME initialization parameter) for all
  of the databases in the Data Guard configuration.
  http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams123.htm#REFRN10237
5.我感觉oracle不如把这个命令改写为:
  ALTER SYSTEM FLUSH REDO TO log_archive_dest_N;
  这样好理解.不容易错误.^_^.
6.实际上测试中总是磕磕绊绊,还遇到一个问题就是备库参数log_archive_dest_1中.如果最后的DB_UNIQUE_NAME=bookdg(与配置不一致)
  在启动备库时alert提示:
Wed Feb 15 11:37:49 2017
Using STANDBY_ARCHIVE_DEST parameter default value as ?/dbs/arch

--//这样传输的归档实际上在dbs目录
$ ls -l /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/arch*
-rw-r-----  1 oracle oinstall 4608 2017-02-15 11:43:18 /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/arch1_593_896605872.dbf
-rw-r-----  1 oracle oinstall 3584 2017-02-15 11:43:18 /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/arch1_594_896605872.dbf
-rw-r-----  1 oracle oinstall 1024 2017-02-15 11:43:18 /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/arch1_595_896605872.dbf
--//配置本地归档可以不使用最后的DB_UNIQUE_NAME=XXXX.

7.最后我的观点,在配置dg中每个数据库配置不同的DB_UNIQUE_NAME有必要的.无论是备份还是管理都很有必要.
  而且规范的命令风格也很重要,像我们的灾备系统主库net 服务名xxxx,备库net 服务名yyyy,非常容易乱.
  而如果主库net服务名xxxx,备库net 服务名xxxxdg,不是很清晰明了.
  我一般建议配置数据库的ORACLE_SID不要超过6个字符,这样备库存在多个,我习惯的备库命令ORACLE_SID命名风格是xxxxxxd1,xxxxxxd2.
8.还原相关设置:

--//备库:
SYS@bookdg> alter system set log_archive_config='DG_CONFIG=(book,bookdg)';
System altered.

SYS@bookdg> alter system set log_archive_dest_1='LOCATION=/u01/app/oracle/archivelog/book MANDATORY VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=bookdg' scope=spfile;
System altered.

SYS@bookdg> alter system set db_unique_name='bookdg' scope=spfile;
System altered.

--//主库:
SYS@book> alter system set log_archive_config='DG_CONFIG=(book,bookdg)';
System altered.

SYS@book> alter system set log_archive_dest_2='SERVICE=bookdg LGWR ASYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=bookdg' ;
System altered.

目录
相关文章
|
9月前
|
存储 SQL 缓存
【MySQL】change buffer,buffer pool,redo log,bin log,undo log的作用
【MySQL】change buffer,buffer pool,redo log,bin log,undo log的作用
94 0
|
6月前
|
关系型数据库 MySQL 数据库
MySQL学习笔记-change buffer 和 redo log
MySQL学习笔记-change buffer 和 redo log
82 0
|
关系型数据库 Oracle
|
监控 Oracle 关系型数据库
[20171115]redo and commit.txt
[20171115]redo and commit.txt --//参考Jonathan Lewis的https://jonathanlewis.wordpress.com/2011/08/19/redo-2/ --//很早以前的帖子,自己觉得很有意思,重复测试: --//事务已经提交,但是redo log buffer还没有写到磁盘.
1022 0
|
机器学习/深度学习 SQL 关系型数据库
[20170520]利用undo表空间保护数据.txt
[20170520]利用undo表空间保护数据.txt --//undo表空间是用来记录前映像信息,也用来保证查询时一致性的.上个星期去听一些课,提到不打开归档情况下一些维护技巧, --//就是建立多个redo日志文件,用来保存日志,至少维持3-4天甚至1个星期的日志,这样可以一定程度减少错误以及会查问题.
828 0
|
监控 Oracle 关系型数据库
[20170412]分析重做日志.txt
[20170412]分析重做日志.txt --//自己很少做重做日志转储,测试看看。 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER --...
1015 0
|
监控 Oracle 关系型数据库
[20170308]关于redo dump.txt
[20170308]关于redo dump.txt --//前一阵子在探究是否可以备库的备用日志来恢复主库,当主库在线日志丢失的情况下.遇到一些问题. DUMP OF REDO FROM FILE '/mnt/ramdisk/book/redo01.
693 0
|
缓存 Apache PHP
flush vs ob_flush
刷新PHP程序的缓冲,而不论PHP执行在何种情况下(CGI ,web服务器等等)。该函数将当前为止程序的所有输出发送到用户的浏览器。 flush() 函数不会对服务器或客户端浏览器的缓存模式产生影响。因此,必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。
865 0