Skip to content
#!/bin/bash -x
ORACLEASM=/etc/init.d/oracleasm
echo"ASM Diskgroup Mapping luns"
echo"----------------------------------------------------"
for f in `$ORACLEASMlistdisks`
do
dp=`$ORACLEASM querydisk -p  $f |head-2| grep /dev | awk-F: '{print $1}'`
echo"$f: $dp"
done

Oracle官方有使用KFED更为便捷的脚本,该文档介绍如下:

 

That information can be obtained with the following shell script:

#!/bin/bash
for asmlibdisk in `ls /dev/oracleasm/disks/*`
do
echo “ASMLIB disk name: $asmlibdisk”
asmdisk=`kfed read $asmlibdisk | grep dskname | tr -s ‘ ‘| cut -f2 -d’ ‘`
echo “ASM disk name: $asmdisk”
majorminor=`ls -l $asmlibdisk | tr -s ‘ ‘ | cut -f5,6 -d’ ‘`
device=`ls -l /dev | tr -s ‘ ‘ | grep -w “$majorminor” | cut -f10 -d’ ‘`
echo “Device path: /dev/$device”
done

The script can be run as OS user that owns ASM or Grid Infrastructure home (oracle/grid), i.e. it does not need to be run as privileged user. The only requirement it that kfed binary exists and that it is in the PATH.

If an ASMLIB disk was already deleted, it will not show up in /dev/oracleasm/disks. We can check for devices that are (or were) associated with ASM with the following shell script:

#!/bin/bash
for device in `ls /dev/sd*`
do
asmdisk=`kfed read $device | grep ORCL | tr -s ‘ ‘ | cut -f2 -d’ ‘ | cut -c1-4`
if [ “$asmdisk” = “ORCL” ]
then
echo “Disk device $device may be an ASM disk”
fi
done

The second scripts takes a peek at sd devices in /dev, so in addition to the requirement for the kfed binary to be in the PATH, it also needs to be run as privileged user. Of course we can look at /dev/dm*, /dev/mapper, etc or all devices in /dev, although that may not be a good idea.

The kfed binary should be available in RDBMS home (prior to version 11.2) and in the Grid Infrastructure home (in version 11.2 and later). If the binary is not there, it can be built as follows:

cd $ORACLE_HOME/rdbms/lib
make -f ins* ikfed

Where ORACLE_HOME is the RDBMS home (prior to version 11.2) and the Grid Infrastructure home in version 11.2 and later.

The same can be achieved without kfed with a script like this:

#!/bin/bash
for device in `ls /dev/sd*`
do
asmdisk=`od -c $device | head | grep 0000040 | tr -d ‘ ‘ | cut -c8-11`
if [ “$asmdisk” = “ORCL” ]
then
echo “Disk device $device may be an ASM disk”
fi
done
快速列出ASM DISK和OS DISK DEV设备对应的脚本

遭遇11g R2 DRM bug:gcs resource directory to be unfrozen

用户的环境是aix版本的11.2.0.2集群,数据库实例hang,看到gcs resource,第一时间就反应是drm和lmon,结合hang前的awr也发现等待事件集中在gcs resource directory to be unfrozen,这个时候一般集中检查和gcs相关的信息:数据库告警日志,lmon trace,lms trace。整个过程是DRM触发了,但是并没有切换资源,导致实例hang住,根本原因是过大的buffer cache导致,根据lmon的信息和官方bug 12879027吻合,打上11.2.0.2.7的psu(DB和GI),后续继续观察

LMON进程trace可见如下:

*** 2014-08-14 21:13:51.87
 CGS recovery timeout = 85 sec
Begin DRM(231) (swin 1)
* drm quiesce

*** 2014-08-14 21:17:06.782
* Request pseudo reconfig due to drm quiesce hang
2012-07-14 21:17:03.752735 : kjfspseudorcfg: requested with reason 5(DRM Quiesce step stall)

