[20180413]热备模式相关问题.txt

简介: [20180413]热备模式相关问题.txt --//昨天遇到开启热备模式的相关问题,一个不是很重要的数据库,估计有人开启了热备模式,异常关机,打开报错, --//自己在测试环境重复测试: 1.

[20180413]热备模式相关问题.txt

--//昨天遇到开启热备模式的相关问题,一个不是很重要的数据库,估计有人开启了热备模式,异常关机,打开报错,
--//自己在测试环境重复测试:

1.环境:

SCOTT@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

SCOTT@book> alter database begin backup ;
Database altered.

SYS@book> shutdown immediate
ORA-01149: cannot shutdown - file 1 has online backup set
ORA-01110: data file 1: '/mnt/ramdisk/book/system01.dbf'

--//处于热备模式,无法正常关闭数据库.排除system表空间看看,是否可以关闭数据库.

SYS@book> set numw 12
SYS@book> select * from v$backup ;
       FILE# STATUS                  CHANGE# TIME
------------ ------------------ ------------ -------------------
           1 ACTIVE              13277525910 2018-04-13 09:03:44
           2 ACTIVE              13277525910 2018-04-13 09:03:44
           3 ACTIVE              13277525910 2018-04-13 09:03:44
           4 ACTIVE              13277525910 2018-04-13 09:03:44
           5 ACTIVE              13277525910 2018-04-13 09:03:44
           6 ACTIVE              13277525910 2018-04-13 09:03:44
6 rows selected.

SYS@book> alter tablespace system  end   backup ;
Tablespace altered.

SYS@book> select * from v$backup ;
       FILE# STATUS                  CHANGE# TIME
------------ ------------------ ------------ -------------------
           1 NOT ACTIVE          13277525910 2018-04-13 09:03:44
           2 ACTIVE              13277525910 2018-04-13 09:03:44
           3 ACTIVE              13277525910 2018-04-13 09:03:44
           4 ACTIVE              13277525910 2018-04-13 09:03:44
           5 ACTIVE              13277525910 2018-04-13 09:03:44
           6 ACTIVE              13277525910 2018-04-13 09:03:44
6 rows selected.

SYS@book> shutdown immediate
ORA-01149: cannot shutdown - file 2 has online backup set
ORA-01110: data file 2: '/mnt/ramdisk/book/sysaux01.dbf'

--//也就是处于热备份,如果有表空间处于热备模式,无法正常关闭数据库.我结束sysaux,UNDOTBS1也一样遇到上述问题.

2.模拟异常关闭数据库:
SYS@book> shutdown abort ;
ORACLE instance shut down.

SYS@book> startup
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.
ORA-10873: file 4 needs to be either taken out of backup mode or media recovered
ORA-01110: data file 4: '/mnt/ramdisk/book/users01.dbf'

SYS@book> select * from v$backup ;
       FILE# STATUS                  CHANGE# TIME
------------ ------------------ ------------ -------------------
           1 NOT ACTIVE          13277525910 2018-04-13 09:03:44
           2 NOT ACTIVE          13277525910 2018-04-13 09:03:44
           3 NOT ACTIVE          13277525910 2018-04-13 09:03:44
           4 ACTIVE              13277525910 2018-04-13 09:03:44
           5 ACTIVE              13277525910 2018-04-13 09:03:44
           6 ACTIVE              13277525910 2018-04-13 09:03:44
6 rows selected.

3.解决方法:
--//方法1:
SYS@book> recover datafile 4;
Media recovery complete.

SYS@book> alter database open ;
alter database open
*
ERROR at line 1:
ORA-10873: file 5 needs to be either taken out of backup mode or media recovered
ORA-01110: data file 5: '/mnt/ramdisk/book/example01.dbf'

--//简单recover database可以修复.

--//方法2:
SYS@book> alter database end   backup ;
Database altered.

SYS@book> alter database open ;
Database altered.

--//不知道如果归档不存在情况如何,验证看看.

4.验证归档不存在的情况:
SYS@book> alter tablespace users begin backup ;
Tablespace altered.

SYS@book> select * from v$backup where file#=4;
FILE# STATUS                  CHANGE# TIME
----- ------------------ ------------ -------------------
    4 ACTIVE              13277546699 2018-04-13 09:16:22

