dg1

[oracle@dg1 arch]$ ls -rtl

-rw-r—– 1 oracle oinstall      12800 Nov 15 13:44 1_174_923589103.dbf

-rw-r—– 1 oracle oinstall      61952 Nov 15 13:49 1_175_923589103.dbf

-rw-r—– 1 oracle oinstall       7168 Nov 16 07:59 1_176_923589103.dbf

-rw-r—– 1 oracle oinstall     896512 Nov 16 08:01 1_177_923589103.dbf

-rw-r—– 1 oracle oinstall    3692032 Nov 16 08:06 1_178_923589103.dbf

-rw-r—– 1 oracle oinstall    1393664 Nov 16 08:11 1_179_923589103.dbf

-rw-r—– 1 oracle oinstall     338944 Nov 16 08:16 1_180_923589103.dbf

-rw-r—– 1 oracle oinstall     530944 Nov 16 08:21 1_181_923589103.dbf

-rw-r—– 1 oracle oinstall      36352 Nov 16 08:26 1_182_923589103.dbf

-rw-r—– 1 oracle oinstall    3706880 Nov 16 08:31 1_183_923589103.dbf

-rw-r—– 1 oracle oinstall      29184 Nov 16 08:36 1_184_923589103.dbf

-rw-r—– 1 oracle oinstall     116224 Nov 16 08:41 1_185_923589103.dbf

-rw-r—– 1 oracle oinstall      10752 Nov 16 08:46 1_186_923589103.dbf

-rw-r—– 1 oracle oinstall      16384 Nov 16 08:51 1_187_923589103.dbf

-rw-r—– 1 oracle oinstall       5120 Nov 16 08:56 1_188_923589103.dbf

-rw-r—– 1 oracle oinstall    1235968 Nov 16 09:01 1_189_923589103.dbf

-rw-r—– 1 oracle oinstall      24576 Nov 16 09:06 1_190_923589103.dbf

-rw-r—– 1 oracle oinstall      11776 Nov 16 09:11 1_191_923589103.dbf

-rw-r—– 1 oracle oinstall       4608 Nov 16 09:16 1_192_923589103.dbf

-rw-r—– 1 oracle oinstall     327680 Nov 16 09:21 1_193_923589103.dbf

 

dg2

[oracle@dg2 arch]$ rm -rf 1_18*

[oracle@dg2 arch]$ ls rtl

-rw-r—– 1 oracle oinstall      16896 Dec  6 09:25 1_173_923589103.dbf

-rw-r—– 1 oracle oinstall      12800 Dec  6 09:25 1_174_923589103.dbf

-rw-r—– 1 oracle oinstall       7168 Dec  6 09:25 1_176_923589103.dbf

-rw-r—– 1 oracle oinstall      61952 Dec  6 09:25 1_175_923589103.dbf

-rw-r—– 1 oracle oinstall     896512 Dec  6 09:25 1_177_923589103.dbf

-rw-r—– 1 oracle oinstall    1393664 Dec  6 09:25 1_179_923589103.dbf

-rw-r—– 1 oracle oinstall    3692032 Dec  6 09:25 1_178_923589103.dbf

-rw-r—– 1 oracle oinstall      24576 Dec  6 09:25 1_190_923589103.dbf

-rw-r—– 1 oracle oinstall      11776 Dec  6 09:25 1_191_923589103.dbf

-rw-r—– 1 oracle oinstall       4608 Dec  6 09:25 1_192_923589103.dbf

-rw-r—– 1 oracle oinstall       5632 Dec  6 09:25 1_194_923589103.dbf

-rw-r—– 1 oracle oinstall      12288 Dec  6 09:25 1_195_923589103.dbf

-rw-r—– 1 oracle oinstall     327680 Dec  6 09:25 1_193_923589103.dbf

 

备库上查看丢失的归档:

SQL> SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;

 

   THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#

———- ————- ————–

         1           140            155

备库查看丢失归档时的最小scn号:

SQL> select current_scn from v$database;

 

CURRENT_SCN

———–

1146993

SQL> select min(fhscn) from x$kcvfh;

 

MIN(FHSCN)

—————-

1146994

 

在主库以最小SCN号以RMAN创建增量备份:

