RAC_RMAN冷備份

1.環境說明

    os: linux

    db:oracle rac 11g/12c

2.冷備份遇到的問題

2.1現象,執行備份失敗

RMAN> backup  database format '/home/oracle/data_%d_%I_%s_%p_%T.bak';
Starting backup at 26-MAR-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=691 instance=orcl1 device type=DISK
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/26/2018 09:12:03
ORA-01138: database must either be open in this instance or not at all
continuing other job steps, job failed will not be re-run
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/26/2018 09:12:03
ORA-01138: database must either be open in this instance or not at all
continuing other job steps, job failed will not be re-run
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/26/2018 09:12:03
ORA-01138: database must either be open in this instance or not at all

2.2原因描述

備份步驟:在RAC環境中,使用節點1,sqplus關閉數據庫==>啓動數據庫到mount狀態==>執行以上備份失敗

實際原因:在節點1執行了關閉數據庫的狀態,僅是實例1的狀態切換從open->shutdown->mount狀態,實際上實例2的狀態一直是open狀態


1)查看當前數據庫狀態:

[grid@node1 ~]$crsctl status res -t
-
NAME           TARGET  STATE        SERVER    STATE_DETAILS
ora.orcl.db
      1       ONLINE  ONLINE         node1      Open

                       
      2       ONLINE  ONLINE        node2      Open  

2)節點1使用sqlplus關閉數據庫
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

3)查看數據庫狀態

[grid@node1 ~]$crsctl status res -t
-
NAME           TARGET  STATE        SERVER      STATE_DETAILS
ora.orcl.db
      1        OFFLINE OFFLINE      node1      Instance Shutdown

 
      2        ONLINE  ONLINE       node2      Open                            
4)節點1啓動數據庫到mount狀態
SQL>startup mount;
ORACLE instance started.
Total System Global Area  477073408 bytes
Fixed Size                  1345744 bytes
Variable Size             226494256 bytes
Database Buffers          243269632 bytes
Redo Buffers                5963776 bytes
Database mounted.
SQL>select open_mode from v$database;
OPEN_MODE
--------------------
MOUNTED
SQL>
5)查看數據庫狀態

[grid@node1 ~]$crsctl status res -t
NAME           TARGET  STATE        SERVER       STATE_DETAILS
ora.orcl.db
      1        ONLINE  INTERMEDIATE     node1       Mounted (Closed)   
      2        ONLINE  ONLINE       node2       Open  

6)此時在節點1使用RMAN執行數據庫的備份,會報2.1的錯誤     


3.正確執行冷備份步驟如下

3.1檢查數據庫狀態

[grid@node1 ~]$srvctl status database -d orcl
Instance orcl1 is running on node node1
Instance orcl2 is running on node node

3.2關閉數據庫、
[grid@node1 ~]$srvctl stop database -d orcl -o immediate

3.3檢查數據庫狀態
[grid@node1 ~]$srvctl status database -d orcl
Instance orcl1 is not running on node node1
Instance orcl2 is not running on node node2

3.4啓動節點1實例到mount狀態
[grid@node1 ~]$srvctl start instance -d orcl -i orcl1 -o mount

3.5檢查數據庫狀態

[grid@node1 ~]$srvctl status database -d orcl
Instance orcl1 is running on node node1
Instance orcl2 is not running on node node2
[grid@node1 ~]$

3.6在節點1執行數據庫的冷備份


[root@node1 ~]#su - oracle
[oracle@node1 ~]$ .oraenv
-bash: .oraenv: command not found
[oracle@node1 ~]$ . oraenv
ORACLE_SID = [oracle] ? orcl1
ORACLE_HOME = [/home/oracle] ? /u01/app/oracle
ORACLE_BASE environment variable is not being set since this
information is not available for the current user ID oracle.
You can set ORACLE_BASE manually if it is required.
[oracle@node1 ~]$vi /etc/oratab
[oracle@node1 ~]$ . oraenv
ORACLE_SID = [orcl1] ? orcl1
The Oracle base has been set to /u01/app/oracle
[oracle@node1 ~]$rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Mar 27 09:38:28 2018

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

connected to target database: ORCL (DBID=1499601137, not open)