SYS@book> alter system archive log current ;
System altered.

SYS@book> alter system archive log current ;
System altered.

SYS@book> alter system archive log current ;
System altered.

SYS@book> alter system archive log current ;
System altered.

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

SYS@book> column name format a52
SYS@book> select NAME,SEQUENCE#,FIRST_CHANGE#,NEXT_CHANGE#,COMPLETION_TIME from v$archived_log where dest_id=1 and SEQUENCE#>=743;
NAME                                                    SEQUENCE# FIRST_CHANGE# NEXT_CHANGE# COMPLETION_TIME
---------------------------------------------------- ------------ ------------- ------------ -------------------
/u01/app/oracle/archivelog/book/1_743_896605872.dbf           743   13277475418  13277507502 2018-04-13 04:48:00
/u01/app/oracle/archivelog/book/1_744_896605872.dbf           744   13277507502  13277546258 2018-04-13 09:14:09
/u01/app/oracle/archivelog/book/1_745_896605872.dbf           745   13277546258  13277546740 2018-04-13 09:16:54
/u01/app/oracle/archivelog/book/1_746_896605872.dbf           746   13277546740  13277546745 2018-04-13 09:16:55
/u01/app/oracle/archivelog/book/1_747_896605872.dbf           747   13277546745  13277546752 2018-04-13 09:16:59
/u01/app/oracle/archivelog/book/1_748_896605872.dbf           748   13277546752  13277546757 2018-04-13 09:17:01
6 rows selected.

SYS@book> alter system checkpoint ;
System altered.

SYS@book> SELECT file#, CHECKPOINT_CHANGE#,CHECKPOINT_TIME,UNRECOVERABLE_CHANGE#,UNRECOVERABLE_TIME,LAST_CHANGE#,LAST_TIME, OFFLINE_CHANGE#, ONLINE_CHANGE#,FIRST_NONLOGGED_SCN,FIRST_NONLOGGED_TIME,status,name FROM v$datafile;
FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME     UNRECOVERABLE_CHANGE# UNRECOVERABLE_TIME  LAST_CHANGE# LAST_TIME           OFFLINE_CHANGE# ONLINE_CHANGE# FIRST_NONLOGGED_SCN FIRST_NONLOGGED_TIM STATUS  NAME
----- ------------------ ------------------- --------------------- ------------------- ------------ ------------------- --------------- -------------- ------------------- ------------------- ------- --------------------------------------------------
    1        13277547058 2018-04-13 09:21:36                     0                                                               925701         925702                   0                     SYSTEM  /mnt/ramdisk/book/system01.dbf
    2        13277547058 2018-04-13 09:21:36                     0                                                               925701         925702                   0                     ONLINE  /mnt/ramdisk/book/sysaux01.dbf
    3        13277547058 2018-04-13 09:21:36                     0                                                               925701         925702                   0                     ONLINE  /mnt/ramdisk/book/undotbs01.dbf
    4        13277546699 2018-04-13 09:16:22                     0                                                               925701         925702                   0                     ONLINE  /mnt/ramdisk/book/users01.dbf
    5        13277547058 2018-04-13 09:21:36           13274819965 2017-01-16 22:00:05                                           952916         952921                   0                     ONLINE  /mnt/ramdisk/book/example01.dbf
    6        13277547058 2018-04-13 09:21:36                     0                                                                    0              0                   0                     ONLINE  /mnt/ramdisk/book/tea01.dbf
6 rows selected.

