当前位置 博文首页 > LuciferLiu_DBA:RHEL7 ASM磁盘的两种绑定方式:UDEV&ASMLIB

    LuciferLiu_DBA:RHEL7 ASM磁盘的两种绑定方式:UDEV&ASMLIB

    作者:[db:作者] 时间:2021-06-16 21:12

    一、UDEV(multipath+UDEV方式配置ASM共享盘)

    1.配置multipath(配置所有节点)

    yum install -y device-mapper*
    mpathconf --enable --with_multipathd y

    Tips:虚拟化配置的磁盘可能看不到UUID输出,需设置参数:disk.EanbleUUID=TRUE才能看到UUID。

    2.查看磁盘UUID

    [root@p19c01 ~]# lsblk
    NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda             8:0    0  100G  0 disk 
    ├─sda1          8:1    0    2G  0 part /boot
    └─sda2          8:2    0   98G  0 part 
      ├─rhel-root 253:0    0   88G  0 lvm  /
      ├─rhel-swap 253:1    0    8G  0 lvm  [SWAP]
      └─rhel-tmp  253:2    0    2G  0 lvm  /tmp
    sdb             8:16   0   50G  0 disk
    sdc             8:32   0   50G  0 disk
    sdd             8:48   0  100G  0 disk
    sr0            11:0    1  4.2G  0 rom  
    
    [root@p19c01 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdb
    36000c2964792e25a77be71f0560fce7a
    [root@p19c01 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdc
    36000c29853ecf85a3f02590985424c9a
    [root@p19c01 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdd
    36000c291e106c0356d6029937b7954b3

    3.配置multipath.conf绑定磁盘(配置所有节点)

    [root@p19c01 ~]# vim /etc/multipath.conf
    
    defaults {
        user_friendly_names yes
    }
    
    blacklist {
    ? devnode "^sda"
    }
     
    multipaths {
    ? multipath {
    ? wwid "36000c2964792e25a77be71f0560fce7a"
    ? alias OCR
    ? }
      multipath {
    ? wwid "36000c29853ecf85a3f02590985424c9a"
    ? alias FRA
    ? }
    ? multipath {
    ? wwid "36000c291e106c0356d6029937b7954b3"
    ? alias DATA
    ? }
    }

    激活多路径conf文件(配置所有节点)

    [root@p19c01 ~]# multipath -v2
    [root@p19c01 ~]# multipath -ll
    FRA (36000c29853ecf85a3f02590985424c9a) dm-4 VMware  ,Virtual disk    
    size=50G features='0' hwhandler='0' wp=rw
    `-+- policy='service-time 0' prio=1 status=active
      `- 2:0:1:0 sdc 8:32 active ready running
    OCR (36000c2964792e25a77be71f0560fce7a) dm-3 VMware  ,Virtual disk    
    size=50G features='0' hwhandler='0' wp=rw
    `-+- policy='service-time 0' prio=1 status=active
      `- 2:0:0:0 sdb 8:16 active ready running
    DATA (36000c291e106c0356d6029937b7954b3) dm-5 VMware  ,Virtual disk    
    size=100G features='0' hwhandler='0' wp=rw
    `-+- policy='service-time 0' prio=1 status=active
      `- 2:0:2:0 sdd 8:48 active ready running
    

    4.获取ENV{DM_UUID}

    cd /dev/mapper
    >udev_info
    for i in `ls OCR FRA DATA`;
    do
    printf "%s %s\n" "$i" "$(udevadm info --query=all --name=/dev/mapper/$i |grep -i dm_uuid)">>udev_info;
    done
    
    --操作记录
    [root@p19c01 ~]# cd /dev/mapper
    [root@p19c01 mapper]# >udev_info
    [root@p19c01 mapper]# for i in `ls OCR FRA DATA`;
    > do
    > printf "%s %s\n" "$i" "$(udevadm info --query=all --name=/dev/mapper/$i |grep -i dm_uuid)">>udev_info;
    > done
    
    [root@p19c01 mapper]# cat udev_info 
    DATA E: DM_UUID=mpath-36000c291e106c0356d6029937b7954b3
    FRA E: DM_UUID=mpath-36000c29853ecf85a3f02590985424c9a
    OCR E: DM_UUID=mpath-36000c2964792e25a77be71f0560fce7a

    5.配置udev规则文件、99-oracle-asmdevices.rules文件(配置所有节点)

    [root@p19c01 ~]# vim /etc/udev/rules.d/99-oracle-asmdevices.rules
    KERNEL=="dm-*",ENV{DM_UUID}=="mpath-36000c2964792e25a77be71f0560fce7a",OWNER="grid",SYMLINK+="asm_ocr",GROUP="asmadmin",MODE="0660"
    KERNEL=="dm-*",ENV{DM_UUID}=="mpath-36000c29853ecf85a3f02590985424c9a",OWNER="grid",SYMLINK+="asm_fra",GROUP="asmadmin",MODE="0660"
    KERNEL=="dm-*",ENV{DM_UUID}=="mpath-36000c291e106c0356d6029937b7954b3",OWNER="grid",SYMLINK+="asm_data",GROUP="asmadmin",MODE="0660"

    6.启动udev服务

    [root@p19c01 ~]# udevadm control --reload-rules
    [root@p19c01 ~]# udevadm trigger

    7.查看udev绑盘是否成功

    [root@p19c01 ~]# ll /dev/asm_*
    lrwxrwxrwx 1 root root 4 2月  25 06:13 /dev/asm_data -> dm-5
    lrwxrwxrwx 1 root root 4 2月  25 06:13 /dev/asm_fra -> dm-4
    lrwxrwxrwx 1 root root 4 2月  25 06:13 /dev/asm_ocr -> dm-3
    

    二、ASMLIB配置ASM共享盘

    1.安装oracleasm(配置所有节点)

    [root@p19c01 ~]# yum install -y kmod-oracleasm
    [root@p19c01 ~]# rpm -ivh oracleasmlib-2.0.12-1.el7.x86_64.rpm?
    [root@p19c01 ~]# rpm -ivh oracleasm-support-2.1.11-2.el7.x86_64.rpm

    Tips:下载路径
    http://public-yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracleasm-support-2.1.11-2.el7.x86_64.rpm
    http://download.oracle.com/otn_software/asmlib/oracleasmlib-2.0.12-1.el7.x86_64.rpm

    2.初始化(配置所有节点)

    [root@p19c01 ~]# oracleasm configure -i
    Configuring the Oracle ASM library driver.
    
    This will configure the on-boot properties of the Oracle ASM library
    driver.  The following questions will determine whether the driver is
    loaded on boot and what permissions it will have.  The current values
    will be shown in brackets ('[]').  Hitting <ENTER> without typing an
    answer will keep that current value.  Ctrl-C will abort.
    
    Default user to own the driver interface []: grid
    Default group to own the driver interface []: oinstall
    Start Oracle ASM library driver on boot (y/n) [n]: y
    Scan for Oracle ASM disks on boot (y/n) [y]: y
    Writing Oracle ASM library driver configuration: done
    

    3.启动oracleasm(配置所有节点)

    [root@p19c01 ~]# oracleasm init
    Loading module "oracleasm": oracleasm
    Configuring "oracleasm" to use device physical block size
    Mounting ASMlib driver filesystem: /dev/oracleasm
    [root@p19c01 ~]# oracleasm status
    Checking if ASM is loaded: yes
    Checking if /dev/oracleasm is mounted: yes

    4.fdisk 分区(配置所有节点)

    [root@p19c01 ~]# lsblk 
    NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda             8:0    0  100G  0 disk 
    ├─sda1          8:1    0    2G  0 part /boot
    └─sda2          8:2    0   98G  0 part 
      ├─rhel-root 253:0    0   88G  0 lvm  /
      ├─rhel-swap 253:1    0    8G  0 lvm  [SWAP]
      └─rhel-tmp  253:2    0    2G  0 lvm  /tmp
    sdb             8:16   0   50G  0 disk 
    sdc             8:32   0   50G  0 disk 
    sdd             8:48   0  100G  0 disk 
    sr0            11:0    1  4.2G  0 rom  
    [root@p19c01 ~]# fdisk /dev/sdb
    欢迎使用 fdisk (util-linux 2.23.2)。
    
    更改将停留在内存中,直到您决定将更改写入磁盘。
    使用写入命令前请三思。
    
    
    命令(输入 m 获取帮助):m
    命令操作
       a   toggle a bootable flag
       b   edit bsd disklabel
       c   toggle the dos compatibility flag
       d   delete a partition
       g   create a new empty GPT partition table
       G   create an IRIX (SGI) partition table
       l   list known partition types
       m   print this menu
       n   add a new partition
       o   create a new empty DOS partition table
       p   print the partition table
       q   quit without saving changes
       s   create a new empty Sun disklabel
       t   change a partitions system id
       u   change display/entry units
       v   verify the partition table
       w   write table to disk and exit
       x   extra functionality (experts only)
    
    命令(输入 m 获取帮助):n
    Partition type:
       p   primary (0 primary, 0 extended, 4 free)
       e   extended
    Select (default p): p
    分区号 (1-4,默认 1):
    起始 扇区 (2048-104857599,默认为 2048):
    将使用默认值 2048
    Last 扇区, +扇区 or +size{K,M,G} (2048-104857599,默认为 104857599):
    将使用默认值 104857599
    分区 1 已设置为 Linux 类型,大小设为 50 GiB
    
    命令(输入 m 获取帮助):w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    正在同步磁盘。
    --/dev/sdc和/dev/sdd同样新建分区
    [root@p19c01 ~]# lsblk 
    NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda             8:0    0  100G  0 disk 
    ├─sda1          8:1    0    2G  0 part /boot
    └─sda2          8:2    0   98G  0 part 
      ├─rhel-root 253:0    0   88G  0 lvm  /
      ├─rhel-swap 253:1    0    8G  0 lvm  [SWAP]
      └─rhel-tmp  253:2    0    2G  0 lvm  /tmp
    sdb             8:16   0   50G  0 disk 
    └─sdb1          8:17   0   50G  0 part 
    sdc             8:32   0   50G  0 disk 
    └─sdc1          8:33   0   50G  0 part 
    sdd             8:48   0  100G  0 disk 
    └─sdd1          8:49   0  100G  0 part 
    sr0            11:0    1  4.2G  0 rom 

    5.创建asm磁盘 (在1节点操作,其他节点执行oracleasm scandisks)

    [root@p19c01 ~]# oracleasm createdisk OCR /dev/sdb1 
    Writing disk header: done
    Instantiating disk: done
    [root@p19c01 ~]# oracleasm createdisk FRA /dev/sdc1 
    Writing disk header: done
    Instantiating disk: done
    [root@p19c01 ~]# oracleasm createdisk DATA /dev/sdd1 
    Writing disk header: done
    Instantiating disk: done
    [root@p19c01 ~]# oracleasm listdisks
    DATA
    FRA
    OCR
    
    [root@p19c02 oracleasm]# oracleasm scandisks
    Reloading disk partitions: done
    Cleaning any stale ASM disks...
    Scanning system for ASM disks...
    Instantiating disk "OCR"
    Instantiating disk "FRA"
    Instantiating disk "DATA"
    
    [root@p19c02 ~]# ll /dev/oracleasm/*
    /dev/oracleasm/disks:
    总用量 0
    brw-rw---- 1 grid oinstall 8, 49 2月  25 06:36 DATA
    brw-rw---- 1 grid oinstall 8, 33 2月  25 06:36 FRA
    brw-rw---- 1 grid oinstall 8, 17 2月  25 06:36 OCR
    

    ?

    ?