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>