SYS@book> SELECT file#, CHECKPOINT_CHANGE#, CHECKPOINT_TIME,CREATION_CHANGE#  , RESETLOGS_CHANGE#,status, CHECKPOINT_COUNT,fuzzy,name,tablespace_name  FROM v$datafile_header;
FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME     CREATION_CHANGE# RESETLOGS_CHANGE# STATUS  CHECKPOINT_COUNT FUZ NAME                                               TABLESPACE_NAME
----- ------------------ ------------------- ---------------- ----------------- ------- ---------------- --- -------------------------------------------------- ------------------------------
    1        13277547058 2018-04-13 09:21:36                7            925702 ONLINE               922 YES /mnt/ramdisk/book/system01.dbf                     SYSTEM
    2        13277547058 2018-04-13 09:21:36             1834            925702 ONLINE               911 YES /mnt/ramdisk/book/sysaux01.dbf                     SYSAUX
    3        13277547058 2018-04-13 09:21:36           923328            925702 ONLINE               832 YES /mnt/ramdisk/book/undotbs01.dbf                    UNDOTBS1
    4        13277546699 2018-04-13 09:16:22            16143            925702 ONLINE               918 YES /mnt/ramdisk/book/users01.dbf                      USERS
    5        13277547058 2018-04-13 09:21:36           952916            925702 ONLINE               827 YES /mnt/ramdisk/book/example01.dbf                    EXAMPLE
    6        13277547058 2018-04-13 09:21:36      13276257767            925702 ONLINE               295 YES /mnt/ramdisk/book/tea01.dbf                        TEA
6 rows selected.
--//可以发现数据文件4的文件头scn被冻结,scn=13277546699,控制文件记录的也是13277546699.
--//移出其中的一个归档看看.seq=748.
$ mv /u01/app/oracle/archivelog/book/1_748_896605872.dbf /u01/app/oracle/archivelog/book/1_748_896605872.dbf_xxx

SYS@book> shutdown abort ;
ORACLE instance shut down.
SYS@book> startup
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.
ORA-10873: file 4 needs to be either taken out of backup mode or media recovered
ORA-01110: data file 4: '/mnt/ramdisk/book/users01.dbf'

SYS@book> recover datafile 4;
ORA-00279: change 13277567601 generated at 04/13/2018 09:28:36 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/archivelog/book/1_750_896605872.dbf
ORA-00280: change 13277567601 for thread 1 is in sequence #750
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
--//注:recover datafile 4;是补做的,也就是选择recover datafile如果归档不在无法继续.

SYS@book> alter database end   backup ;
Database altered.

--//OK.没有问题.使用recover datafile有问题.
--//总之,不再建议在采用热备模式管理oracle的备份.

目录
相关文章
|
Oracle 关系型数据库 数据库管理
[20180413]热备模式相关问题2.txt
[20180413]热备模式相关问题2.txt --//上午测试热备模式相关问题,就是如果打开热备模式,如果中间的归档丢失,oracle在alter database end   backup ;时并没有应用日志.
822 0
|
SQL Oracle 关系型数据库
[20171225]没有备份数据文件的恢复.txt
[20171225]没有备份数据文件的恢复.txt --//别人问的问题,增加了数据文件没有备份,如何恢复,实际上很简单,因为当前控制文件有记录建立时间只要从建立数据文件开始的 --//归档日志都存在恢复是没有任何问题的.
912 0
|
Oracle 关系型数据库 数据库
[20171122]恢复数据文件块头5.txt
[20171122]恢复数据文件块头5.txt --//前几天做了恢复数据文件块头,通过备份文件直接取出文件块头,覆盖原来的数据块,然后修复. --//今天测试使用image copy来恢复.
1123 0
|
负载均衡
|
Oracle 关系型数据库 数据库
[20171114]恢复数据文件块头2.txt
[20171114]恢复数据文件块头2.txt --//曾经写过一篇[20161111]数据库文件头的修复.txt,但是利用大小相似的数据文件头覆盖来恢复,那是属于特种恢复.
1082 0
|
Oracle 关系型数据库 数据库
[20171031]rman备份压缩模式.txt
[20171031]rman备份压缩模式.txt --//测试rman备份压缩模式,那种效果好,我记忆里选择medium在备份时间和备份文件大小综合考虑最佳. --//还是通过脚本测试: 1.
1242 0
|
Oracle 关系型数据库
[20170725]关于备份集与备份片.txt
[20170725]关于备份集与备份片.txt --//以前学习rman对于备份集与备份片这个概念也不是很清晰. --//备份片(BACKUPPIECE)表示一个由RMAN产生备份的文件.
874 0
|
SQL Oracle 关系型数据库
[20170105]关于使用datafilecopy恢复.txt
[20170105]关于使用datafilecopy恢复.txt --如果指定恢复数据文件是从datafilecopy,必须加括号,写一个例子说明: 1.环境: SYS@book> @ &r/ver1 PORT_STRING             ...
1047 0