RMAN> run
{
allocate channel ch_c1 device type disk maxpiecesize=30G;
2> backup   database format '/home/oracle/data_%d_%I_%s_%p_%T.bak';
backup spfile format '/home/oracle/spfile_%d_%I_%s_%p_%T.bak';
backup current controlfile format '/home/oracle/ctrl_%d_%I_%s_%p_%T.bak';
release channel ch_c1;
3> 4> }5> 6> 7> 8>

using target database control file instead of recovery catalog
allocated channel: ch_c1
channel ch_c1: SID=37 instance=orcl1 device type=DISK

Starting backup at 27-MAR-18
channel ch_c1: starting full datafile backup set
channel ch_c1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/orcl/datafile/system.256.971820183
input datafile file number=00002 name=+DATA/orcl/datafile/sysaux.257.971820183
input datafile file number=00005 name=+DATA/orcl/datafile/example.264.971820435
input datafile file number=00003 name=+DATA/orcl/datafile/undotbs1.258.971820183
input datafile file number=00006 name=+DATA/orcl/datafile/undotbs2.265.971820693
input datafile file number=00004 name=+DATA/orcl/datafile/users.259.971820185
channel ch_c1: starting piece 1 at 27-MAR-18
channel ch_c1: finished piece 1 at 27-MAR-18
piece handle=/home/oracle/data_ORCL_1499601137_1_1_20180327.bak tag=TAG20180327T094050 comment=NONE
channel ch_c1: backup set complete, elapsed time: 00:01:54
channel ch_c1: starting full datafile backup set
channel ch_c1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ch_c1: starting piece 1 at 27-MAR-18
channel ch_c1: finished piece 1 at 27-MAR-18
piece handle=/home/oracle/data_ORCL_1499601137_2_1_20180327.bak tag=TAG20180327T094050 comment=NONE
channel ch_c1: backup set complete, elapsed time: 00:00:03
Finished backup at 27-MAR-18

Starting backup at 27-MAR-18
channel ch_c1: starting full datafile backup set
channel ch_c1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ch_c1: starting piece 1 at 27-MAR-18
channel ch_c1: finished piece 1 at 27-MAR-18
piece handle=/home/oracle/spfile_ORCL_1499601137_3_1_20180327.bak tag=TAG20180327T094258 comment=NONE
channel ch_c1: backup set complete, elapsed time: 00:00:01
Finished backup at 27-MAR-18

Starting backup at 27-MAR-18
channel ch_c1: starting full datafile backup set
channel ch_c1: specifying datafile(s) in backup set
including current control file in backup set
channel ch_c1: starting piece 1 at 27-MAR-18
channel ch_c1: finished piece 1 at 27-MAR-18
piece handle=/home/oracle/ctrl_ORCL_1499601137_4_1_20180327.bak tag=TAG20180327T094259 comment=NONE
channel ch_c1: backup set complete, elapsed time: 00:00:03
Finished backup at 27-MAR-18

released channel: ch_c1

RMAN>

3.7恢復數據庫open狀態

節點1數據庫狀態
[grid@node1 ~]$ . oraenv
ORACLE_SID = [grid] ? +ASM1
The Oracle base has been set to /u01/app/grid
[grid@node1 ~]$srvctl status database -d orcl
Instance orcl1 is running on node node1
Instance orcl2 is not running on node node2
[grid@node1 ~]$srvctl start instance -d orcl -i orcl2  -o open(啓動到mount狀態的數據庫,使用該命令也僅能啓動到mount狀態)[grid@node1 ~]$srvctl status database -d orcl
Instance orcl1 is running on node node1
Instance orcl2 is running on node node2
[grid@node1 ~]$exit
logout

[root@node1 oracle]#su - oracle
[oracle@node1 ~]$. oraenv
ORACLE_SID = [oracle] ? orcl1
The Oracle base has been set to /u01/app/oracle
[oracle@node1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Tue Mar 27 09:54:22 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL>select open_mode from v$database;

OPEN_MODE
--------------------
MOUNTED

SQL>alter database open;

Database altered.

SQL>select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

SQL>
節點2查看數據庫狀態
[oracle@node2 ~]$. oraenv
ORACLE_SID = [orcl2] ?
The Oracle base has been set to /u01/app/oracle
[oracle@node2 ~]$sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Tue Mar 27 09:56:34 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL>select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

SQL>








   

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章