欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

Oracle数据库服务器磁盘满导致数据库无法登陆,通过清理归档文件解决

程序员文章站 2022-05-07 14:14:38
...

测试部门发生了多次数据库服务器空间满而导致无法登陆oracle实例的事情,在此特地整理一篇文章以提供测试部门人员参考。根据原因

测试部门发生了多次数据库服务器空间满而导致无法登陆Oracle实例的事情,在此特地整理一篇文章以提供测试部门人员参考。根据原因是由于测试部门在内网测试环境中开启了数据库的归档模式,一般由于测试数据库服务器就是普通的pc,空间小,在一段时间测试后,由于归档文件的大量积累导致数据库服务器空间满,从而导致数据库不能正常登陆。考虑到测试环境以及测试数据库一般情况下的非特别重要性,提供解决思路就是删除几天前的归档文件,进而关闭归档,来解决这一问题。

1。登陆测试数据库,此时由于磁盘满,无法登陆数据库,通过数据库启动初始化文件或者pfile、spfile文件查找确定数据库归档文件存放路径。

根据数据库启动访问参数文件的顺序spfile.ora,spfile.ora,init.ora,init.ora,相信下面大家会知道应该查看哪个文件的内容。

[root@dev2_180db ~]# su - oracle

[oracle@dev2_180db ~]$ cd $ORACLE_HOME/dbs
[oracle@dev2_180db dbs]$ ls
hc_center.dat initcenter.ora initdw.ora init.ora lkCENTER orapwcenter spfilecenter.ora

[oracle@dev2_180db dbs]$more spfilecenter.ora

center.__db_cache_size=1224736768
center.__java_pool_size=16777216
center.__large_pool_size=16777216
center.__shared_pool_size=301989888
center.__streams_pool_size=0
*._allow_resetlogs_corruption=true
*._kgl_large_heap_warning_threshold=8388608
*.aq_tm_processes=0
*.audit_file_dest='/u01/app/oracle/admin/center/adump'
*.background_dump_dest='/u01/app/oracle/admin/center/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/app/oracle/admin/center/control01.ctl','/u02/oradata/center/control02.ctl','/u02/oradata/center/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/center/cdump'
*.db_2k_cache_size=33554432
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=128
*.db_files=4000
*.db_name='center'
*.db_recovery_file_dest_size=4294967296
*.db_recovery_file_dest=''
*.job_queue_processes=0
*.log_archive_dest='/u02/oradata/center/archive'
*.log_checkpoints_to_alert=FALSE
*.open_cursors=600
*.parallel_execution_message_size=65535
*.parallel_max_servers=128
*.pga_aggregate_target=209715200
*.processes=1000
*.recyclebin='ON'
*.remote_login_passwordfile='EXCLUSIVE'
*.replication_dependency_tracking=FALSE
*.session_cached_cursors=100
*.sga_target=1610612736
*.shared_pool_size=100m
*.undo_management='AUTO'
*.undo_retention=0
*.undo_tablespace='UNDOTS'
*.user_dump_dest='/u01/app/oracle/admin/center/udump'
*.workarea_size_policy='AUTO'

查找到*.log_archive_dest的配置路径

[oracle@dev2_180db dbs]$ cd /u02/oradata/center/archive

2。删除指定1天前的归档文件

[oracle@dev2_180db archive]$ find /u02/oradata/center/archive -mtime +1 -name "*.dbf" -exec rm -rf {} \;

当手工删除了归档日志以后,Rman备份会检测到日志缺失,从而无法进一步继续执行。
所以此时需要手工执行crosscheck过程,之后Rman备份可以恢复正常。

3。通过rman进行Crosscheck日志

[oracle@dev2_180db archive]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jan 12 00:45:38 2012

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

connected to target database: CENTER (DBID=4195036994)

RMAN> crosscheck archivelog all;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1028 devtype=DISK
validation failed for archived log
archive log filename=/u02/oradata/center/archive/1_1_766187842.dbf recid=1 stamp=766189358
Crosschecked 1 objects

4。使用delete expired archivelog all 命令删除所有过期归档日志:

RMAN> delete expired archivelog all;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1028 devtype=DISK

List of Archived Log Copies
Key Thrd Seq S Low Time Name
------- ---- ------- - --------- ----
1 1 1 X 02-NOV-11 /u02/oradata/center/archive/1_1_766187842.dbf

Do you really want to delete the above objects (enter YES or NO)? Y
deleted archive log
archive log filename=/u02/oradata/center/archive/1_1_766187842.dbf recid=1 stamp=766189358
Deleted 1 EXPIRED objects

5。简要介绍一下report obsolete命令

使用report obsolete命令报告过期备份

RMAN> report obsolete;

6。使用delete obsolete命令删除过期备份:
RMAN> delete obsolete;

7再次crosscheck 日志,看返回信息判断是否数据库已经正常
RMAN> crosscheck archivelog all;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1028 devtype=DISK
specification does not match any archive log in the recovery catalog

如果有看到specification does not match any archive log in the recovery catalog返回信息,,那说明数据库已经正常了。

8。退出rman,登陆oracle数据库改归档模式为到非归档模式

RMAN> exit

Recovery Manager complete.
[oracle@dev2_180db archive]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jan 12 01:11:38 2012

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

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


SQL>shutdown immediate;

SQL>start mount;

SQL>alter database noarchivelog;

SQL>alter database open;

Oracle数据库服务器磁盘满导致数据库无法登陆,通过清理归档文件解决