标签 rman 下的文章

ORA-00257报错处理

用户反映NC测试库不能连接,报ORA-00257错误,截图如下:
ORA-00257.png
错误原因是很常见的‘归档日志’写满‘快闪恢复区’(flash recovery area)导致的问题。解决方法如下:
一、删除过期的归档文件;
二、修改快闪恢复区(flash recovery area)的大小;





---阅读剩余部分---

expdp/impdp/rman会话进度查看

oracle11g使用DBA_DATAPUBMP_JOBS和DBA_DATAPUMP_SESSIONS视图来显示数据泵取作业的信息,
查看expdp进度:

select * from DBA_DATAPUBMP_JOBS;
select * from DBA_DATAPUMP_SESSIONS;
select sid,serial# from v$session s,dba_datapump_sessions d where s.saddr=d.saddr;

查看impdp进度:

SELECT   a.tablespace_name,
         ROUND (a.total_size) "total_size(MB)",
         ROUND (a.total_size) - ROUND (b.free_size, 3) "used_size(MB)",
         ROUND (b.free_size, 3) "free_size(MB)",
         ROUND (b.free_size / total_size * 100, 2) || '%' free_rate
  FROM   (  SELECT   tablespace_name, SUM (bytes) / 1024 / 1024 total_size
              FROM   dba_data_files
          GROUP BY   tablespace_name) a,
         (  SELECT   tablespace_name, SUM (bytes) / 1024 / 1024 free_size
              FROM   dba_free_space
          GROUP BY   tablespace_name) b
 WHERE   a.tablespace_name = b.tablespace_name(+);

查看RMAN备份进度:

SELECT SID,OPNAME, SERIAL#, CONTEXT, SOFAR, TOTALWORK,
ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE"
FROM V$SESSION_LONGOPS
WHERE OPNAME LIKE 'RMAN%'
AND OPNAME NOT LIKE '%aggregate%'
AND TOTALWORK != 0
AND SOFAR <> TOTALWORK
order by "%_COMPLETE"
desc

Oracle RMAN控制文件备份

进入RMAN界面

rman target /
 
RMAN>
修改控制文件备份方式为自动备份
RMAN > configure controlfile autobackup on;
查看控制文件备份是否为自动备份
RMAN > show controlfile autobackup;
查看控制文件自动备份路径
RMAN> show controlfile autobackup format;
修改控制文件自动备份路径
RMAN > configure controlfile autobackup format for device type disk to '/backup/orcl/%F';
注意%F是DBID+日期,可以用来识别时间及DBID

Oracle在非归档模式下RMAN的备份和恢复

1、Oracle数据库在非归档模式下的备份:

[oracle@dbnode1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on 星期三 8月 8 21:24:39 2018

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

SQL> archive log list;   #查看是否启用归档模式
Database log mode           No Archive Mode
Automatic archival           Disabled
Archive destination           /home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/arch
Oldest online log sequence     31004
Current log sequence           31006

登录到rman下:

[oracle@dbnode1 ~]$ rman target /   #登录rman

Recovery Manager: Release 11.2.0.3.0 - Production on 星期三 8月 8 21:29:02 2018

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

connected to target database: ORCL (DBID=1351645873)
RMAN> shutdown immediate   #停掉数据库

using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down
RMAN>startup mount    #启动并挂载数据库,但是不打开

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area   25120276480 bytes

Fixed Size                     2240016 bytes
Variable Size              19193135600 bytes
Database Buffers            5905580032 bytes
Redo Buffers                  19320832 bytes
开始全量备份
RMAN> run
2> {
3> allocate channel t1 type disk;
4>  backup database format '/bak/rmanbak/20180808/df_%t_%s_%p.bak';
5> }

allocated channel: t1
channel t1: SID=518 device type=DISK

Starting backup at 08-8月 -18
channel t1: starting full datafile backup set
channel t1: specifying datafile(s) in backup set
input datafile file number=00005 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_data01.dbf
input datafile file number=00003 name=/home/oracle/app/oracle/oradata/ORCL/undotbs01.dbf
input datafile file number=00010 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_index03.dbf
input datafile file number=00007 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_data03.dbf
input datafile file number=00008 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_index01.dbf
input datafile file number=00013 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_data01b.dbf
input datafile file number=00006 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_data02.dbf
input datafile file number=00001 name=/home/oracle/app/oracle/oradata/ORCL/system01.dbf
input datafile file number=00012 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_data01a.dbf
input datafile file number=00002 name=/home/oracle/app/oracle/oradata/ORCL/sysaux01.dbf
input datafile file number=00009 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/nnc_index02.dbf
input datafile file number=00011 name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/IUFO.dbf
input datafile file number=00004 name=/home/oracle/app/oracle/oradata/ORCL/users01.dbf
channel t1: starting piece 1 at 08-8月 -18
channel t1: finished piece 1 at 08-8月 -18
piece handle=/bak/rmanbak/20180808/df_983655480_2_1.bak tag=TAG20180808T213800 comment=NONE
channel t1: backup set complete, elapsed time: 00:18:16
channel t1: starting full datafile backup set
channel t1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel t1: starting piece 1 at 08-8月 -18
channel t1: finished piece 1 at 08-8月 -18
piece handle=/bak/rmanbak/20180808/df_983656576_3_1.bak tag=TAG20180808T213800 comment=NONE
channel t1: backup set complete, elapsed time: 00:00:01
Finished backup at 08-8月 -18
released channel: t1
RMAN> alter database open;   #打开数据库

database opened

RMAN> 

2、非归档模式数据库恢复

RMAN> shutdown immediate    #停止数据库

database closed
database dismounted
Oracle instance shut down

RMAN> startup mount   #启动挂载数据库

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area 535662592 bytes

Fixed Size 1375792 bytes
Variable Size 411042256 bytes
Database Buffers 117440512 bytes
Redo Buffers 5804032 bytes

RMAN> restore database;    #恢复数据库

Starting restore at 03-NOV-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=133 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to D:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF
channel ORA_DISK_1: restoring datafile 00002 to D:\ORACLE\ORADATA\ORCL\SYSAUX01.DBF
channel ORA_DISK_1: restoring datafile 00004 to D:\ORACLE\ORADATA\ORCL\USERS01.DBF
channel ORA_DISK_1: restoring datafile 00005 to D:\ORACLE\ORADATA\ORCL\TEST01.DBF channel ORA_DISK_1: restoring datafile 00006 to D:\ORACLE\ORADATA\ORCL\UNDOTBS02.DBF
channel ORA_DISK_1: reading from backup piece E:\RMAN_BAK\20111103\DF_766235030_5_1.BAK
channel ORA_DISK_1: piece handle=E:\RMAN_BAK\20111103\DF_766235030_5_1.BAK tag=TAG20111103T110349
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:35
Finished restore at 03-NOV-11

RMAN> recover database;   #恢复数据库

Starting recover at 03-NOV-18
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 3246 is already on disk as file D:\ORACLE\ORADATA\ORCL\REDO03.LOG archived log for thread 1 with sequence 3247 is already on disk as file D:\ORACLE\ORADATA\ORCL\REDO01.LOG
archived log file name=D:\ORACLE\ORADATA\ORCL\REDO03.LOG thread=1 sequence=3246
archived log file name=D:\ORACLE\ORADATA\ORCL\REDO01.LOG thread=1 sequence=3247
media recovery complete, elapsed time: 00:00:09
Finished recover at 03-NOV-18
打开数据库进行读/写操作时,会立即完成刚刚执行的还原。因此,先先在READ ONLY模式下打开数据库并查看某些数据,检查恢复操作是否符合预期结果。
RMAN> SQL 'ALTER DATABASE OPEN READ ONLY';
#如对恢复结果感到满意,则使用RESETLOGS选项打开数据库
RMAN> alter database open resetlogs;   

database opened

VIA: https://blog.csdn.net/rlhua/article/details/12346829

RMAN连接数据库 多实例场景下需要指定SID

RMAN 是Oracle数据库软件自带的备份恢复工具,一种是类似于DOS,通过键盘操作的 命令行方式。

通过RMAN连接本地数据库非常简单,以 Windows 平台为例,进入到命令提示符界面:

C:/Documents and Settings/admin> SET ORACLE_SID =jssbook

C:/Documents and Settings/admin> RMAN TARGET /

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Mar 17 21:12:17 2009

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

connected to target database: JSSBOOK (DBID=1415261003)

RMAN>
如上所示,使用RMAN连接本地数据库之前必须首先设置操作系统环境变量:ORACLE_SID,并指定该值等于目标数据库的实例名。如果本地库只有一个实例并已经设置了ORACLE_SID环境变量,则不需要再指定ORACLE_SID。RMAN会自动连接到默认实例。

Linux/UNIX 环境下设置操作系统环境变量应使用 export 命令,另外ORACLE_SID必须为大写。例如:


---阅读剩余部分---

最新

分类

归档

评论

其它