*** 2014-08-14 21:17:04.911
kjxgmrcfg: Reconfiguration started, type 6
CGS/IMR TIMEOUTS:
 CSS recovery timeout = 31 sec (Total CSS waittime = 65)
 IMR Reconfig timeout = 75 sec
 CGS rcfg timeout = 85 sec
kjxgmcs: Setting state to 70 0.
 - AWR Top waits are "gcs resource directory to be unfrozen" & "gc remaster"

官方文档:

Bug 12879027  LMON gets stuck in DRM quiesce causing intermittent pseudo reconfiguration

 This note gives a brief overview of bug 12879027. 
 The content was last updated on: 15-OCT-2013
 Click here for details of each of the sections below.

Affects:

Product (Component) Oracle Server (Rdbms)
Range of versions believed to be affected Versions BELOW 12.1
Versions confirmed as being affected
Platforms affected Generic (all / most platforms affected)

Fixed:

The fix for 12879027 is first included in

Interim patches may be available for earlier versions – click here to check.

Symptoms:

Related To:

Description

This bug is only relevant when using Real Application Clusters (RAC)

LMON process can get stuck in the DRM quiesce step triggering
pseudo reconfiguration eventually.

Rediscovery Notes:
 DRM quiesce step hangs and triggers pseudoreconfiguration especially
 in single window DRM and when the buffer cache is very large.

Workaround
 None

Getting a Fix
 Use one of the "Fixed" versions listed above
 (for Patch Sets / bundles use the latest version available as
  contents are cumulative - the "Fixed" version listed above is
  the first version where the fix is included)
 or
 You can check for existing interim patches here: Patch:12879027

Please note: The above is a summary description only. Actual symptoms can vary. Matching to any symptoms here does not confirm that you are encountering this problem. For questions about this bug please consult Oracle Support.

References

Bug:12879027 (This link will only work for PUBLISHED bugs)
Note:245840.1 Information on the sections in this article

MDATA命令使用手册

MDATA的命令可以通过-help获取,参考如下:

MDATA>help

help ---- get command list
exit ---- exit from minidul
desc ---- display table structure
unload ---- unload data
unload table ---- unload data
unload table all
unload user
list ---- list schema object,partition,datafile
list users
list

<user_name>

命令介绍:
1.reload dict
重新加载数据字典,该作用为测试时候新建完对象使得数据库checkpoint一次后执行,主要是同步数据库数据字典,使用如下:

MDATA>reload dict
Start reload dict,Thu Aug 14 22:39:19 CST 2014
SQLException: State:   X0X95Severity: 30000
Operation 'TRUNCATE TABLE' cannot be performed on object 'IDUL_OBJ' because there is an open ResultSet dependent on that object.
load BOOTSTRAP$ success!
load TAB$ success!
load COL$ success!
load OBJ$ success!
load USER$ success!
load PROPS$ success!
load TABPART$ success!
load TABSUBPART$ success!
End reload dict,Thu Aug 14 22:39:26 CST 2014,reload success!

2.list命令
list命令可以列出当前数据库的用户,表等,使用如下:

MDATA>list table luda
OWNER                         TABLE
---------------               --------------
LUDA                          LUDA
LUDA                          LUDA
LUDA                          LUDA
LUDA                          LUDA
MDATA>list index scott
OWNER                         INDEX
---------------               --------------
SCOTT                         PK_DEPT
SCOTT                         PK_EMP
SCOTT                         PK_DEPT
SCOTT                         PK_EMP
MDATA>list users
USER#                         USER_NAME
---------------               --------------
43                            XDBWEBSERVICES
44                            ORDSYS
45                            ORDPLUGINS
46                            SI_INFORMTN_SCHEMA
47                            MDSYS
48                            OLAPI_TRACE_USER
50                            OLAP_DBA
......

3.desc 命令
该命令与sqlplus下的desc命令完全一致,列出表结构使用如下:

MDATA>desc luda.luda
Name                          Null?               Type
ID                                                NUMBER
NAME                                              NVARCHAR2(100)

