服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|Access|数据库技术|

服务器之家 - 数据库 - Oracle - oracle丢失temp表空间的处理方法

oracle丢失temp表空间的处理方法

2023-05-02 14:01cycsa Oracle

之前有做临时表空间的切换,切换后没drop tablespace就删除了temp01.dbf结果排序跟查dba_temp_files报错

之前有做临时表空间的切换,切换后没drop tablespace就删除了temp01.dbf结果排序跟查dba_temp_files报错

?
1
2
3
4
5
6
7
8
9
SQL> select tablespace_name,file_id,file_name,bytes/1024/1024 Mbytes from dba_temp_files;
select tablespace_name,file_id,file_name,bytes/1024/1024 Mbytes from dba_temp_files
                                                                     *
ERROR at line 1:
ORA-01116: error in opening database file 201
ORA-01110: data file 201: '/home/oracle/oradata/osa/temp01.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3

两种方法可以恢复

1、重启数据库

重启后系统会自动重建,数据库会提示re-creating在bdump的alter_sid.log中

Re-creating tempfile /home/oracle/oradata/osa/temp01.db

2、重建

alter tablespace temp add tempfile '/oracle/oradata/osa/temp03.dbf' size 50m;
alter tablespace temp drop tempfile '/oracle/oradata/osa/temp01.dbf' ;

Oracle 11g的Temp表空间怎么恢复?

答案是系统会自动重建;

实验如下:

我们先查看Temp表空间对应的数据文件

?
1
2
3
4
5
SQL> select FILE_NAME,TABLESPACE_NAME,STATUS from dba_temp_files;
 
FILE_NAME                TABLESPACE_NAME                                        STATUS
---------------------------------------- ------------------------------------------------------------------------------------------ ---------------------
/u01/oracle/oradata/orcl/temp01.dbf  TEMP                                               ONLINE

然后登陆到sys用户下,shutdown immediate

在文件系统层面去删除该数据文件

?
1
2
3
cd /u01/oracle/oradata/orcl/
ls
rm -f temp01.dbf

启动过程中,可观察到Alert日志中出现如下语句

?
1
Re-creating tempfile /u01/oracle/oradata/orcl/temp01.dbf

然后Oracle正常启动,查看文件系统,又多了temp01.dbf
实验结束。

还有一种情况,考虑到生产环境,数据库需要7*24小时的运转,假如说运行过程中temp数据文件出问题,而该问题又没有导致数据库异常关闭的情况下,该如何修复? 值得注意的是,temp表有排序的功能。

由于实验过程不好模拟,我们需要执行的操作就是丢一个temp02.dbf的数据文件给临时表空间,然后去掉temp01.dbf的数据文件就可以了。

原文链接:https://www.cnblogs.com/cycsa/p/3158887.html

延伸 · 阅读

精彩推荐