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-18using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=691 instance=orcl1 device type=DISKRMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/26/2018 09:12:03ORA-01138: database must either be open in this instance or not at allcontinuing other job steps, job failed will not be re-runRMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/26/2018 09:12:03ORA-01138: database must either be open in this instance or not at allcontinuing other job steps, job failed will not be re-runRMAN-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:03ORA-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 WRITESQL> 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 bytesFixed Size 1345744 bytesVariable Size 226494256 bytesDatabase Buffers 243269632 bytesRedo Buffers 5963776 bytesDatabase mounted.SQL>select open_mode from v$database;OPEN_MODE--------------------MOUNTEDSQL>5)查看数据库状态
[grid@node1 ~]$crsctl status res -tNAME 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 orclInstance orcl1 is running on node node1Instance 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 orclInstance orcl1 is not running on node node1Instance 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 orclInstance orcl1 is running on node node1Instance 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 ~]$ . oraenvORACLE_SID = [oracle] ? orcl1ORACLE_HOME = [/home/oracle] ? /u01/app/oracleORACLE_BASE environment variable is not being set since thisinformation 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 ~]$ . oraenvORACLE_SID = [orcl1] ? orcl1The 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 2018Copyright (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 catalogallocated channel: ch_c1channel ch_c1: SID=37 instance=orcl1 device type=DISKStarting backup at 27-MAR-18channel ch_c1: starting full datafile backup setchannel ch_c1: specifying datafile(s) in backup setinput datafile file number=00001 name=+DATA/orcl/datafile/system.256.971820183input datafile file number=00002 name=+DATA/orcl/datafile/sysaux.257.971820183input datafile file number=00005 name=+DATA/orcl/datafile/example.264.971820435input datafile file number=00003 name=+DATA/orcl/datafile/undotbs1.258.971820183input datafile file number=00006 name=+DATA/orcl/datafile/undotbs2.265.971820693input datafile file number=00004 name=+DATA/orcl/datafile/users.259.971820185channel ch_c1: starting piece 1 at 27-MAR-18channel ch_c1: finished piece 1 at 27-MAR-18piece handle=/home/oracle/data_ORCL_1499601137_1_1_20180327.bak tag=TAG20180327T094050 comment=NONEchannel ch_c1: backup set complete, elapsed time: 00:01:54channel ch_c1: starting full datafile backup setchannel ch_c1: specifying datafile(s) in backup setincluding current control file in backup setincluding current SPFILE in backup setchannel ch_c1: starting piece 1 at 27-MAR-18channel ch_c1: finished piece 1 at 27-MAR-18piece handle=/home/oracle/data_ORCL_1499601137_2_1_20180327.bak tag=TAG20180327T094050 comment=NONEchannel ch_c1: backup set complete, elapsed time: 00:00:03Finished backup at 27-MAR-18Starting backup at 27-MAR-18channel ch_c1: starting full datafile backup setchannel ch_c1: specifying datafile(s) in backup setincluding current SPFILE in backup setchannel ch_c1: starting piece 1 at 27-MAR-18channel ch_c1: finished piece 1 at 27-MAR-18piece handle=/home/oracle/spfile_ORCL_1499601137_3_1_20180327.bak tag=TAG20180327T094258 comment=NONEchannel ch_c1: backup set complete, elapsed time: 00:00:01Finished backup at 27-MAR-18Starting backup at 27-MAR-18channel ch_c1: starting full datafile backup setchannel ch_c1: specifying datafile(s) in backup setincluding current control file in backup setchannel ch_c1: starting piece 1 at 27-MAR-18channel ch_c1: finished piece 1 at 27-MAR-18piece handle=/home/oracle/ctrl_ORCL_1499601137_4_1_20180327.bak tag=TAG20180327T094259 comment=NONEchannel ch_c1: backup set complete, elapsed time: 00:00:03Finished backup at 27-MAR-18released channel: ch_c1RMAN>3.7恢复数据库open状态
节点1数据库状态[grid@node1 ~]$ . oraenvORACLE_SID = [grid] ? +ASM1The Oracle base has been set to /u01/app/grid[grid@node1 ~]$srvctl status database -d orclInstance orcl1 is running on node node1Instance 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 orclInstance orcl1 is running on node node1Instance orcl2 is running on node node2[grid@node1 ~]$exitlogout
[root@node1 oracle]#su - oracle[oracle@node1 ~]$. oraenvORACLE_SID = [oracle] ? orcl1The Oracle base has been set to /u01/app/oracle[oracle@node1 ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Tue Mar 27 09:54:22 2018Copyright (c) 1982, 2011, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Data Mining and Real Application Testing optionsSQL>select open_mode from v$database;OPEN_MODE--------------------MOUNTEDSQL>alter database open;Database altered.SQL>select open_mode from v$database;OPEN_MODE--------------------READ WRITESQL>节点2查看数据库状态[oracle@node2 ~]$. oraenvORACLE_SID = [orcl2] ?The Oracle base has been set to /u01/app/oracle[oracle@node2 ~]$sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Tue Mar 27 09:56:34 2018Copyright (c) 1982, 2011, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Data Mining and Real Application Testing optionsSQL>select open_mode from v$database;OPEN_MODE--------------------READ WRITESQL>