4.unload命令
默认情况下unload是不会删除delete的数据的,要恢复delete的数据需要在unloadl table/unload user username 后面加上contain delete data(1.8版本更新)
unload命令为恢复导出数据使用,可以针对以某张表,也可以针对某个用户下的所有对象(用户级别的恢复),使用如下:

MDATA>unload user luda
unload user:LUDA
file_id:4,segment_id:51879
file_id:4,segment_id:51880
file_id:4,segment_id:51878
MDATA>unload table luda.luda
schema:LUDA;tab:LUDA
file_id:4,segment_id:51879
file_id:4,segment_id:51880
file_id:4,segment_id:51878
MDATA>

恢复出来的数据会存放在程序根目录的data文件夹中,恢复使用sqlload工具,此恢复参考http://www.ludatou.com/?p=1531

还有一篇场景恢复,目前MDATA支持delete,truncate的恢复,暂不支持drop的恢复,drop的恢复会在fk(扫描数据文件)功能开发完成后分享出来。

MDATA部署配置手册

配置MDATA

在一个环境中,需要配置的地方主要是4个,在内存上需预留空闲内存至少512M。

1. JDK配置

在MDATA1.1版本以来JDK版本要求为1.5以上版本,而在Oracle10g(包含10g)之前,包括Linux系统本身5.2之前都为1.4版本,在配置时候首先检测下JDK的版本:

系统自带的JDK版本检测

[root@ludatou ~]# java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20071124 (Red Hat 4.1.2-42)

10g自带java版本

[ora10g@ludatou ~]$ $ORACLE_HOME/jdk/bin/java -version
java version "1.4.2_14"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_14-b05)
Java HotSpot(TM) Client VM (build 1.4.2_14-b05, mixed mode)

11gr1自带的java版本

[ora10g@ludatou ~]$ /u01/oracle/product/11.1.7/jdk/bin/java -version
java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)

如果jdk版本低于1.5则无法正常使用MDATA,这里就需要指定1.5以上版本的JDK来执行MDATA程序,通过修改MDATA.SH(linux平台)或者MDATA.BAT(WIN平台)实现。

以linux为例

修改前:
[ora10g@ludatou MDATA155]$ cat MDATA.sh
java -Xms1024M -server -jar MDATA.jar
修改后:
[ora10g@ludatou MDATA155]$ cat MDATA.sh
/u01/oracle/product/11.1.7/jdk/bin/java -Xms512M -server -jar MDATA.jar

JDK下载地址:

JDK DOWNLOAD

2. 根目录下的config.txt

config.txt主要配置参数,字符集,块大小,版本,实例名。
具体配置参考如下:

[ora10g@ludatou MDATA155]$ cat config.txt
format=Oracle
block=8192
os=LITTLE
field=|
delete=false
charset_name=GBK
ncharset_name=AL16UTF16
db_name=lu10g
config=control.txt
output=output.log
#version 10g,11g,9i
version=10g

3. 根目录下的control.txt

control.txt主要配置需要恢复数据库的数据文件设置,配置数据文件的TS#,FILE#,NAME。
具体配置参考如下:

[ora10g@ludatou MDATA155]$ cat control.txt
# ts# file# name
[DATAFILE]
0 1 /oradata/lu10g/system01.dbf
1 2 /oradata/lu10g/undotbs01.dbf
2 3 /oradata/lu10g/sysaux01.dbf
4 4 /oradata/lu10g/users01.dbf

此信息的获取

set linesize 200
set pagesize 1024
col name for a100
select ts#,file#,name from v$datafile;

4. 根目录下的asmdisk.txt

手上暂时没有asm环境,不过配置直接从asm视图中可以查询。

[ora10g@ludatou MDATA155]$ cat asmdisk.txt
#disk_no disk_path group_name meta_block_size ausize disk_size header_offset
0  /dev/sdb1
1 /dev/sdc1