Home  >  Article  >  Database  >  【翻译自mos文章】在rac中,使用asmcmd命令从文件系统movesystem

【翻译自mos文章】在rac中,使用asmcmd命令从文件系统movesystem

WBOY
WBOYOriginal
2016-06-07 15:58:321123browse

在rac中,使用asmcmd命令从 文件系统 move system datafile 到asm磁盘组的方法。 参考原文: How to move a SYSTEM datafile from filesystem to the ASM diskgroup using ASMCMD on RAC. (Doc ID 1607292.1) 适用于: Oracle Database - Enterprise Edition


在rac中,使用asmcmd命令从 文件系统 move system datafile 到asm磁盘组的方法。

参考原文:
How to move a SYSTEM datafile from filesystem to the ASM diskgroup using ASMCMD on RAC. (Doc ID 1607292.1)

适用于:
Oracle Database - Enterprise Edition - Version 11.2.0.1 to 11.2.0.3 [Release 11.2]
Oracle Database - Enterprise Edition - Version 10.2.0.1 to 10.2.0.1 [Release 10.2]
Information in this document applies to any platform.


症状:
由于误操作,客户在为system 表空间添加datafile时,没有带+号,添加datafile的命令执行后,datafile被创建在了一个节点的 $ORACLE_HOME/dbs 下。其他节点看不到这个新添加的datafile,会报ORA-01157: cannot identify/lock data file

需要move 该system表空的datafile 到 asm磁盘组中。

原因:
datafile被创建在了文件系统中,而不是创建在asm磁盘组中。

[oracle@mbrac2 ~]$ echo $ORACLE_SID
ORCL2
File exists on one node but not on the other:

[oracle@mbrac2 dbs]$ ls -ltr
total 524848
-rw-r--r--. 1 oracle oinstall 2851 May 15 2009 init.ora
-rw-r-----. 1 oracle oinstall 1536 Nov 28 16:12 orapwORCL2
-rw-r-----. 1 oracle oinstall 35 Nov 28 16:13 initORCL2.ora
-rw-rw----. 1 oracle dba 1544 Dec 3 15:23 hc_ORCL2.dat
-rw-r-----. 1 oracle dba 536879104 Dec 10 17:56 DATA ==============
[oracle@mbrac1 dbs]$ ls -ltr
total 32
-rw-r--r--. 1 oracle oinstall 2851 May 15 2009 init.ora
-rw-r-----. 1 oracle oinstall 1536 Nov 28 16:12 orapwORCL1
-rw-r-----. 1 oracle oinstall 35 Nov 28 16:13 initORCL1.ora
-rw-rw----. 1 oracle dba 1544 Dec 3 15:23 hc_ORCL1.dat

上面的的显示可以看出:DATA只在mbrac2上有,在mbrac1上没有这个文件。


解决方案:

1.stop db
2.使用asmcmd命令move datafile
3.mount db
4.rename 该datafile
5.open db
6.在其他rac节点上重启数据库实例,否则会遇到错误ORA-01516 or original error ORA-01157: cannot identify/lock data file

======下面是具体的步骤=======

1.stop db
对于system 表空间,不得不stop db,否则会报错:ORA-01541: system tablespace cannot be brought offline

[oracle@mbrac1 dbs]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/dbs
SQL> select TABLESPACE_NAME, file_name, file_id, online_status from dba_data_files where TABLESPACE_NAME='SYSTEM';

TABLESPACE_NAME
------------------------------
FILE_NAME
--------------------------------------------------------------------------------
FILE_ID ONLINE_
---------- -------
SYSTEM
+DATA/orcl/datafile/system.256.832695063
1 SYSTEM

SYSTEM
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/DATA
6 SYSTEM

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

No errors in alert.log

2. 使用asmcmd cp move datafile。注意:别名是正常的,因为这不是系统指派别名。

ASMCMD> cp /u01/app/oracle/product/11.2.0/dbhome_1/dbs/DATA +DATA/ORCL/DATAFILE/SYSTEM2
copying /u01/app/oracle/product/11.2.0/dbhome_1/dbs/DATA -> +DATA/ORCL/DATAFILE/SYSTEM2
ASMCMD> ls -lt
Type Redund Striped Time Sys Name
DATAFILE UNPROT COARSE DEC 10 18:00:00 Y USERS.259.832695063
DATAFILE UNPROT COARSE DEC 10 18:00:00 Y UNDOTBS2.264.832695177
DATAFILE UNPROT COARSE DEC 10 18:00:00 Y UNDOTBS1.258.832695063
N SYSTEM2 => +DATA/ASM/DATAFILE/SYSTEM2.268.833825159
DATAFILE UNPROT COARSE DEC 10 18:00:00 Y SYSTEM.256.832695063
DATAFILE UNPROT COARSE DEC 10 18:00:00 Y SYSAUX.257.832695063

--->注意 oracle 10g的时候还没有asmcmd下的cp命令,
--->因此,若是10g,请参考NOTE:390274.1 - How to move a datafile from a file system to ASM


3. mount database
SQL> startup mount;
ORACLE instance started.

Total System Global Area 1252663296 bytes
Fixed Size 2252824 bytes
Variable Size 805310440 bytes
Database Buffers 436207616 bytes
Redo Buffers 8892416 bytes
Database mounted.


4. rename datafile :

SQL> alter database rename file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/DATA' to '+DATA/ORCL/DATAFILE/SYSTEM2';
Database altered.


5.open db:
SQL> alter database open;
Database altered.

6. 在其他rac节点上重启数据库实例,否则会遇到错误ORA-01516 or original error ORA-01157: cannot identify/lock data file
在所有实例上对比system表空间的datafile,看是否一样。

[oracle@mbrac1 dbs]$ echo $ORACLE_SID
ORCL1
[oracle@mbrac1 dbs]$
[oracle@mbrac1 dbs]$ sqlplus

SQL*Plus: Release 11.2.0.4.0 Production on Tue Dec 10 19:00:47 2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Enter user-name: / as sysdba

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

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area 1252663296 bytes
Fixed Size 2252824 bytes
Variable Size 872419304 bytes
Database Buffers 369098752 bytes
Redo Buffers 8892416 bytes
Database mounted.
Database opened.
SQL>

SQL>
SQL> select TABLESPACE_NAME, file_name, file_id from dba_data_files where TABLESPACE_NAME='SYSTEM';
TABLESPACE_NAME FILE_NAME FILE_ID
--------------------------------------------------------------------------------
SYSTEM
+DATA/orcl/datafile/system.256.832695063
1
SYSTEM
+DATA/orcl/datafile/system2
6

SQL> select INSTANCE_NUMBER, INSTANCE_NAME from v$instance ;
INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
1 ORCL1

Then on the second node:

SQL> select TABLESPACE_NAME, file_name, file_id, online_status from dba_data_files where TABLESPACE_NAME='SYSTEM';
TABLESPACE_NAME FILE_NAME FILE_ID ONLINE_
--------------------------------------------------------------------------------
SYSTEM +DATA/orcl/datafile/system.256.832695063
1 SYSTEM

SYSTEM +DATA/orcl/datafile/system2
6 SYSTEM
SQL> select INSTANCE_NUMBER, INSTANCE_NAME from v$instance ;
INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
2 ORCL2

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn