意外在rac集群中将数据文件添加到本地文件系统

2023年 12月 14日 27.8k 0

在检查集群表空间数据文件的情况时发现有一个数据文件放在本地文件系统上,会造成集群例外的一个节点无法写入数据,后台日志报错,需要将这个数据文件迁移到asm磁盘组,让集群中所有实例都能访问到这个数据文件。

[oracle@sourcedb1:/home/oracle rac1]$ orafile

FILENAME |CREATED |TBSNAME |STATUS | INITMB| CURMB| MAXMB|AUTOEXT
----------------------------------------------------|------------------|---------------|----------|-------|-------|-------|--------
+DATA/rac/datafile/ogg_tbs.268.1134729409 |2023-04-21 10:36 |OGG_TBS |AVAILABLE | 1024| 1024| 32777|YES
/oracle/app/oracle/product/11.2.0/db_1/dbs/syw01.dbf|2023-09-22 16:12 |SYW |AVAILABLE | 500| 500| 32777|YES
+DATA/rac/datafile/sysaux.260.1134574539 |2023-04-19 15:35 |SYSAUX |AVAILABLE | 600| 1760| 32777|YES
+DATA/rac/datafile/system.259.1134574537 |2023-04-19 15:35 |SYSTEM |AVAILABLE | 700| 1540| 32777|YES
+DATA/rac/datafile/tbs_ggsyw_data.273.1138891657 |2023-06-07 14:47 |TBS_GGSYW_DATA |AVAILABLE | 1024| 1024| 32777|YES
+DATA/rac/datafile/undotbs1.261.1134574539 |2023-04-19 15:35 |UNDOTBS1 |AVAILABLE | 200| 32768| 32777|YES
+DATA/rac/datafile/undotbs2.263.1134574543 |2023-04-19 15:35 |UNDOTBS2 |AVAILABLE | 200| 510| 32777|YES
+DATA/rac/datafile/users.264.1134574543 |2023-04-19 15:35 |USERS |AVAILABLE | 5| 32741| 32777|YES
+DATA/rac/datafile/sywzx.272.1137338613 |2023-05-20 15:23 |SYWZX |AVAILABLE | 10| 13008| 32777|YES
+DATA/rac/datafile/sywzx.271.1137338611 |2023-05-20 15:23 |SYWZX |AVAILABLE | 10| 13211| 32777|YES
+DATA/rac/datafile/sywzx.270.1137338611 |2023-05-20 15:23 |SYWZX |AVAILABLE | 10| 12996| 32777|YES
+DATA/rac/datafile/sywzx.269.1137338595 |2023-05-20 15:23 |SYWZX |AVAILABLE | 10| 12935| 32777|YES

12 rows selected.

Elapsed: 00:00:00.02
[oracle@sourcedb1:/home/oracle rac1]$

报错

Fri Sep 22 16:12:37 2023
Errors in file /oracle/app/oracle/diag/rdbms/rac/rac2/trace/rac2_dbw0_18072.trc:
ORA-01157: cannot identify/lock data file 12 - see DBWR trace file
ORA-01110: data file 12: '/oracle/app/oracle/product/11.2.0/db_1/dbs/syw01.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /oracle/app/oracle/diag/rdbms/rac/rac2/trace/rac2_dbw0_18072.trc:
ORA-01186: file 12 failed verification tests

将表空间设置为read only

[oracle@sourcedb1:/home/oracle rac1]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Dec 14 14:37:44 2023
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
14:37:44 sys@@sourcedb1:RAC:rac1> ALTER TABLESPACE syw READ ONLY;
Tablespace altered.

使用 RMAN COPY 命令将数据文件复制到 ASM 磁盘组,当然也可以将数据文件offline直接手工拷贝到asm磁盘组中

[oracle@sourcedb1:/home/oracle rac1]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Dec 14 14:37:51 2023
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: RAC (DBID=2722556546)
RMAN> COPY DATAFILE '/oracle/app/oracle/product/11.2.0/db_1/dbs/syw01.dbf' TO '+DATA';
Starting backup at 14-DEC-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00012 name=/oracle/app/oracle/product/11.2.0/db_1/dbs/syw01.dbf
output file name=+DATA/rac/datafile/syw.275.1155566323 tag=TAG20231214T143842 RECID=1 STAMP=1155566323
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 14-DEC-23
RMAN>

在 SQL*Plus 中,指向新的 ASM 数据文件位置并将表空间切换回读写模式:

[oracle@sourcedb1:/home/oracle rac1]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Dec 14 14:39:47 2023
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
14:39:47 sys@@sourcedb1:RAC:rac1> ALTER TABLESPACE syw OFFLINE;
Tablespace altered.
Elapsed: 00:00:00.24
14:39:49 sys@@sourcedb1:RAC:rac1> ALTER DATABASE RENAME FILE '/oracle/app/oracle/product/11.2.0/db_1/dbs/syw01.dbf' TO '+DATA/rac/datafile/syw.275.1155566323';
Database altered.
Elapsed: 00:00:00.10
14:40:07 sys@@sourcedb1:RAC:rac1> ALTER TABLESPACE syw ONLINE;
Tablespace altered.
Elapsed: 00:00:00.02
14:40:17 sys@@sourcedb1:RAC:rac1> ALTER TABLESPACE syw READ WRITE;
Tablespace altered.
Elapsed: 00:00:00.10
14:40:24 sys@@sourcedb1:RAC:rac1>

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论