ASM简单管理(2)

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:ASM简单管理(2)

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

1、磁盘组卸载/挂载

--查看当前磁盘组状态
SQL> select group_number,name,state,total_mb,free_mb from v$asm_diskgroup;

GROUP_NUMBER NAME                 STATE                    TOTAL_MB    FREE_MB
------------ -------------------- ---------------------- ---------- ----------
           1 ARCHIVELOG           MOUNTED                     12637      12585
           2 DATA                 MOUNTED                     10228       7644
           3 FLASHBACK            MOUNTED                      7836       7786
           4 DG2                  MOUNTED                      5114       5012
--卸载dg2磁盘组
SQL> alter diskgroup dg2 dismount;

Diskgroup altered.

SQL> select group_number,name,state,total_mb,free_mb from v$asm_diskgroup;

GROUP_NUMBER NAME                 STATE                    TOTAL_MB    FREE_MB
------------ -------------------- ---------------------- ---------- ----------
           1 ARCHIVELOG           MOUNTED                     12637      12585
           2 DATA                 MOUNTED                     10228       7644
           3 FLASHBACK            MOUNTED                      7836       7786
           0 DG2                  DISMOUNTED                      0          0
--挂载dg2磁盘组
SQL> alter diskgroup dg2 mount;

Diskgroup altered.

SQL> select group_number,name,state,total_mb,free_mb from v$asm_diskgroup;

GROUP_NUMBER NAME                 STATE                    TOTAL_MB    FREE_MB
------------ -------------------- ---------------------- ---------- ----------
           1 ARCHIVELOG           MOUNTED                     12637      12585
           2 DATA                 MOUNTED                     10228       7644
           3 FLASHBACK            MOUNTED                      7836       7786
           4 DG2                  MOUNTED                      5114       5012
--卸载所有磁盘组
SQL> alter diskgroup all dismount;

Diskgroup altered.

SQL> select group_number,name,state,total_mb,free_mb from v$asm_diskgroup;

GROUP_NUMBER NAME                 STATE                    TOTAL_MB    FREE_MB
------------ -------------------- ---------------------- ---------- ----------
           0 DATA                 DISMOUNTED                      0          0
           0 DG2                  DISMOUNTED                      0          0
           0 FLASHBACK            DISMOUNTED                      0          0
           0 ARCHIVELOG           DISMOUNTED                      0          0
--挂载所有磁盘组
SQL> alter diskgroup all mount;

Diskgroup altered.

SQL> select group_number,name,state,total_mb,free_mb from v$asm_diskgroup;

GROUP_NUMBER NAME                 STATE                    TOTAL_MB    FREE_MB
------------ -------------------- ---------------------- ---------- ----------
           2 DATA                 MOUNTED                     10228       7644
           3 DG2                  MOUNTED                      5114       5012
           4 FLASHBACK            MOUNTED                      7836       7786
           1 ARCHIVELOG           MOUNTED                     12637      12585
--如果当前磁盘组有实例在访问,则不能被卸载

SQL> alter diskgroup data dismount;
alter diskgroup data dismount
*
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-15027: active use of diskgroup "DATA" precludes its dismount

2、磁盘组目录

--创建目录
SQL> alter diskgroup dg2 add directory '+DG2/CHENGFEI';

Diskgroup altered.
--使用asmcmd查看(export ORACLE_SID=+ASM;asmcmd进入)
ASMCMD> pwd
+DG2
ASMCMD> ls -l
Type  Redund  Striped  Time             Sys  Name
                                        N    CHENGFEI/
--目录重命名
SQL> alter diskgroup dg2 rename directory '+DG2/CHENGFEI' TO '+DG2/XIFENFEI';

Diskgroup altered.

ASMCMD> ls 
XIFENFEI/
--删除目录
SQL> alter diskgroup dg2 drop directory '+DG2/xifenfei';

Diskgroup altered.

ASMCMD> ls
ASMCMD> 

3、文件别名

--添加别名
SQL> alter diskgroup dg2 add alias '+dg2/XIFENFEI' for '+dg2/tasm/datafile/XFF.256.754832383';

Diskgroup altered.
--使用asmcmd查看别名是否成功                                           
ASMCMD> pwd
+dg2
ASMCMD> ls -l
Type      Redund  Striped  Time             Sys  Name
                                            Y    TASM/
                                            N    XIFENFEI => +DG2/TASM/DATAFILE/XFF.256.754832383
--别名重命名
SQL> alter diskgroup dg2 rename alias '+DG2/XIFENFEI' TO '+DG2/FEIFEI.DBF';

Diskgroup altered.

                                            N    XIFENFEI => +DG2/TASM/DATAFILE/XFF.256.754832383
ASMCMD> ls -l
Type      Redund  Striped  Time             Sys  Name
                                            N    FEIFEI.DBF => +DG2/TASM/DATAFILE/XFF.256.754832383
 
                                           Y    TASM/
--删除别名
SQL> alter diskgroup dg2 drop alias '+dg2/feifei.dbf';

Diskgroup altered.

ASMCMD> ls -l
Type  Redund  Striped  Time             Sys  Name
                                        Y    TASM/

说明:
1)asmcmd命令行操作中,目录文件名不区分大小写,命令关键字区分大小写
2)磁盘组中的一个文件,最多只能建立一个别名可以通过v$asm_alias视图查看别名的相关信息
ASM简单管理(1)

此条目发表在 Oracle ASM 分类目录。将固定链接加入收藏夹。

评论功能已关闭。