共计 28604 个字符,预计需要花费 72 分钟才能阅读完成。
本篇内容主要讲解“Oracle ASM Filter Driver 的相关知识点有哪些”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让丸趣 TV 小编来带大家学习“Oracle ASM Filter Driver 的相关知识点有哪些”吧!
Oracle ASM Filter Driver(Oracle ASMFD)消除了在系统每次被重启后 Oracle ASM 需要重新绑定磁盘设备来简化对磁盘设备的配置与管理。Oracle ASM Filter Driver(Oracle ASMFD)是一种内置在 Oracle ASM 磁盘的 IO 路径中的内核模块。Oracle ASM 使用 filter driver 来验证对 Oracle ASM 磁盘的写 IO 操作。Oracle ASM Filter Driver 会拒绝任何无效的 IO 请求。这种操作消除了意外覆盖 Oracle ASM 磁盘而损坏磁盘组中的磁盘与文件。例如,Oracle ASM Filter Driver 会过滤掉所有可能意外覆盖磁盘的非 Oracle IO 操作。从 Oracle 12.2 开始,Oracle ASM Filter Driver(Oracle ASMFD)在系统安装 Oracle ASMLIB 的情况下不能被安装,如果你想安装与配置 Oracle ASMFD,那么必须首先卸载 Oracle ASMLIB。Oracle 12.2 的 ASMFD 不支持扩展分区表。
配置 Oracle ASM Filter Driver
可以在安装 Oracle Grid Infrastructure 时或在安装 Oracle Grid Infrastructure 后对磁盘设备永久性配置 Oracle ASM Filter Driver(Oracle ASMFD)。
在安装 Oracle Grid Infrastructure 时配置 Oracle ASM Filter Driver
在安装 Oracle Grid Infrastructure 时,可以选择启用自动安装与配置 Oracle ASM Filter Driver。如果在安装 Oracle Grid Infrastructure 所在的系统中没有使用 udev,那么可以在在安装 Oracle Grid Infrastructure 之前执行下面的操作来为 Oracle ASMFD 准备磁盘。下面的操作必须在 Oracle Grid Infrastructure 软件包在 Oracle Grid Infrastructure home 目录中必须解压后,但在配置 ASMFD 之前执行。
1. 为了使用 Oracle ASM Filter Driver 来配置共享磁盘,以 root 用户来设置环境变量 $ORACLE_HOME 为 Grid Home 目录,设置环境变量 $ORACLE_BASE 为临时目录
# set ORACLE_HOME=/u01/app/oracle/12.2.0/grid
# set ORACLE_BASE=/tmp
ORACLE_BASE 变量被设置为临时目录可以避免在安装 Oracle Grid Infrastructure 之前在 Grid Home 目录中创建诊断或跟踪文件。在执行下面的操作之前,确保是在 $ORACLE_HOME/bin 目录中执行命令。
2. 使用 ASMCMD afd_label 命令来为 Oracle ASM Filter Driver 来准备磁盘.
#asmcmd afd_label DATA1 /dev/disk1a --init
3. 使用 ASMCMD afd_lslbl 命令来验证磁盘是否已经被标记可以为 Oracle ASMFD 所使用
#asmcmd afd_lslbl /dev/disk1a
查看某块磁盘
[rootd@cs1 ~]./asmcmd afd_lslbl /dev/asmdisk01
--------------------------------------------------------------------------------
Label Duplicate Path
================================================================================
CRS2 /dev/asmdisk01
列出已经标记可以为 Oracle ASMFD 所使用的所有磁盘
[grid@jytest1 ~]$ asmcmd afd_lslbl
--------------------------------------------------------------------------------
Label Duplicate Path
================================================================================
CRS1 /dev/asmdisk02
CRS2 /dev/asmdisk01
DATA1 /dev/asmdisk03
DATA2 /dev/asmdisk04
FRA1 /dev/asmdisk07
TEST1 /dev/asmdisk05
TEST2 /dev/asmdisk06
4. 当为 Oracle ASMFD 准备完磁盘后清除变量 ORACLE_BASE
# unset ORACLE_BASE
5. 运行安装脚本 (gridSetup.sh) 来安装 Oracle Grid Infrastructure 并启用 Oracle ASM Filter Driver 配置。
在安装 Oracle Grid Infrastructure 后配置 Oracle ASM Filter Driver
如果在安装 Grid Infrastructure 时没有启用配置 Oracle ASMFD,那么可以使用 Oracle ASMFD 来手动配置 Oracle ASM 设备。
为 Oracle Grid Infrastructure Clusterware 环境配置 Oracle ASM,具体操作如下:
1. 以 Oracle Grid Infrastructure 用户来更新 Oracle ASM 磁盘发现路径来使 Oracle ASMFD 来发现磁盘。
首先检查当前 Oracle ASM 磁盘发现路径并更新
[grid@cs1 ~]$ asmcmd dsget
parameter:/dev/sd*, /dev/asm*
profile:/dev/sd*,/dev/asm*
将 AFD:* 增加到发现磁盘路径中
[grid@cs1 ~]$ asmcmd dsset dev/sd* , /dev/asm*
, AFD:*
[grid@cs1 ~]$ asmcmd dsget
parameter:dev/sd*, /dev/asm*, AFD:*
profile:dev/sd*,/dev/asm*,AFD:*
2. 以 Oracle Grid Infrastructure 用户来获取 cluster 中的节点列表与角色
[grid@cs1 ~]$ olsnodes -a
cs1 Hub
cs2 Hub
3. 在每个 Hub 与 Leaf 节点上,可以以回滚或非回滚模式来执行以下操作
3.1 以 root 用户来停止 Oracle Grid Infrastructure
# $ORACLE_HOME/bin/crsctl stop crs
如果命令返回错误,那么执行下面的命令来强制停止 Oracle Grid Infrastructure
# $ORACLE_HOME/bin/crsctl stop crs
-f
3.2 在节点层面以 root 用户来配置 Oracle ASMFD
# $ORACLE_HOME/bin/asmcmd afd_configure
3.3 以 Oracle Grid Infrastructure 用户来验证 Oracle ASMFD 的状态
[grid@cs2 ~]$ asmcmd afd_state
ASMCMD-9526: The AFD state is LOADED and filtering is ENABLED on host cs2.jy.net
3.4 以 root 用户来启动 Oracle Clusterware stack
# $ORACLE_HOME/bin/crsctl start crs
3.5 以 Oracle Grid Infrastructure 用户来设置 Oracle ASMFD 发现磁盘路径为步骤 3.1 中所检索到的原始 Oracle ASM 磁盘发现路径
[grid@cs1 ~]$ asmcmd dsset dev/sd* , /dev/asm*
迁移不包含 OCR 或 vote 文件的磁盘组到 Oracle ASMFD
1. 以 Oracle Grid Infrastructure 用户来执行以下操作
2. 列出已经存在的磁盘组
[grid@cs2 ~]$ asmcmd lsdg
State Type Rebal Sector Logical_Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED EXTERN N 512 512 4096 4194304 40960 1544 0 1544 0 Y CRS/
MOUNTED EXTERN N 512 512 4096 4194304 40960 860 0 860 0 N DATA/
MOUNTED NORMAL N 512 512 4096 4194304 40960 40704 0 20352 0 N DN/
3. 列出相关磁盘
[grid@cs2 ~]$ asmcmd lsdsk -G DN
/dev/asmdisk03
/dev/asmdisk05
从下面的查询可以看到 /dev/asmdisk03 和 /dev/asmdisk05 的 label 字段为空
SQL select group_number,disk_number,name,label,path from v$asm_disk;
GROUP_NUMBER DISK_NUMBER NAME LABEL PATH
------------ ----------- ------------------------------ -------------------------------------------------- --------------------------------------------------
0 0 CRS2 /dev/asmdisk01
0 1 CRS1 /dev/asmdisk02
0 2 DATA1 /dev/asmdisk04
3 0 DN_0000 /dev/asmdisk03
3 1 DN_0001 /dev/asmdisk05
1 0 CRS1 CRS1 AFD:CRS1
2 0 DATA1 DATA1 AFD:DATA1
1 1 CRS2 CRS2 AFD:CRS2
4. 检查 Oracle ASM 是否是活动状态
[grid@cs2 ~]$ srvctl status asm
ASM is running on cs1,cs2
5. 在所有节点上停止数据库与 dismount 磁盘组
[grid@cs2 ~]$srvctl stop diskgroup -diskgroup DN -f
6. 在每个 Hub 节点上执行以下命令来为磁盘组中的所有已经存在的磁盘进行标记
[grid@cs2 ~]$ asmcmd afd_label DN1 /dev/asmdisk03 --migrate
[grid@cs2 ~]$ asmcmd afd_label DN2 /dev/asmdisk05 --migrate
7. 在所有 Hub 节点上扫描磁盘
[grid@cs1 ~]$ asmcmd afd_scan
[grid@cs2 ~]$ asmcmd afd_scan
8. 在所有节点启动数据库并 mount 磁盘组
[grid@cs2 ~]$ srvctl start diskgroup -diskgroup DN
从下面的查询可以看到 /dev/asmdisk03 和 /dev/asmdisk05 的 label 字段分别显示为 DN1 和 DN2
SQL select group_number,disk_number,name,label,path from v$asm_disk;
GROUP_NUMBER DISK_NUMBER NAME LABEL PATH
------------ ----------- ------------------------------ -------------------------------------------------- --------------------------------------------------
0 0 CRS2 /dev/asmdisk01
0 1 DN2 /dev/asmdisk05
0 2 DN1 /dev/asmdisk03
0 3 CRS1 /dev/asmdisk02
0 4 DATA1 /dev/asmdisk04
1 1 CRS2 CRS2 AFD:CRS2
2 0 DATA1 DATA1 AFD:DATA1
1 0 CRS1 CRS1 AFD:CRS1
3 0 DN_0000 DN1 AFD:DN1
3 1 DN_0001 DN2 AFD:DN2
现在可以将原先的 udev rules 文件移除。当然,这要在所有节点中都运行。以后如果服务器再次重启,AFD 就会完全接管了。
[root@cs1 bin]# cd /etc/udev/rules.d/
[root@cs1 rules.d]# ls -lrt
total 16
-rw-r--r--. 1 root root 709 Mar 6 2015 70-persistent-ipoib.rules
-rw-r--r-- 1 root root 1416 Mar 9 12:23 99-my-asmdevices.rules
-rw-r--r-- 1 root root 224 Mar 9 15:52 53-afd.rules
-rw-r--r-- 1 root root 190 Mar 9 15:54 55-usm.rules
[root@cs1 rules.d]# mv 99-my-asmdevices.rules 99-my-asmdevices.rules.bak
[root@cs1 rules.d]# cat 53-afd.rules
# AFD devices
KERNEL== oracleafd/.* , OWNER= grid , GROUP= asmadmin , MODE= 0775
KERNEL== oracleafd/* , OWNER= grid , GROUP= asmadmin , MODE= 0775
KERNEL== oracleafd/disks/* , OWNER= grid , GROUP= asmadmin , MODE= 0664
[root@cs1 rules.d]# ls -l /dev/oracleafd/disks
total 20
-rwxrwx--- 1 grid oinstall 15 Aug 30 14:30 CRS1
-rwxrwx--- 1 grid oinstall 15 Aug 30 14:30 CRS2
-rwxrwx--- 1 grid oinstall 15 Aug 30 14:30 DATA1
-rwxrwx--- 1 grid oinstall 15 Aug 30 17:42 DN1
-rwxrwx--- 1 grid oinstall 15 Aug 30 17:42 DN2
[root@cs2 bin]# cd /etc/udev/rules.d/
[root@cs2 rules.d]# ls -lrt
total 16
-rw-r--r--. 1 root root 709 Mar 6 2015 70-persistent-ipoib.rules
-rw-r--r-- 1 root root 1416 Mar 9 12:23 99-my-asmdevices.rules
-rw-r--r-- 1 root root 224 Mar 9 15:52 53-afd.rules
-rw-r--r-- 1 root root 190 Mar 9 15:54 55-usm.rules
[root@cs2 rules.d]# mv 99-my-asmdevices.rules 99-my-asmdevices.rules.bak
[root@cs2 rules.d]# cat 53-afd.rules
# AFD devices
KERNEL== oracleafd/.* , OWNER= grid , GROUP= asmadmin , MODE= 0775
KERNEL== oracleafd/* , OWNER= grid , GROUP= asmadmin , MODE= 0775
KERNEL== oracleafd/disks/* , OWNER= grid , GROUP= asmadmin , MODE= 0664
[root@cs2 rules.d]# ls -l /dev/oracleafd/disks
total 20
-rwxrwx--- 1 grid oinstall 15 Aug 30 14:30 CRS1
-rwxrwx--- 1 grid oinstall 15 Aug 30 14:30 CRS2
-rwxrwx--- 1 grid oinstall 15 Aug 30 14:30 DATA1
-rwxrwx--- 1 grid oinstall 15 Aug 30 17:42 DN1
-rwxrwx--- 1 grid oinstall 15 Aug 30 17:42 DN2
其实,AFD 也在使用 udev
迁移包含 OCR 或 vote 文件的磁盘组到 Oracle ASMFD
1. 以 root 用户来列出包含 OCR 和 vote 文件的磁盘组
[root@cs1 ~]# cd /u01/app/product/12.2.0/crs/bin
[root@cs1 bin]# sh ocrcheck -config
Oracle Cluster Registry configuration is :
Device/File Name : +CRS
Device/File Name : +DATA
[root@cs1 bin]# sh crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE 750a78e1ae984fcdbfb4dbf44d337a77 (/dev/asmdisk02) [CRS]
Located 1 voting disk(s).
2. 以 Oracle Grid Infrastructure 用户来列出与磁盘组相关的磁盘
[grid@cs2 ~]$ asmcmd lsdsk -G CRS
/dev/asmdisk01
/dev/asmdisk02
3. 以 root 用户来在所有节点上停止数据库与 Oracle Clusterware
[root@cs1 bin]# ./crsctl stop cluster -all
CRS-2673: Attempting to stop ora.crsd on cs2
CRS-2673: Attempting to stop ora.crsd on cs1
CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on server cs2
CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on server cs1
CRS-2673: Attempting to stop ora.cs.db on cs1
CRS-2673: Attempting to stop ora.qosmserver on cs2
CRS-2673: Attempting to stop ora.cs.db on cs2
CRS-2673: Attempting to stop ora.chad on cs2
CRS-2673: Attempting to stop ora.gns on cs2
CRS-2677: Stop of ora.gns on cs2 succeeded
CRS-2677: Stop of ora.cs.db on cs2 succeeded
CRS-2673: Attempting to stop ora.CRS.dg on cs2
CRS-2673: Attempting to stop ora.DATA.dg on cs2
CRS-2673: Attempting to stop ora.LISTENER.lsnr on cs2
CRS-2673: Attempting to stop ora.LISTENER_SCAN2.lsnr on cs2
CRS-2673: Attempting to stop ora.LISTENER_SCAN3.lsnr on cs2
CRS-2673: Attempting to stop ora.cvu on cs2
CRS-2673: Attempting to stop ora.gns.vip on cs2
CRS-2677: Stop of ora.cs.db on cs1 succeeded
CRS-2677: Stop of ora.CRS.dg on cs2 succeeded
CRS-2673: Attempting to stop ora.LISTENER.lsnr on cs1
CRS-2673: Attempting to stop ora.LISTENER_SCAN1.lsnr on cs1
CRS-2677: Stop of ora.DATA.dg on cs2 succeeded
CRS-2673: Attempting to stop ora.asm on cs2
CRS-2677: Stop of ora.asm on cs2 succeeded
CRS-2677: Stop of ora.LISTENER.lsnr on cs1 succeeded
CRS-2673: Attempting to stop ora.ASMNET1LSNR_ASM.lsnr on cs2
CRS-2677: Stop of ora.LISTENER_SCAN1.lsnr on cs1 succeeded
CRS-2673: Attempting to stop ora.scan1.vip on cs1
CRS-2677: Stop of ora.LISTENER.lsnr on cs2 succeeded
CRS-2677: Stop of ora.LISTENER_SCAN3.lsnr on cs2 succeeded
CRS-2677: Stop of ora.LISTENER_SCAN2.lsnr on cs2 succeeded
CRS-2677: Stop of ora.scan1.vip on cs1 succeeded
CRS-2673: Attempting to stop ora.cs2.vip on cs2
CRS-2673: Attempting to stop ora.scan2.vip on cs2
CRS-2673: Attempting to stop ora.scan3.vip on cs2
CRS-2677: Stop of ora.gns.vip on cs2 succeeded
CRS-2677: Stop of ora.scan3.vip on cs2 succeeded
CRS-2677: Stop of ora.cs2.vip on cs2 succeeded
CRS-2677: Stop of ora.qosmserver on cs2 succeeded
CRS-2677: Stop of ora.scan2.vip on cs2 succeeded
CRS-2677: Stop of ora.ASMNET1LSNR_ASM.lsnr on cs2 succeeded
CRS-2673: Attempting to stop ora.chad on cs1
CRS-2677: Stop of ora.cvu on cs2 succeeded
CRS-2677: Stop of ora.chad on cs2 succeeded
CRS-2673: Attempting to stop ora.ons on cs2
CRS-2677: Stop of ora.ons on cs2 succeeded
CRS-2673: Attempting to stop ora.net1.network on cs2
CRS-2677: Stop of ora.net1.network on cs2 succeeded
CRS-2792: Shutdown of Cluster Ready Services-managed resources on cs2 has completed
CRS-2677: Stop of ora.crsd on cs2 succeeded
CRS-2673: Attempting to stop ora.ctssd on cs2
CRS-2673: Attempting to stop ora.evmd on cs2
CRS-2673: Attempting to stop ora.storage on cs2
CRS-2677: Stop of ora.storage on cs2 succeeded
CRS-2673: Attempting to stop ora.asm on cs2
CRS-2677: Stop of ora.ctssd on cs2 succeeded
CRS-2677: Stop of ora.evmd on cs2 succeeded
CRS-2677: Stop of ora.chad on cs1 succeeded
CRS-2673: Attempting to stop ora.mgmtdb on cs1
CRS-2677: Stop of ora.mgmtdb on cs1 succeeded
CRS-2673: Attempting to stop ora.MGMTLSNR on cs1
CRS-2673: Attempting to stop ora.CRS.dg on cs1
CRS-2673: Attempting to stop ora.DATA.dg on cs1
CRS-2677: Stop of ora.CRS.dg on cs1 succeeded
CRS-2677: Stop of ora.DATA.dg on cs1 succeeded
CRS-2673: Attempting to stop ora.asm on cs1
CRS-2677: Stop of ora.MGMTLSNR on cs1 succeeded
CRS-2673: Attempting to stop ora.cs1.vip on cs1
CRS-2677: Stop of ora.cs1.vip on cs1 succeeded
CRS-2677: Stop of ora.asm on cs2 succeeded
CRS-2673: Attempting to stop ora.cluster_interconnect.haip on cs2
CRS-2677: Stop of ora.cluster_interconnect.haip on cs2 succeeded
CRS-2673: Attempting to stop ora.cssd on cs2
CRS-2677: Stop of ora.cssd on cs2 succeeded
CRS-2677: Stop of ora.asm on cs1 succeeded
CRS-2673: Attempting to stop ora.ASMNET1LSNR_ASM.lsnr on cs1
CRS-2677: Stop of ora.ASMNET1LSNR_ASM.lsnr on cs1 succeeded
CRS-2673: Attempting to stop ora.ons on cs1
CRS-2677: Stop of ora.ons on cs1 succeeded
CRS-2673: Attempting to stop ora.net1.network on cs1
CRS-2677: Stop of ora.net1.network on cs1 succeeded
CRS-2792: Shutdown of Cluster Ready Services-managed resources on cs1 has completed
CRS-2677: Stop of ora.crsd on cs1 succeeded
CRS-2673: Attempting to stop ora.ctssd on cs1
CRS-2673: Attempting to stop ora.evmd on cs1
CRS-2673: Attempting to stop ora.storage on cs1
CRS-2677: Stop of ora.storage on cs1 succeeded
CRS-2673: Attempting to stop ora.asm on cs1
CRS-2677: Stop of ora.ctssd on cs1 succeeded
CRS-2677: Stop of ora.evmd on cs1 succeeded
CRS-2677: Stop of ora.asm on cs1 succeeded
CRS-2673: Attempting to stop ora.cluster_interconnect.haip on cs1
CRS-2677: Stop of ora.cluster_interconnect.haip on cs1 succeeded
CRS-2673: Attempting to stop ora.cssd on cs1
CRS-2677: Stop of ora.cssd on cs1 succeeded
4. 以 Oracle Grid Infrastructure 用户来执行下面的命令为每个 Hub 节点上的磁盘组中的磁盘进行标记
[grid@cs2 ~]$ asmcmd afd_label DN1 /dev/asmdisk03
[grid@cs2 ~]$ asmcmd afd_label DN2 /dev/asmdisk05
5. 以 Oracle Grid Infrastructure 用户来执行下面的命令对每个 Hub 节点进行磁盘重新扫描
[grid@cs1 ~]$ asmcmd afd_scan
[grid@cs2 ~]$ asmcmd afd_scan
6. 以 root 用户来在所有节点上启用 Oracle Clusterware stack 并 mount OCR 与 vote 文件磁盘与数据库
[root@cs1 bin]# ./crsctl start cluster -all
CRS-2672: Attempting to start ora.cssdmonitor on cs1
CRS-2672: Attempting to start ora.evmd on cs1
CRS-2672: Attempting to start ora.cssdmonitor on cs2
CRS-2672: Attempting to start ora.evmd on cs2
CRS-2676: Start of ora.cssdmonitor on cs1 succeeded
CRS-2672: Attempting to start ora.cssd on cs1
CRS-2672: Attempting to start ora.diskmon on cs1
CRS-2676: Start of ora.diskmon on cs1 succeeded
CRS-2676: Start of ora.evmd on cs1 succeeded
CRS-2676: Start of ora.cssdmonitor on cs2 succeeded
CRS-2672: Attempting to start ora.cssd on cs2
CRS-2672: Attempting to start ora.diskmon on cs2
CRS-2676: Start of ora.diskmon on cs2 succeeded
CRS-2676: Start of ora.evmd on cs2 succeeded
CRS-2676: Start of ora.cssd on cs1 succeeded
CRS-2672: Attempting to start ora.ctssd on cs1
CRS-2672: Attempting to start ora.cluster_interconnect.haip on cs1
CRS-2676: Start of ora.cssd on cs2 succeeded
CRS-2672: Attempting to start ora.ctssd on cs2
CRS-2672: Attempting to start ora.cluster_interconnect.haip on cs2
CRS-2676: Start of ora.ctssd on cs1 succeeded
CRS-2676: Start of ora.ctssd on cs2 succeeded
CRS-2676: Start of ora.cluster_interconnect.haip on cs1 succeeded
CRS-2672: Attempting to start ora.asm on cs1
CRS-2676: Start of ora.cluster_interconnect.haip on cs2 succeeded
CRS-2672: Attempting to start ora.asm on cs2
CRS-2676: Start of ora.asm on cs2 succeeded
CRS-2672: Attempting to start ora.storage on cs2
CRS-2676: Start of ora.asm on cs1 succeeded
CRS-2672: Attempting to start ora.storage on cs1
CRS-2676: Start of ora.storage on cs1 succeeded
CRS-2672: Attempting to start ora.crsd on cs1
CRS-2676: Start of ora.crsd on cs1 succeeded
CRS-2676: Start of ora.storage on cs2 succeeded
CRS-2672: Attempting to start ora.crsd on cs2
CRS-2676: Start of ora.crsd on cs2 succeeded
判断 Oracle ASM Filter Driver 是否已经配置
可以通过判断 Oracle ASM 实例的 SYS_ASMFD_PROPERTIES 的 AFD_STATE 参数值来判断 Oracle ASMFD 是否被配置。也可以使用 ASMCMD afd_state 命令来检查 Oracle ASMFD 的状态
[grid@cs1 ~]$ asmcmd afd_state
ASMCMD-9526: The AFD state is LOADED and filtering is DISABLED on host cs1.jy.net
[grid@cs2 ~]$ asmcmd afd_state
ASMCMD-9526: The AFD state is LOADED and filtering is ENABLED on host cs2.jy.net
下面的查询如果 AFD_STATE 参数值等于 NOT AVAILABLE 就表示 Oracle ASMFD 没有被配置
SQL select sys_context(SYS_ASMFD_PROPERTIES , AFD_STATE) from dual;
SYS_CONTEXT(SYS_ASMFD_PROPERTIES , AFD_STATE)
---------------------------------------------------------------------------
CONFIGURED
设置 Oracle ASM Filter Driver 的 AFD_DISKSTRING 参数
AFD_DISKSTRING 参数来指定 Oracle ASMFD 磁盘发现路径来标识由 Oracle ASMFD 来管理的磁盘。也可以使用 ASMCMD afd_dsset 和 afd_dsget 命令来设置和显示 AFD_DISKSTRING 参数:
[grid@cs1 ~]$ asmcmd afd_dsset /dev/sd* , /dev/asm* , AFD:*
[grid@cs2 ~]$ asmcmd afd_dsset /dev/sd* , /dev/asm* , AFD:*
[grid@cs1 ~]$ asmcmd dsget
parameter:dev/sd*, /dev/asm*, AFD:*
profile:dev/sd*,/dev/asm*,AFD:*
[grid@cs2 ~]$ asmcmd dsget
parameter:dev/sd*, /dev/asm*, AFD:*
profile:dev/sd*,/dev/asm*,AFD:*
可以使用 alter system 语句来设置 AFD_DISKSTRING。标识已经被创建在磁盘头中通过 Oracle ASMFD 磁盘发现路径来识别磁盘
SQL ALTER SYSTEM AFD_DISKSTRING SET dev/sd* , /dev/asm* , AFD:*
System altered.
SQL SELECT SYS_CONTEXT(SYS_ASMFD_PROPERTIES , AFD_DISKSTRING) FROM DUAL;
SYS_CONTEXT(SYS_ASMFD_PROPERTIES , AFD_DISKSTRING)
-----------------------------------------------------------------------------------
dev/sd*,/dev/asm*,AFD:*
为 Oracle ASM Filter Driver 磁盘设置 Oracle ASM ASM_DISKSTRING 参数
可以更新 Oracle ASM 磁盘发现路径来增加或删除 Oracle ASMFD 磁盘标识名到 ASM_DISKSTRING 参数,可以使用 alter system 语句或 asmcmd dsset 命令
SQL show parameter asm_diskstring
NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
asm_diskstring string dev/sd*, /dev/asm*, AFD:*
[grid@cs1 ~]$ asmcmd dsset dev/sd* , /dev/asm*
, AFD:*
[grid@cs2 ~]$ asmcmd dsset dev/sd* , /dev/asm* , AFD:*
测试 Filter 功能
首先检查 filter 功能是否开启
[grid@cs1 ~]$ asmcmd afd_state
ASMCMD-9526: The AFD state is LOADED and filtering is ENABLED on host cs1.jy.net
[grid@jytest1 ~]$ asmcmd afd_lsdsk
--------------------------------------------------------------------------------
Label Filtering Path
================================================================================
CRS1 ENABLED /dev/asmdisk02
CRS2 ENABLED /dev/asmdisk01
DATA1 ENABLED /dev/asmdisk03
DATA2 ENABLED /dev/asmdisk04
FRA1 ENABLED /dev/asmdisk07
TEST1 ENABLED /dev/asmdisk05
TEST2 ENABLED /dev/asmdisk06
上面的结果显示 filter 功能已经开启,如果要禁用 filter 功能执行 asmcmd afd_filter -d
[grid@cs1 ~]$ asmcmd afd_filter -d
[grid@cs1 ~]$ asmcmd afd_state
ASMCMD-9526: The AFD state is LOADED and filtering is ENABLED on host jytest1.jydba.net
[grid@cs1 ~]$ asmcmd afd_lsdsk
There are no labelled devices.
如果要开启 filter 功能执行 asmcmd afd_filter -e
[grid@jytest1 ~]$ asmcmd afd_lsdsk
--------------------------------------------------------------------------------
Label Filtering Path
================================================================================
CRS1 ENABLED /dev/asmdisk02
CRS2 ENABLED /dev/asmdisk01
DATA1 ENABLED /dev/asmdisk03
DATA2 ENABLED /dev/asmdisk04
FRA1 ENABLED /dev/asmdisk07
TEST1 ENABLED /dev/asmdisk05
TEST2 ENABLED /dev/asmdisk06
先用 KFED 读取一下 TEST 磁盘组的 AFD:TEST1 的磁盘头,验证一下确实无误
[grid@jytest1 ~]$ kfed read AFD:TEST1
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD
kfbh.datfmt: 1 ; 0x003: 0x01
kfbh.block.blk: 0 ; 0x004: blk=0
kfbh.block.obj: 2147483648 ; 0x008: disk=0
kfbh.check: 3275580027 ; 0x00c: 0xc33d627b
kfbh.fcn.base: 0 ; 0x010: 0x00000000
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfdhdb.driver.provstr: ORCLDISKTEST1 ; 0x000: length=13
kfdhdb.driver.reserved[0]: 1414743380 ; 0x008: 0x54534554
kfdhdb.driver.reserved[1]: 49 ; 0x00c: 0x00000031
kfdhdb.driver.reserved[2]: 0 ; 0x010: 0x00000000
kfdhdb.driver.reserved[3]: 0 ; 0x014: 0x00000000
kfdhdb.driver.reserved[4]: 0 ; 0x018: 0x00000000
kfdhdb.driver.reserved[5]: 0 ; 0x01c: 0x00000000
kfdhdb.compat: 203424000 ; 0x020: 0x0c200100
kfdhdb.dsknum: 0 ; 0x024: 0x0000
kfdhdb.grptyp: 2 ; 0x026: KFDGTP_NORMAL
kfdhdb.hdrsts: 3 ; 0x027: KFDHDR_MEMBER
kfdhdb.dskname: TEST1 ; 0x028: length=5
kfdhdb.grpname: TEST ; 0x048: length=4
kfdhdb.fgname: TEST1 ; 0x068: length=5
kfdhdb.fgname: DN1 ; 0x068: length=3
下面直接用 dd 尝试将磁盘头清零。dd 命令本身没有任何错误返回。
[root@cs1 ~]# dd if=/dev/zero of=/dev/asmdisk03 bs=1024 count=10000
10000+0 records in
10000+0 records out
10240000 bytes (10 MB) copied, 1.24936 s, 8.2 MB/s
备份磁盘的前 1024 字节并清除,普通用户没权限读
[root@jytest1 ~]# dd if=/dev/asmdisk05 of=asmdisk05_header bs=1024 count=1
1+0 records in
1+0 records out
1024 bytes (1.0 kB) copied, 0.000282638 s, 3.6 MB/s
[root@jytest1 ~]# ls -lrt
-rw-r--r-- 1 root root 1024 Aug 31 01:22 asmdisk05_header
[root@jytest1 ~]# dd if=/dev/zero of=/dev/asmdisk05 bs=1024 count=1
1+0 records in
1+0 records out
1024 bytes (1.0 kB) copied, 0.000318516 s, 3.2 MB/s
再用 KFED 读取一下 TEST 磁盘组的 AFD:TEST1 的磁盘头,验证一下确实无误
[grid@jytest1 ~]$ kfed read AFD:TEST1
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD
kfbh.datfmt: 1 ; 0x003: 0x01
kfbh.block.blk: 0 ; 0x004: blk=0
kfbh.block.obj: 2147483648 ; 0x008: disk=0
kfbh.check: 3275580027 ; 0x00c: 0xc33d627b
kfbh.fcn.base: 0 ; 0x010: 0x00000000
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfdhdb.driver.provstr: ORCLDISKTEST1 ; 0x000: length=13
kfdhdb.driver.reserved[0]: 1414743380 ; 0x008: 0x54534554
kfdhdb.driver.reserved[1]: 49 ; 0x00c: 0x00000031
kfdhdb.driver.reserved[2]: 0 ; 0x010: 0x00000000
kfdhdb.driver.reserved[3]: 0 ; 0x014: 0x00000000
kfdhdb.driver.reserved[4]: 0 ; 0x018: 0x00000000
kfdhdb.driver.reserved[5]: 0 ; 0x01c: 0x00000000
kfdhdb.compat: 203424000 ; 0x020: 0x0c200100
kfdhdb.dsknum: 0 ; 0x024: 0x0000
kfdhdb.grptyp: 2 ; 0x026: KFDGTP_NORMAL
kfdhdb.hdrsts: 3 ; 0x027: KFDHDR_MEMBER
kfdhdb.dskname: TEST1 ; 0x028: length=5
kfdhdb.grpname: TEST ; 0x048: length=4
kfdhdb.fgname: TEST1 ; 0x068: length=5
测试 dismount 磁盘组 TEST,再 mount 磁盘组 TEST 都能成功
[grid@jytest1 ~]$ asmcmd umount TEST
[grid@jytest1 ~]$ asmcmd lsdg
State Type Rebal Sector Logical_Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED EXTERN N 512 512 4096 4194304 40960 264 0 264 0 Y CRS/
MOUNTED EXTERN N 512 512 4096 4194304 40960 24732 0 24732 0 N DATA/
MOUNTED EXTERN N 512 512 4096 4194304 40960 18452 0 18452 0 N FRA/
[grid@jytest1 ~]$ asmcmd mount TEST
[grid@jytest1 ~]$ asmcmd lsdg
State Type Rebal Sector Logical_Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED EXTERN N 512 512 4096 4194304 40960 264 0 264 0 Y CRS/
MOUNTED EXTERN N 512 512 4096 4194304 40960 24732 0 24732 0 N DATA/
MOUNTED EXTERN N 512 512 4096 4194304 40960 18452 0 18452 0 N FRA/
MOUNTED NORMAL N 512 512 4096 4194304 40960 11128 0 5564 0 N TEST/
现在对磁盘 /dev/asmdisk05 禁用 filter 功能
[grid@jytest1 ~]$ asmcmd afd_lsdsk
--------------------------------------------------------------------------------
Label Filtering Path
================================================================================
CRS1 ENABLED /dev/asmdisk02
CRS2 ENABLED /dev/asmdisk01
DATA1 ENABLED /dev/asmdisk03
DATA2 ENABLED /dev/asmdisk04
FRA1 ENABLED /dev/asmdisk07
TEST1 ENABLED /dev/asmdisk05
TEST2 ENABLED /dev/asmdisk06
[grid@jytest1 ~]$ asmcmd afd_filter -d /dev/asmdisk05
[grid@jytest1 ~]$ asmcmd afd_lsdsk
--------------------------------------------------------------------------------
Label Filtering Path
================================================================================
CRS1 ENABLED /dev/asmdisk02
CRS2 ENABLED /dev/asmdisk01
DATA1 ENABLED /dev/asmdisk03
DATA2 ENABLED /dev/asmdisk04
FRA1 ENABLED /dev/asmdisk07
TEST1 DISABLED /dev/asmdisk05
TEST2 ENABLED /dev/asmdisk06
清除磁盘的前 1024 字节
[root@jytest1 ~]# dd if=/dev/zero of=/dev/asmdisk05 bs=1024 count=1
1+0 records in
1+0 records out
1024 bytes (1.0 kB) copied, 0.000318516 s, 3.2 MB/s
[grid@jytest1 ~]$ asmcmd umount TEST
[grid@jytest1 ~]$ asmcmd mount TEST
ORA-15032: not all alterations performed
ORA-15017: diskgroup TEST cannot be mounted
ORA-15040: diskgroup is incomplete (DBD ERROR: OCIStmtExecute)
[grid@jytest1 ~]$ kfed read AFD:TEST1
kfbh.endian: 0 ; 0x000: 0x00
kfbh.hard: 0 ; 0x001: 0x00
kfbh.type: 0 ; 0x002: KFBTYP_INVALID
kfbh.datfmt: 0 ; 0x003: 0x00
kfbh.block.blk: 0 ; 0x004: blk=0
kfbh.block.obj: 0 ; 0x008: file=0
kfbh.check: 0 ; 0x00c: 0x00000000
kfbh.fcn.base: 0 ; 0x010: 0x00000000
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
000000000 00000000 00000000 00000000 00000000 [................]
Repeat 255 times
KFED-00322: invalid content encountered during block traversal: [kfbtTraverseBlock][Invalid OSM block type][][0]
可以看到当 filter 功能被禁用时就失去了保护功能
使用之前备份的磁盘前 1024 字节信息来恢复磁盘头
[root@jytest1 ~]# dd if=asmdisk05_header of=/dev/asmdisk05 bs=1024 count=1
1+0 records in
1+0 records out
1024 bytes (1.0 kB) copied, 0.000274822 s, 3.7 MB/s
[grid@jytest1 ~]$ kfed read /dev/asmdisk05
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD
kfbh.datfmt: 1 ; 0x003: 0x01
kfbh.block.blk: 0 ; 0x004: blk=0
kfbh.block.obj: 2147483648 ; 0x008: disk=0
kfbh.check: 1645917758 ; 0x00c: 0x621ab63e
kfbh.fcn.base: 0 ; 0x010: 0x00000000
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfdhdb.driver.provstr: ORCLDISKTEST1 ; 0x000: length=13
kfdhdb.driver.reserved[0]: 1414743380 ; 0x008: 0x54534554
kfdhdb.driver.reserved[1]: 49 ; 0x00c: 0x00000031
kfdhdb.driver.reserved[2]: 0 ; 0x010: 0x00000000
kfdhdb.driver.reserved[3]: 0 ; 0x014: 0x00000000
kfdhdb.driver.reserved[4]: 0 ; 0x018: 0x00000000
kfdhdb.driver.reserved[5]: 0 ; 0x01c: 0x00000000
kfdhdb.compat: 203424000 ; 0x020: 0x0c200100
kfdhdb.dsknum: 0 ; 0x024: 0x0000
kfdhdb.grptyp: 2 ; 0x026: KFDGTP_NORMAL
kfdhdb.hdrsts: 3 ; 0x027: KFDHDR_MEMBER
kfdhdb.dskname: TEST1 ; 0x028: length=5
kfdhdb.grpname: TEST ; 0x048: length=4
kfdhdb.fgname: TEST1 ; 0x068: length=5
再次 mount 磁盘组 TEST
[grid@jytest1 ~]$ asmcmd lsdg
State Type Rebal Sector Logical_Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED EXTERN N 512 512 4096 4194304 40960 264 0 264 0 Y CRS/
MOUNTED EXTERN N 512 512 4096 4194304 40960 24732 0 24732 0 N DATA/
MOUNTED EXTERN N 512 512 4096 4194304 40960 18452 0 18452 0 N FRA/
[grid@jytest1 ~]$ asmcmd mount TEST
[grid@jytest1 ~]$ asmcmd lsdg
State Type Rebal Sector Logical_Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED EXTERN N 512 512 4096 4194304 40960 264 0 264 0 Y CRS/
MOUNTED EXTERN N 512 512 4096 4194304 40960 24732 0 24732 0 N DATA/
MOUNTED EXTERN N 512 512 4096 4194304 40960 18452 0 18452 0 N FRA/
MOUNTED NORMAL N 512 512 4096 4194304 40960 11120 0 5560 0 N TEST/
设置,清除与扫描 Oracle ASM Filter Driver Labels
给由 Oracle ASMFD 管理的磁盘设置一个标识,在标识设置后,指定的磁盘将会由 Oracle ASMFD 来管理。可以使用 ASMCMD afd_label,afd_unlabel 与 afd_scan 来增加,删除和扫描标识查看已经标识过的磁盘可以看到磁盘 /dev/asmdisk03 和 /dev/asmdisk05 没有被标识。
[grid@cs1 ~]$ asmcmd afd_lsdsk
--------------------------------------------------------------------------------
Label Filtering Path
================================================================================
CRS1 ENABLED /dev/asmdisk02
CRS2 ENABLED /dev/asmdisk01
DATA1 ENABLED /dev/asmdisk04
SQL select group_number,disk_number,name,label,path from v$asm_disk;
GROUP_NUMBER DISK_NUMBER NAME LABEL PATH
------------ ----------- ------------------------------ -------------------------------------------------- --------------------------------------------------
0 0 CRS1 AFD:CRS1
0 1 /dev/asmdisk05
0 2 DATA1 AFD:DATA1
0 3 /dev/asmdisk03
0 4 CRS2 AFD:CRS2
1 0 CRS1 CRS1 /dev/asmdisk02
1 1 CRS2 CRS2 /dev/asmdisk01
2 0 DATA1 DATA1 /dev/asmdisk04
设置标识
[grid@cs2 ~]$ asmcmd afd_label DN1 /dev/asmdisk03
[grid@cs2 ~]$ asmcmd afd_label DN2 /dev/asmdisk05
查看已经标识过的磁盘可以看到磁盘 /dev/asmdisk03 和 /dev/asmdisk05 已经被标识
[grid@cs1 ~]$ asmcmd afd_lsdsk
--------------------------------------------------------------------------------
Label Filtering Path
================================================================================
CRS1 ENABLED /dev/asmdisk02
CRS2 ENABLED /dev/asmdisk01
DATA1 ENABLED /dev/asmdisk04
DN1 ENABLED /dev/asmdisk03
DN2 ENABLED /dev/asmdisk05
SQL select group_number,disk_number,name,label,path from v$asm_disk;
GROUP_NUMBER DISK_NUMBER NAME LABEL PATH
------------ ----------- ------------------------------ -------------------------------------------------------------- --------------------------------------------------
0 0 CRS1 AFD:CRS1
0 1 DN2 /dev/asmdisk05
0 2 DN1 AFD:DN1
0 3 DATA1 AFD:DATA1
0 4 DN1 /dev/asmdisk03
0 6 CRS2 AFD:CRS2
0 5 DN2 AFD:DN2
1 1 CRS2 CRS2 /dev/asmdisk01
1 0 CRS1 CRS1 /dev/asmdisk02
2 0 DATA1 DATA1 /dev/asmdisk04
清除标识
[grid@cs1 ~]$ asmcmd afd_unlabel DN1
[grid@cs1 ~]$ asmcmd afd_unlabel DN2
注意在清除标识时,如果标识所标记的磁盘已经用来创建磁盘组了那么是不能清除的,例如
[grid@cs1 ~]$ asmcmd afd_unlabel TEST1
disk AFD:TEST1 is already provisioned for ASM
No devices to be unlabeled.
ASMCMD-9514: ASM disk label clear operation failed.
扫描标识
[grid@cs1 ~]$ asmcmd afd_scan
查看已经标识过的磁盘可以看到 /dev/asmdisk03 和 /dev/asmdisk05 的标识已经清除了
[grid@cs1 ~]$ asmcmd afd_lsdsk
--------------------------------------------------------------------------------
Label Filtering Path
================================================================================
CRS1 ENABLED /dev/asmdisk02
CRS2 ENABLED /dev/asmdisk01
DATA1 ENABLED /dev/asmdisk04
SQL select group_number,disk_number,name,label,path from v$asm_disk;
GROUP_NUMBER DISK_NUMBER NAME LABEL PATH
------------ ----------- ------------------------------ -------------------------------------------------------------- --------------------------------------------------
0 0 CRS1 AFD:CRS1
0 1 /dev/asmdisk05
0 2 DATA1 AFD:DATA1
0 3 /dev/asmdisk03
0 4 CRS2 AFD:CRS2
1 1 CRS2 CRS2 /dev/asmdisk01
1 0 CRS1 CRS1 /dev/asmdisk02
2 0 DATA1 DATA1 /dev/asmdisk04
到此,相信大家对“Oracle ASM Filter Driver 的相关知识点有哪些”有了更深的了解,不妨来实际操作一番吧!这里是丸趣 TV 网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!