sitemap

RSS地图

收藏本站

设为首页

Oracle研究中心

当前位置:Oracle研究中心 > 产品DBA > Oracle ASM >

Oracle DBA ASM日常工作ASMCMD常用基本命令 必须掌握ASM的命令

时间:2016-04-13 22:39   来源:Oracle研究中心   作者:网络   点击:

天萃荷净

Oracle DBA ASM日常工作ASMCMD常用基本命令

一、ASM磁盘和磁盘组管理

1、创建磁盘组
create diskgroup DG2 EXTERNAL REDUNDANCY DISK 'ORCL:A1';
   create diskgroup SYSDGM normal redundancy FAILGROUP flgrp1 disk '/dev/rhdisk52','/dev/rhdisk53' FAILGROUP flgrp2 disk '/dev/rhdisk14','/dev/rhdisk13';
1)磁盘名称需要大写
2)磁盘名称使用V$asm_disk.path

2、磁盘组中添加磁盘
alter diskgroup dg2 add disk 'ORCL:A2';
1)磁盘名称使用V$asm_disk.path

3、磁盘组中删除磁盘
alter diskgroup dg2 drop disk 'a1';
1)磁盘名称使用的是V$asm_disk.name

4、删除磁盘组
drop diskgroup dg2 including contents;

二、ASM相关视图

1、查看是否有数据库实例连接上ASM实例
select instance_name,db_name,status from v$asm_client;

2、记录BALANCE操作
select operation,state,power,actual,sofar from v$asm_operation;
alter diskgroup SYSDGM rebalance power 11;
---power0~11,0表示不rebalance,这个参数由ASM_POWER_LIMIT设置。

3、ASM DISK信息
select path, state, total_mb, free_mb from v$asm_disk;

4、ASM DISKGROUP信息,包括磁盘大小和剩余空间
select name,state,type,total_mb,free_mb from v$asm_diskgroup;

三、ASM和表空间管理

1、ASM中创建表空间
create tablespace tgyun datafile '+DG2' SIZE 100M;

2、ASM表空间中添加数据文件
alter tablespace tgyun add datafile '+dg2' size 10m;

3、ASM表空间中删除数据文件
alter tablespace tgyun drop datafile '+DG2/tgyun/datafile/tgyun.257.747278679';
或者
alter tablespace tgyun drop datafile 3;

4、删除表空间
drop tablespace tgyun including contents;

--查看当前磁盘组状态
SQL> select group_number,name,state,total_mb,free_mb from v$asm_diskgroup;
--卸载dg2磁盘组
SQL> alter diskgroup dg2 dismount;
SQL> select group_number,name,state,total_mb,free_mb from v$asm_diskgroup;
--挂载dg2磁盘组
SQL> alter diskgroup dg2 mount;
--卸载所有磁盘组
SQL> alter diskgroup all dismount;
SQL> select group_number,name,state,total_mb,free_mb from v$asm_diskgroup;
--挂载所有磁盘组
SQL> alter diskgroup all mount;
select group_number,name,state,total_mb,free_mb from v$asm_diskgroup;
--如果当前磁盘组有实例在访问,则不能被卸载
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

--创建目录
SQL> alter diskgroup dg2 add directory '+DG2/TGYUN'; 
Diskgroup altered.
--使用asmcmd查看(export ORACLE_SID=+ASM;asmcmd进入)
ASMCMD> pwd
+DG2
ASMCMD> ls -l
Type  Redund  Striped  Time             Sys  Name
                                        N    TGYUN/
--目录重命名
SQL> alter diskgroup dg2 rename directory '+DG2/CHENGFEI' TO '+DG2/TGYUN'; 
Diskgroup altered. 
ASMCMD> ls TGYUN/
--删除目录
SQL> alter diskgroup dg2 drop directory '+DG2/tgyun';
Diskgroup altered.
ASMCMD> ls
ASMCMD>
--添加别名
SQL> alter diskgroup dg2 add alias '+dg2/TGYUN' for '+dg2/tgyun/datafile/TY.256.754832383';
 
Diskgroup altered.
--使用asmcmd查看别名是否成功
ASMCMD> pwd
--别名重命名
SQL> alter diskgroup dg2 rename alias '+DG2/TGYUN' TO '+DG2/TGYUN.DBF';
 
Diskgroup altered.
--删除别名
SQL> alter diskgroup dg2 drop alias '+dg2/tgyun.dbf';
 
Diskgroup altered.
说明:
1)asmcmd命令行操作中,目录文件名不区分大小写,命令关键字区分大小写
2)磁盘组中的一个文件,最多只能建立一个别名,可以通过v$asm_alias视图查看别名的相关信息

---------------------------------------------------------------------------------------------------------------------------------------
md_backup: 将disk group中的metadata备份到文件; md_backup /tmp/backupfile -G DATAGP

md_restore: 将备份文件中的metadata恢复到disk group;  md_restore -full -G data --silent /tmp/file

lsattr: 列出disk group的属性; lsattr -l -G DATAGP

setattr: 设置disk group的属性; setattr -G DATAGP compataible.asm 11.2.0.0.0

cd, cp, du, help, ls, makedir, pwd, rm

find: 查找; find --type CONTROLFILE +data/orcl *

lsct: 显示v$asm_client的信息, ASM client的信息; lsct DATAGP

