oracle 12c rac tablespace 表空间删除办法

文章来源: 原创adler_cn,大路

场景展示:

通过在某一台node节点上执行shell 脚本,正常会同步到其他node节点上,事实并不是如此,我们发现执行完脚本之后,RAC服务器上生成的tablespace 文件,并不能正确,

错误结果类似:'/u01/app/oracle/product/12.2.0/db_1/dbs/adler.dat'  这样的生成路径,这是不正确的,是单机节点的表现结果,

正常结果应该类似: +DATA/ORCL/99B08294CD7F045EE0511061480A4ADC/DATAFILE/adler.290.1029008888

后果:不能正常生成tablespace ,将会导致数据不能正常同步,问题很严重。

我们该如何解决类似的错误?

以下为解决办法:

1、先清理报错的事项,如账号和角色

drop user alder cascade;
drop role alder_REP_ROLE;
drop role alder_APP_ROLE;

2、查询空间表相关信息
select name from v$datafile;  #查询表空间
select tablespace_name,status from dba_tablespaces; #查询表空间相关信息

3、操作,先offline ,再执行删除操作;步骤:第一步执行  select name from v$datafile;  获取file_name,第二步执行  select tablespace_name,status from dba_tablespaces; 获取tablespace_name;
第一步:alter database datafile '/u01/app/oracle/product/12.2.0/db_1/dbs/adler.dat' offline drop;  
第二步:drop tablespace adler including contents; #删除以上表空间
              drop tablespace adler including contents and datafiles; #删除以上表空间和物理文件,和上面语句有一定差别,不过都可以执行

提示: 按照以上的办法,把其他需要重新生成的表空间和物理文件删除


4、验证结果

select tablespace_name, 
file_id, 
file_name, 
round(bytes / (1024 * 1024), 0) total_space 
from dba_data_files 
order by tablespace_name;  #查询表空间相关信息

select tablespace_name,file_name from dba_temp_files; # 查询临时表空间

 

5、重新执行shell 脚本,重新生成tablespace 表空间


6、表空间操作(补充)
查询:
SELECT tablespace_name, 
file_id, 
file_name, 
round(bytes / (1024 * 1024), 0) total_space 
FROM dba_data_files 
ORDER BY tablespace_name; 

新增操作:
create tablespace SIRM2 
datafile '+DATA/ORCL/99B08294CD7F045EE0539061480A4ADC/DATAFILE/SIRM2.dbf' size 1024M 
autoextend on next 10M maxsize unlimited
EXTENT MANAGEMENT local  autoallocate
segment space management auto;

删除操作:
drop tablespace SIRM2 including contents and datafiles;


7、用户删除操作(补充)

删除用户提示,无法删除在用用户

首先将索要删除的用户锁定(这句必须执行):

     alter user 用户名 account lock;

查看当前用户占用资源:

     select saddr,sid,serial#,paddr,username,status from v$session where username = '用户名';

然后可以看到status  为 INACTIVE 的记录;

 执行以下杀死进程的sql(下面的两个参数是status  为 INACTIVE 时的记录):

  alter system kill session 'sid,serial#';

 执行删除用户操作

  drop user 用户名 cascade;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章