Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3693544
  • 博文数量: 715
  • 博客积分: 1860
  • 博客等级: 上尉
  • 技术积分: 7745
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-07 08:51
个人简介

偶尔有空上来看看

文章分类

全部博文(715)

文章存档

2023年(75)

2022年(134)

2021年(238)

2020年(115)

2019年(11)

2018年(9)

2017年(9)

2016年(17)

2015年(7)

2014年(4)

2013年(1)

2012年(11)

2011年(27)

2010年(35)

2009年(11)

2008年(11)

分类: Oracle

2022-03-17 10:44:48

通过一些脚本检查asm 磁盘状态

  1. -- check asm disk
  2. -- example :@ac.sql DATADG

  3. set ver off
  4. set lin 200 pages 100
  5. col DISKGROUP for a12
  6. col name for a30
  7. col value for a15
  8. SELECT SUBSTR(dg.name,1,12) AS diskgroup, SUBSTR(a.name,1,24) AS name,
  9.      SUBSTR(a.value,1,24) AS value, read_only FROM V$ASM_DISKGROUP dg,
  10.      V$ASM_ATTRIBUTE a WHERE dg.name = '&1' AND dg.group_number = a.group_number
  11.      AND a.name NOT LIKE '%template%';

  12. col ASM_COMPAT for a20
  13. col DB_COMPAT for a20
  14. col FAILGROUP for a20
  15. SELECT name AS diskgroup, substr(compatibility,1,12) AS asm_compat,
  16.      substr(database_compatibility,1,12) AS db_compat,ALLOCATION_UNIT_SIZE/1024/1024 au_size_M,type,state,total_mb,free_mb,OFFLINE_DISKS,VOTING_FILES FROM V$ASM_DISKGROUP;

  17. col path for a30
  18. col name for a20
  19. col mount_status for a10
  20. col header_status for a12
  21. select GROUP_NUMBER,name,path,MOUNT_STATUS,HEADER_STATUS,STATE,VOTING_FILE,total_mb,free_mb from v$asm_disk order by 1,2;

  22. col disk_name for a20
  23. SELECT SUBSTR(dg.name,1,16) AS diskgroup, SUBSTR(d.name,1,16) AS disk_name,
  24.      d.mount_status, d.state, SUBSTR(d.failgroup,1,16) AS failgroup
  25.      FROM V$ASM_DISKGROUP dg, V$ASM_DISK d WHERE dg.group_number = d.group_number;
  26.      
  27.  SELECT SUBSTR(dgs.name,1,10) AS diskgroup, SUBSTR(ds.name,1,10) AS asmdisk,
  28.        ds.mount_status, ds.state, ds.reads, ds.writes, ds.read_time, ds.write_time,
  29.        bytes_read, bytes_written
  30.        FROM V$ASM_DISKGROUP_STAT dgs, V$ASM_DISK_STAT ds
  31.        WHERE dgs.group_number = ds.group_number AND dgs.name = '&1';

  32. col INSTANCE for a15
  33. col DBNAME for a15
  34. col SOFTWARE for a20
  35. col COMPATIBLE for a20
  36. SELECT dg.name AS diskgroup, SUBSTR(c.instance_name,1,12) AS instance,
  37.     SUBSTR(c.db_name,1,12) AS dbname, SUBSTR(c.SOFTWARE_VERSION,1,12) AS software,
  38.     SUBSTR(c.COMPATIBLE_VERSION,1,12) AS compatible
  39.     FROM V$ASM_DISKGROUP dg, V$ASM_CLIENT c
  40.     WHERE dg.group_number = c.group_number;
  41.     
  42. SELECT dg.name AS diskgroup, u.group_number, u.user_number, u.os_id, u.os_name
  43.      FROM V$ASM_DISKGROUP dg, V$ASM_USER u
  44.      WHERE dg.group_number = u.group_number AND dg.name = '&1';
  45.      
  46. SELECT dg.name AS diskgroup, ug.group_number, ug.owner_number, u.os_name,
  47.      ug.usergroup_number, ug.name FROM V$ASM_DISKGROUP dg, V$ASM_USER u, V$ASM_USERGROUP ug
  48.      WHERE dg.group_number = ug.group_number AND dg.name = '&1'
  49.      AND ug.owner_number = u.user_number;

  50. SELECT dg.name AS diskgroup, um.group_number, um.member_number, u.os_name,
  51.      um.usergroup_number, ug.name FROM V$ASM_DISKGROUP dg, V$ASM_USER u, V$ASM_USERGROUP_MEMBER um,
  52.      V$ASM_USERGROUP ug WHERE dg.group_number = um.group_number AND
  53.      dg.group_number = ug.group_number AND dg.group_number = u.group_number AND dg.name = '&1'
  54.      AND um.member_number = u.user_number AND um.usergroup_number = ug.usergroup_number;

  55. SELECT dg.name AS diskgroup, a.name, f.permissions, f.user_number, u.os_name,
  56.        f.usergroup_number, ug.name
  57.      FROM V$ASM_DISKGROUP dg, V$ASM_USER u, V$ASM_USERGROUP ug, V$ASM_FILE f, V$ASM_ALIAS a
  58.      WHERE dg.name = '&1' AND dg.group_number = u.group_number AND
  59.        u.group_number = ug.group_number AND ug.group_number = f.group_number AND
  60.        f.group_number = a.group_number AND
  61.        f.usergroup_number = ug.usergroup_number AND f.user_number = u.user_number AND
  62.        f.file_number = a.file_number;

  63. col error_code for a10
  64. select * from v$asm_operation;
  65.        
  66. --自动扩展是否合理(每次扩512M)
  67. col file_name for a60
  68. SELECT distinct df.file_name FROM dba_data_files df, v$asm_alias a,
  69. (SELECT ad.group_number, count(*) DG_num_disks, att.value, (count(*) * att.value) Ext_Size
  70. FROM v$asm_disk ad, V$ASM_ATTRIBUTE att
  71. WHERE ad.group_number=att.group_number
  72. AND att.name = 'au_size'
  73. GROUP BY ad.group_number,att.value) v
  74. WHERE autoextensible = 'YES'
  75. AND status = 'AVAILABLE'
  76. AND a.group_number=v.group_number
  77. AND upper (df.file_name) in
  78. (SELECT concat('+'||gname,sys_connect_by_path(aname, '/'))
  79. FROM (SELECT vg.name gname, va.parent_index pindex, upper(va.name) aname, va.reference_index rindex, va.group_number gnum,va.file_number filnum
  80. FROM v$asm_alias va,v$asm_diskgroup vg
  81. WHERE va.group_number = vg.group_number)
  82. START WITH (MOD(pindex, power(2, 24))) = 0
  83. CONNECT BY PRIOR rindex = pindex)
  84. AND MOD((df.increment_by * (SELECT value FROM v$parameter WHERE name = 'db_block_size')), v.Ext_Size) > 0;


以上方法不太完整,如果想获取所有asm相关信息需要以下脚本
asm_meta.sql
调用示例:
su - grid
sqlplus / as sysasm @asm_meta
然后下载当前路径下的文件ASM_METADATA.html,用浏览器查看

asmcmd_script.zip
调用示例:
su - grid
sh ./asmcmd_script.sh
然后查看 /tmp/asmcmd_script.out

参考:
怎样格式化收集以及备份 10.1,10.2,11.1,11.2 , 12.1和12.2 的 ASM、ACFS 元数据? (Doc ID 2226530.1)
阅读(692) | 评论(0) | 转发(0) |
0

上一篇:ocr 恢复

下一篇:诊断gridSetup.sh

给主人留下些什么吧!~~