lsdg: 显示disk group的信息,v$asm_diskgroup and v$asm_diskgroup_stat; lsdg DATAGP

lsof: 显示local clients的open files; lsof -G DATAGP

mkalias: 给文件取个别名; mkalias SYSAUX.235.34323 sysaux.f; ls --absolutepath可以查看

rmalias: 删除别名; rmalias sysaux.f

chdg: 修改disk group, add或drop disk; chdg DATAGP_config.xml

chkdg: check 或 repair disk group 的metadata; chkdg --repair DATAGP

dropdg: drop disk group; dropdg -r -f DATAGP

iostat: 查看I/O statics通过v$asm_disk_iostat; iostat -G DATAGP

lsdsk: list ASM disks; lsdsk -p -G DATAGP /dev/raw/* ; lsdsk --candidate -p

lsod: list open ASM disks; lsod -G DATAGP

mkdg: create disk group based on a xml file; mkdg DATAGP_config.xml

mount: mount a disk group; mount -f DATAGP; mount --restrict DATAGP; mount -a

offline: offline disks or failure groups that belong to disk group. offline -G DATAGP -F FG1

online: online disks or a failure group; online -G DATAGP -D data_0001 --power=3

rebal: rebalance a disk group; rebal --power 4 DATAGP

remap: mark blocks as unusable on the disk and relocates data; remap DATAGP data_0001 500-700

umount: dismount a disk group; unmount -f DATAGP

pwcopy: copy password file; pwcopy --asm +DG/mydir/mypwfile +DG1/mypwfile

pwcreate: create password file for sys; pwcreate --asm +DG/mdir/mypwfile 'welcome'

pwdelete: delete password file; pwdelete --asm +DG/mydir/mypwfile

pwget: get the location of password file; pwget --asm

pwmove: move password file; pwmove --asm +DG/mydir/mypwfile +DG1/mypwfile

pwset: set the location of password file; pwset -dbuniquename aime1 +DG/mydir/mypwfile

dsget: get the discovery disk string;  dsget

dsset: set the discovery disk string;  dsset /dev/raw/*

lsop: list current operations on disk group from v$asm_operation; lsop

shutdown: shutdown ASM instance; shut immediate

spbackup: backup ASM Spfile; spbackup +DATA/asm/asmprameterfile/register.323.234
+DATA/spf.bak

spcopy: copy spfile; spcopy +DATA/asm/asmprameterfile/register.323.234 +DATA/spf.ora

spget: get the spfile location; spget

spmove: move spfile; spmove +DATA/spf.ora +DATA1/spf.ora

spset: set the location of spfile; spset +DATA/spf.ora

startup: start up ASM instance; startup --nomount --pfile asm.ora

chtmpl:改变template的属性;chtmpl -G DATAGP --redundancy high --striping fine mytemplate

lstmpl: list templates; ls -l -G DATAGP

mktmpl: add template to disk group; mktmpl -G DATA --redundancy mirror --striping coarse
mytp

rmtmpl: remove template from disk group; rmtmpl -G DATAGP mytp

chgrp: change user group of files;  chgrp asm-data +data/mydir/a.f

chmod: change permissions of files; chmod 640 a.f; ls --permission a.f

chown: change owner of files; chown user:usergroup a.f

groups: list all user groups of a user; groups DATAGP user

grpmod: add or remove OS users to ASM user group; grpmod --add fra asm_fra oracle1 oracle2

lsgrp: list all ASM user groups; lsgrp -a

lspwusr: list users from ASM password file; lspwusr

lsusr: list users in a disk group; lsusr -G DATAGP

mkgrp: create new ASM user group; mkgrp DATAGP asm_data oracle1 oracle2

mkusr: add OS user to a disk group; mkusr DATA oracle1

orapwusr: add, drop, modify ASM password file user;  orapwusr --add --privilege sysdba hrusr

passwd: change password of a user; passwd oracle2

rmgrp: remove a user group from disk group; rmgrp DATAGP asm_data

rmusr: remove a OS user from disk group; rmusr DATAGP oracle2

rpusr: replace OS user1 with OS user2; rpusr DATAGP oracle1 oracle2

volcreate: create an ADVM volume in disk group; volcreate -G DATA -s 10G --width 64K --column 8 volume1

voldelete: delete an ADVM volume; voldelete -G DATAGP volume1

voldisable: disable an ADVM volumes in mounted disk groups and remove the volume device on the local node;  voldisable -G DATAGP volume1

volenable: enable ADVM volume in mounted disk groups; volenable -G DATAGP volume1

volinfo: display information of ADVM volumes; volinfo -G DATAGP volume1

volresize: resize an ADVM volume; volresize -G DATAGP -s 20G volume1

volset: set attributes of ADVM volume; volset -G DATA --usagestring 'no file system attached'  volume1

volstat: report I/O statistics of ADVM volume; volstat -G DATAGP

--------------------------------------ORACLE-DBA----------------------------------------

最权威、专业的Oracle案例资源汇总之Oracle DBA ASM日常工作ASMCMD常用基本命令 必须掌握ASM的命令

本文由大师惜分飞原创分享,网址:http://www.oracleplus.net/arch/92.html

Oracle研究中心

关键词:

ASM日常工作ASMCMD常用基本命令