我们新装完11gRAC以后,检查数据文件发现是数据文件全部都是system.260.845655393这种格式,这个是ASM的默认格式。ASM文件名字的格式是固定的:+group/dbname/file type/tag.file.incarnation形式。
SQL> select tablespace_name,file_name from dba_data_files;
TABLESPACE_NAME FILE_NAME
------------------------------ --------------------------------------------------
SYSTEM +DATA1/csdb/datafile/system.260.845655393
SYSAUX +DATA1/csdb/datafile/sysaux.261.845655405
UNDOTBS1 +DATA1/csdb/datafile/undotbs1.262.845655411
UNDOTBS2 +DATA1/csdb/datafile/undotbs2.264.845655429
USERS +DATA1/csdb/datafile/users.265.845655431
在日常管理上,这个名字看着比较别扭,我们可以使用别名来替换这些数据文件名称。其实原理和ln建立软连接差不多,这不过这个设计到了ASM,下面就是我们的替换过程,这里除了ASM建立别名的操作比较陌生以外,其他还是比较简单的。
在新建表空间就不存在这个问题了。
SQL> create tablespace testdb datafile '+data1/csdb/testdb01.dbf' size 500M;
Tablespace created.
SQL> select tablespace_name,file_name from dba_data_files;
TABLESPACE_NAME FILE_NAME
------------------------------ --------------------------------------------------
SYSTEM +DATA1/csdb/datafile/system.260.845655393
SYSAUX +DATA1/csdb/datafile/sysaux.261.845655405
UNDOTBS1 +DATA1/csdb/datafile/undotbs1.262.845655411
UNDOTBS2 +DATA1/csdb/datafile/undotbs2.264.845655429
USERS +DATA1/csdb/datafile/users.265.845655431
TESTDB +DATA1/csdb/testdb01.dbf
6 rows selected.
使用别名方式来管理
-->建立数据文件的别名
[grid@rac2 ~]$ sqlplus / as sysasm
SQL*Plus: Release 11.2.0.3.0 Production on Mon Apr 28 16:27:42 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
SQL>
SQL> alter diskgroup data1 add alias '+data1/csdb/system01.dbf' for '+DATA1/csdb/datafile/system.260.845655393';
Diskgroup altered.
SQL> alter diskgroup data1 add alias '+data1/csdb/sysaux01.dbf' for '+DATA1/csdb/datafile/sysaux.261.845655405';
Diskgroup altered.
SQL> alter diskgroup data1 add alias '+data1/csdb/undotbs1_01.dbf' for '+DATA1/csdb/datafile/undotbs1.262.845655411';
Diskgroup altered.
SQL> alter diskgroup data1 add alias '+data1/csdb/undotbs2_01.dbf' for '+DATA1/csdb/datafile/undotbs2.264.845655429';
Diskgroup altered.
SQL> alter diskgroup data1 add alias '+data1/csdb/users01.dbf' for '+DATA1/csdb/datafile/users.265.845655431';
Diskgroup altered.
-->使用asmcmd检查,通过检查我们发现新建表空间时也是使用的别名机制。
ASMCMD> ls -s testdb01.dbf
Block_Size Blocks Bytes Space Name
testdb01.dbf => +DATA1/CSDB/DATAFILE/TESTDB.269.846087507
ASMCMD> ls -s system01.dbf
Block_Size Blocks Bytes Space Name
system01.dbf => +DATA1/CSDB/DATAFILE/SYSTEM.260.845655393
使用别名替换原来的数据文件名称
这个操作同数据文件修改名称的操作是一致的。
-->关闭2节点
SQL> show parameter instance_name;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
instance_name string csdb2
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
-->将1节点启动到mount状态
SQL> show parameter instance_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
instance_name string csdb1
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1653518336 bytes
Fixed Size 2228904 bytes
Variable Size 1073745240 bytes
Database Buffers 570425344 bytes
Redo Buffers 7118848 bytes
Database mounted.
-->修改数据文件名称
SQL> col name for a60
SQL> select name from v$datafile;
NAME
------------------------------------------------------------
+DATA1/csdb/datafile/system.260.845655393
+DATA1/csdb/datafile/sysaux.261.845655405
+DATA1/csdb/datafile/undotbs1.262.845655411
+DATA1/csdb/datafile/undotbs2.264.845655429
+DATA1/csdb/datafile/users.265.845655431
+DATA1/csdb/testdb01.dbf
6 rows selected.
SQL> alter database rename file '+DATA1/csdb/datafile/system.260.845655393' to '+data1/csdb/system01.dbf';
Database altered.
SQL> alter database rename file '+DATA1/csdb/datafile/sysaux.261.845655405' to '+data1/csdb/sysaux01.dbf';
Database altered.
SQL> alter database rename file '+DATA1/csdb/datafile/undotbs1.262.845655411' to '+data1/csdb/undotbs1_01.dbf';
Database altered.
SQL> alter database rename file '+DATA1/csdb/datafile/undotbs2.264.845655429' to '+data1/csdb/undotbs2_01.dbf';
Database altered.
SQL> alter database rename file '+DATA1/csdb/datafile/users.265.845655431' to '+data1/csdb/users01.dbf';
Database altered.
SQL> select name from v$datafile;
NAME
------------------------------------------------------------
+DATA1/csdb/system01.dbf
+DATA1/csdb/sysaux01.dbf
+DATA1/csdb/undotbs1_01.dbf
+DATA1/csdb/undotbs2_01.dbf
+DATA1/csdb/users01.dbf
+DATA1/csdb/testdb01.dbf
6 rows selected.
SQL> alter database open;
Database altered.
-->启动2节点
SQL> startup
ORACLE instance started.
Total System Global Area 1653518336 bytes
Fixed Size 2228904 bytes
Variable Size 1124076888 bytes
Database Buffers 520093696 bytes
Redo Buffers 7118848 bytes
Database mounted.
Database opened.
SQL> set linesize 200
SQL> select tablespace_name,file_name from dba_data_files;
TABLESPACE_NAME FILE_NAME
---------------------------------------- --------------------------------------------------
SYSTEM +DATA1/csdb/system01.dbf
SYSAUX +DATA1/csdb/sysaux01.dbf
UNDOTBS1 +DATA1/csdb/undotbs1_01.dbf
UNDOTBS2 +DATA1/csdb/undotbs2_01.dbf
USERS +DATA1/csdb/users01.dbf
TESTDB +DATA1/csdb/testdb01.dbf
6 rows selected.
到这里,我们的操作就完成了。