标签 归档 下的文章

ORA-00257报错处理

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





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

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

ucloud归档(冷)存储使用及备份上传脚本

因业务需要对一些附件及数据进行冷备份,原服务器上有打包备份,直接在备份脚本中增加上传至ucloud的归档备份即可,
工具各版本下载地址及说明:https://docs.ucloud.cn/storage_cdn/uarchive/quick
这里用的是Linux版本直接命令行操作即可:
下载、解压、安装:

wget http://tools.ufile.ucloud.cn/uarchivemgr-linux64.tar.gz
tar xvf uarchivemgr-linux64.tar.gz
mv uarchivemgr_linux64.elf/ /usr/local/ubak
mv /usr/local/ubak/uarchivemgr-linux64 /usr/local/ubak/uarchivemgr
chmod +x /usr/local/ubak/uarchivemgr-linux64
mkdir /usr/local/ubak/log



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

Oracle删除归档日志

1、切换oracle用户

su - oracle

2、登录 ramn

rman target /

3、查看归档日志列表

RMAN> list archivelog all; 

查看失效的归档日志列表:

RMAN> list expired archivelog all;

4、删除归档日志

delete archivelog all completed before 'sysdate-10';    删除十天前的日志
delete force archivelog all completed before 'sysdate-10';  sysdate-10,表明当前的系统时间7天前,before关键字表示在10天前的归档日志。
delete archivelog all; 删除全部归档日志
delete noprompt force archivelog all; 日志爆了,用以上命令可能不起作用,行删除所有日志

5、删除物理文件不存在的归档日志

RMAN> crosscheck archivelog all; 检查控制文件和实际物理文件的差别。
RMAN> delete expired archivelog all; 同步控制文件的信息和实际物理文件的信息。

下面的命令用于校验归档日志的有效性,列出无效的归档日志,以及以何种方式清除归档日志,列出几种常用的:

DELETE NOPROMPT ARCHIVELOG UNTIL TIME "TO_DATE('XXXX-XX-XX','YYYY-MM-DD')";

delete noprompt archivelog until time "to_date('2016-09-14 18:00:00','YYYY-MM-DD ')"
    
crosscheck archivelog all;                            --->校验日志的可用性

list expired archivelog all;                          --->列出所有失效的归档日志

delete archivelog until sequence 16;                  --->删除log sequence为16及16之前的所有归档日志

delete archivelog all completed before 'sysdate-7';    --->删除系统时间7天以前的归档日志,不会删除闪回区有效的归档日志

delete archivelog all completed before 'sysdate - 1';  --->同上,1天以前的

delete archivelog from time 'sysdate-1';              --->注意这个命令,删除系统时间1天以内到现在的归档日志

delete noprompt archivelog all completed before 'sysdate';  --->该命令清除所有的归档日志

delete noprompt archivelog all;                              --->同上一命令  

Oracle配置归档日志模式log_archive_format的相关参数

归档日志(Archive Log)是非活动的重做日志备份.通过使用归档日志,可以保留所有重做历史记录,当数据库处于ARCHIVELOG模式并进行日志切换式,后台进程ARCH会将重做日志的内容保存到归档日志中.当数据库出现介质失败时,使用数据文件备份,归档日志和重做日志可以完全恢复数据库.
日志操作模式:ARCHIVELOG NOARCHIVELOG

检查当前日志操作模式

SELECT log_mode from v$database;

手工归档

从oracle database 10g开始,当将日志操作模式转变未ARCHIVELOG模式时,oracle会自动启动ARCH进程.如果要使用手工归档.那么在改变日志操作模式时必须使用命令ALTER DATABASE ARCHIVELOG MANUAL.

需要注意,使用手工归档方式,数据库管理员必须手工执行归档命令.如果没有执行手工归档命令,日志组的原有内容将不能被覆盖.ALTER DATABASE ARCHIVELOG MANUAL 命令是为了与先前的版本兼容而保留的,.将来的oracle版本会淘汰该命令,使用手工归档方式是,数据库管理员可以执行以下命令归档重做日志:

ALTER SYSTEM ARCHIVELOG ALL;

配置归档进程


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

Oracle开启归档模式及修改归档路径

Oracle10G和11G默认的日志归档路径为闪回恢复区($ORACLE_BASE/flash_recovery_area)。对于这个路径,ORACLE有一个限制,就是默认只有2G的空间,而且不只是归档日志的默认路径,也是备份文件和闪回日志的默认地址,这样的话归档日志锁使用的空间就达不到2G,在没有设置好这个路径大小的情况下,很多系统都遇到过 归档日志满而无法归档导致数据库夯住的问题。
切换到归档模式之前,做一次完全备份,因为非归档日志模式下产生的备份日志对于归档模式已经不可用了.

查看是否为归档模式

SQL> archive log list
Database log mode              No Archive Mode     #数据库日志模式             非存档模式
Automatic archival             Disabled            #自动存档             禁用
Archive destination            USE_DB_RECOVERY_FILE_DEST    #存档终点            USE_DB_RECOVERY_FILE_DES
Oldest online log sequence     13            #最早的联机日志序列        13
Current log sequence           15            #当前日志序列             15

上面的存档终点USE_DB_RECOVERY_FILE_DEST默认就是闪回恢复区($ORACLE_BASE/flash_recovery_area),可以通过下面的SQL查看闪回恢复区的信息。


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

最新

分类

归档

评论

其它