[oracle@dg1 ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 – Production on Tue Dec 6 07:02:32 2016

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: CREDIT (DBID=3927758956)

RMAN> backup  incremental from scn 1146993 database  format'/rman/bak_%U%t'tag'forstandby';

 

Starting backup at 06-DEC-16

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=144 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=/oracle/app/oradata/credit/system01.dbf

input datafile file number=00002 name=/oracle/app/oradata/credit/sysaux01.dbf

input datafile file number=00003 name=/oracle/app/oradata/credit/undotbs01.dbf

input datafile file number=00004 name=/oracle/app/oradata/credit/users01.dbf

channel ORA_DISK_1: starting piece 1 at 06-DEC-16

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03009: failure of backup command on ORA_DISK_1 channel at 12/06/2016 07:26:47

ORA-19502: write error on file "/rman/bak_16rmp5tk_1_1929863604", block number 1152 (block size=8192)

ORA-27072: File I/O error

Additional information: 4

Additional information: 1152

Additional information: 303104

报错I/O错误

[oracle@dg1 ~]$ df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda3              16G   15G  9.4M 100% /

tmpfs                 932M  231M  702M  25% /dev/shm

/dev/sda1             2.0G   90M  1.8G   5% /boot

发现,空间不足导致的I/O错误

 

创建一块磁盘挂载到/rman

[root@dg1 ~]# mount /dev/sdb /rman

[root@dg1 ~]# chown -R oracle:oinstall /rman

[root@dg1 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda3              16G   14G  1.1G  93% /

tmpfs                 932M   72K  931M   1% /dev/shm

/dev/sda1             2.0G   90M  1.8G   5% /boot

/dev/sdb               20G  172M   19G   1% /rman

 

再运行命令

[oracle@dg1 ~]$ rman target /

 

Recovery Manager: Release 11.2.0.4.0 – Production on Tue Dec 6 08:02:20 2016

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: CREDIT (DBID=3927758956)

 

RMAN> backup  incremental from scn 1146993 database  format'/rman/bak_%U%t';

 

Starting backup at 06-DEC-16

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=144 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=/oracle/app/oradata/credit/system01.dbf

input datafile file number=00002 name=/oracle/app/oradata/credit/sysaux01.dbf

input datafile file number=00003 name=/oracle/app/oradata/credit/undotbs01.dbf

input datafile file number=00004 name=/oracle/app/oradata/credit/users01.dbf

channel ORA_DISK_1: starting piece 1 at 06-DEC-16

channel ORA_DISK_1: finished piece 1 at 06-DEC-16

piece handle=/rman/bak_18rmp811_1_1929865761 tag=TAG20161206T080240 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

channel ORA_DISK_1: starting piece 1 at 06-DEC-16

channel ORA_DISK_1: finished piece 1 at 06-DEC-16

piece handle=/rman/bak_19rmp824_1_1929865796 tag=TAG20161206T080240 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-DEC-16

 

拷贝备份到备库

[oracle@dg1 rman]$ ll

total 63344

-rw-r—– 1 oracle oinstall 54132736 Dec  6 08:03 bak_18rmp811_1_1929865761

-rw-r—– 1 oracle oinstall 10715136 Dec  6 08:03 bak_19rmp824_1_1929865796

drwx—— 2 oracle oinstall    16384 Dec  6 07:44 lost+found

[oracle@dg1 rman]$ scp bak_18rmp811_1_1929865761  192.168.40.38:/oracle

oracle@192.168.40.38's password:

bak_18rmp811_1_1929865761                             100%   52MB  51.6MB/s   00:01   

[oracle@dg1 rman]$ scp bak_19rmp824_1_1929865796  192.168.40.38:/oracle

oracle@192.168.40.38's password:

bak_19rmp824_1_1929865796                             100%   10MB  10.2MB/s   00:00

在主库创建新的控制文件

SQL> ALTER DATABASE CREATE standby controlfile AS '/home/oracle/standby.ctl';

Database altered.

拷贝到备库:

[oracle@dg1 rman]$ scp /home/oracle/standby.ctl  192.168.40.38:/home/oracle/

oracle@192.168.40.38's password:

standby.ctl                                           100%   10MB  10.2MB/s   viagra feminin forum generique 00:00

 

 

备库启动到nomount状态:

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup nomount

ORACLE instance started.

 

Total System Global Area  776646656 bytes

Fixed Size                  2257272 bytes

Variable Size             507514504 bytes

Database Buffers          260046848 bytes

Redo Buffers                6828032 bytes

备库上通过rman恢复控制文件

 

RMAN> restore controlfile from'/oracle/standby.ctl';

 

Starting restore at 06-DEC-16

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 12/06/2016 14:52:50

ORA-03114: not connected to ORACLE

出现这个问题的原因是我的数据库状态是在另外一个窗口更改的,而rman未更新过数据库状态

当我退出rman并重新进入,再运行命令即可

 

RMAN> exit

Recovery Manager complete.

[oracle@dg2 ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 – Production on Tue Dec 6 15:09:10 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: CREDIT (not mounted)

 

RMAN> restore controlfile from '/oracle/standby.ctl';

Starting restore at 06-DEC-16

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=10 device type=DISK

channel ORA_DISK_1: copied control file copy

output file name=/oracle/app/oradata/credit/control01.ctl

Finished restore at 06-DEC-16

 

备库更改到mount状态

SQL> alter database mount

Database altered.

RMAN> list backup;

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

——- —- — ———- ———– ———— —————

21      Incr 0  1.01G      DISK        00:02:45     06-DEC-16     

        BP Key: 21   Status: AVAILABLE  Compressed: NO  Tag: TAG20161206T070735

        Piece Name: /rman/bak_11rmp4po_1_1

  List of Datafiles in backup set 21

  File LV Type Ckp SCN    Ckp Time  Name

  —- — —- ———- ——— —-

  1    0  Incr 1433264    06-DEC-16 /oracle/app/oradata/credit/system01.dbf

  2    0  Incr 1433264    06-DEC-16 /oracle/app/oradata/credit/sysaux01.dbf

  3    0  Incr 1433264    06-DEC-16 /oracle/app/oradata/credit/undotbs01.dbf

  4    0  Incr 1433264    06-DEC-16 /oracle/app/oradata/credit/users01.dbf

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

——- —- — ———- ———– ———— —————

22      Incr 0  10.23M     DISK        00:00:03     06-DEC-16     

        BP Key: 22   Status: AVAILABLE  Compressed: NO  Tag: TAG20161206T070735

        Piece Name: /rman/bak_12rmp4v0_1_1

  SPFILE Included: Modification time: 06-DEC-16

  SPFILE db_unique_name: CREDIT

  Control File Included: Ckp SCN: 1433328      Ckp time: 06-DEC-16

 

catalog中注册备份片

RMAN> CATALOG START WITH '/oracle/bak_18rmp811_1_1929865761';

 

searching for all files that match the pattern /oracle/bak_18rmp811_1_1929865761

 

List of Files Unknown to the Database

=====================================

File Name: /oracle/bak_18rmp811_1_1929865761

 

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files…

cataloging done

 

List of Cataloged Files

=======================

File Name: /oracle/bak_18rmp811_1_1929865761

 

RMAN> CATALOG START WITH '/oracle/bak_19rmp824_1_1929865796';

 

searching for all files that match the pattern /oracle/bak_19rmp824_1_1929865796

 

List of Files Unknown to the Database

=====================================

File Name: /oracle/bak_19rmp824_1_1929865796

 

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files…

cataloging done

 

List of Cataloged Files

=======================

File Name: /oracle/bak_19rmp824_1_1929865796

 

恢复数据库

RMAN> recover database;

 

Starting recover at 06-DEC-16

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=10 device type=DISK

 

starting media recovery

……

archived log file name=/arch/1_177_923589103.dbf thread=1 sequence=177

archived log file name=/arch/1_178_923589103.dbf thread=1 sequence=178

archived log file name=/arch/1_179_923589103.dbf thread=1 sequence=179

archived log file name=/arch/1_180_923589103.dbf thread=1 sequence=180

archived log file name=/arch/1_181_923589103.dbf thread=1 sequence=181

archived log file name=/arch/1_182_923589103.dbf thread=1 sequence=182

archived log file name=/arch/1_183_923589103.dbf thread=1 sequence=183

archived log file name=/arch/1_184_923589103.dbf thread=1 sequence=184

archived log file name=/arch/1_185_923589103.dbf thread=1 sequence=185

archived log file name=/arch/1_186_923589103.dbf thread=1 sequence=186

archived log file name=/arch/1_187_923589103.dbf thread=1 sequence=187

archived log file name=/arch/1_188_923589103.dbf thread=1 sequence=188

archived log file name=/arch/1_189_923589103.dbf thread=1 sequence=189

archived log file name=/arch/1_190_923589103.dbf thread=1 sequence=190

archived log file name=/arch/1_191_923589103.dbf thread=1 sequence=191

archived log file name=/arch/1_192_923589103.dbf thread=1 sequence=192

……

可以发现原来被删除的180-189号归档被恢复

[root@dg2 trace]# cd /arch/

[root@dg2 arch]# ls -rtl

total 1244276

-rw-r—– 1 oracle oinstall      12288 Nov  7 14:17 1_177_923589103.dbf

-rw-r—– 1 oracle oinstall     839680 Nov  7 14:17 1_178_923589103.dbf

-rw-r—– 1 oracle oinstall     437760 Nov  7 14:17 1_179_923589103.dbf

-rw-r—– 1 oracle oinstall       9728 Nov  7 14:17 1_180_923589103.dbf

-rw-r—– 1 oracle oinstall       6656 Nov  7 14:17 1_181_923589103.dbf

-rw-r—– 1 oracle oinstall     256512 Nov  7 14:17 1_183_923589103.dbf

-rw-r—– 1 oracle oinstall      27136 Nov  7 14:17 1_184_923589103.dbf

-rw-r—– 1 oracle oinstall    1297408 Nov  7 14:17 1_185_923589103.dbf

-rw-r—– 1 oracle oinstall     310784 Nov  7 14:17 1_186_923589103.dbf

-rw-r—– 1 oracle oinstall      19456 Nov  7 14:17 1_187_923589103.dbf

-rw-r—– 1 oracle oinstall    8738304 Nov  7 14:17 1_182_923589103.dbf

-rw-r—– 1 oracle oinstall       9728 Nov  7 14:17 1_188_923589103.dbf

-rw-r—– 1 oracle oinstall      46592 Nov  7 14:17 1_189_923589103.dbf

-rw-r—– 1 oracle oinstall       8192 Nov  7 14:17 1_190_923589103.dbf

 

在备库上重新启动应用日志:

 SQL>ALTER DATABASE recover managed standby DATABASE disconnect FROM SESSION; 

 

 

主库打开,切换日志:

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

 

Total System Global Area  776646656 bytes

Fixed Size                  2257272 bytes

Variable Size             507514504 bytes

Database Buffers          260046848 bytes

Redo Buffers                6828032 bytes

Database mounted.

Database opened.

SQL> alter system switch logfile;

 

System altered.

 

SQL> select max(sequence#) from v$archived_log;

 

MAX(SEQUENCE#)

————–

           501

 

备库端alert日志查看:

[root@dg2 trace]# tail -f alert_credit.log

Tue Dec 06 15:44:13 2016

RFS[2]: Assigned to RFS process 5944

RFS[2]: Opened log for thread 1 sequence 498 dbid -367208340 branch 923589103

Tue Dec 06 15:44:13 2016

RFS[3]: Assigned to RFS process 5946

RFS[3]: Opened log for thread 1 sequence 500 dbid -367208340 branch 923589103

Archived Log entry 165 added for thread 1 sequence 498 rlc 923589103 ID 0xea442912 dest 2:

Archived Log entry 166 added for thread 1 sequence 500 rlc 923589103 ID 0xea442912 dest 2:

Tue Dec 06 15:44:51 2016

RFS[4]: Assigned to RFS process 5955

RFS[4]: Opened log for thread 1 sequence 501 dbid -367208340 branch 923589103

Archived Log entry 167 added for thread 1 sequence 501 rlc 923589103 ID 0xea442912 dest 2:

 

 

备库在应用,恢复成功。




Related posts

coded by nessus
分享:  DeliciousGReader鲜果豆瓣CSDN网摘
Trackback

no comment untill now

Add your comment now

无觅相关文章插件