代码改变世界

实验:利用ASMLib创建ASM磁盘

2018-04-25 00:39 AlfredZhao 阅读(...) 评论(...) 编辑 收藏

环境:RHEL 6.5 + Oracle 11.2.0.4 RAC(2 nodes)
目的:在实验环境使用ASMLib配置共享ASM磁盘,虽然我们已经不建议使用ASMLib进行绑盘,但是无奈有客户是这样做的,而作为一名合格的乙方技术人员,我们是需要熟悉不同技术(包括这种已经不再推荐使用的技术)从而更好的为甲方服务。

1.安装ASMLib相关包

安装ASMLib一共需要3个rpm包,分别是kmod-oracleasm,oracleasmlib和oracleasm-support,注意选择合适的版本安装,比如我这里环境:

[root@jystdrac1 tmp]# rpm -ivh oracleasm-support-2.1.8-1.el6.x86_64.rpm 
warning: oracleasm-support-2.1.8-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing...                ########################################### [100%]
   1:oracleasm-support      ########################################### [100%]
[root@jystdrac1 tmp]# rpm -ivh kmod-oracleasm-2.0.6.rh1-3.el6_5.x86_64.rpm 
warning: kmod-oracleasm-2.0.6.rh1-3.el6_5.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:kmod-oracleasm         ########################################### [100%]
[root@jystdrac1 tmp]# rpm -ivh oracleasmlib-2.0.4-1.el6.x86_64.rpm 
warning: oracleasmlib-2.0.4-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing...                ########################################### [100%]
   1:oracleasmlib           ########################################### [100%]
[root@jystdrac1 tmp]# 

节点2用同样的步骤安装这三个rpm软件包,不再赘述。

2.配置ASMLib

2.1 ASMLib的配置如下:

[root@jystdrac1 ~]# /etc/init.d/oracleasm configure
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 [asmadmin]: 
Start Oracle ASM library driver on boot (y/n) [y]: 
Scan for Oracle ASM disks on boot (y/n) [y]: 
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver: [  OK  ]
Scanning the system for Oracle ASMLib disks: 
[  OK  ]

--节点2同样:
[root@jystdrac2 ~]# /etc/init.d/oracleasm configure
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 []: asmadmin
Start Oracle ASM library driver on boot (y/n) [y]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver: [  OK  ]
Scanning the system for Oracle ASMLib disks: [  OK  ]

2.2 使用oracleasm createdisk创建ASM磁盘:

[root@jystdrac1 ~]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
Marking disk "VOL1" as an ASM disk: [  OK  ]
[root@jystdrac1 ~]# /etc/init.d/oracleasm deletedisk VOL1
Removing ASM disk "VOL1": [  OK  ]

--我这里环境有7块盘,ASMLib使用的盘需要分区,每块盘整个分一个区即可:
/etc/init.d/oracleasm createdisk OCR1 /dev/sdb1
/etc/init.d/oracleasm createdisk OCR2 /dev/sdc1
/etc/init.d/oracleasm createdisk OCR3 /dev/sdd1
/etc/init.d/oracleasm createdisk DATA1 /dev/sde1
/etc/init.d/oracleasm createdisk DATA2 /dev/sdf1
/etc/init.d/oracleasm createdisk DATA3 /dev/sdg1
/etc/init.d/oracleasm createdisk FRA1 /dev/sdh1

2.3 使用oracleasm scandisks扫盘然后listdisks列出
/etc/init.d/oracleasm scandisks
/etc/init.d/oracleasm listdisks

[root@jystdrac2 ~]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks: [  OK  ]
[root@jystdrac2 ~]# /etc/init.d/oracleasm listdisks
DATA1
DATA2
DATA3
FRA1
OCR1
OCR2
OCR3
[root@jystdrac2 ~]# 

2.4 使用oracleasm querydisk查询磁盘是否有效
/etc/init.d/oracleasm querydisk

[root@jystdrac2 rules.d]# /etc/init.d/oracleasm querydisk DATA1
Disk "DATA1" is a valid ASM disk

2.5 parted分区的示例
既然ASMLib需要使用分区过的,那就使用parted对每块LUN进行分区,示例如下:

[root@jystdrac1 ~]# parted /dev/sdh
GNU Parted 2.1
Using /dev/sdh
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt                                                      
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdh: 5369MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End  Size  File system  Name  Flags

(parted) mkpart primary 0-1                                               
End? 5369M                                                                
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I                                                          
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdh: 5369MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      17.4kB  5369MB  5369MB               primary

(parted) q                                                                
Information: You may need to update /etc/fstab.    

2.6 oracleasm命令
/etc/init.d/oracleasm {start|stop|restart|enable|disable|configure|createdisk|deletedisk|querydisk|listdisks|scandisks|status}

[root@jystdrac2 ~]# /etc/init.d/oracleasm
Usage: /etc/init.d/oracleasm {start|stop|restart|enable|disable|configure|createdisk|deletedisk|querydisk|listdisks|scandisks|status}
[root@jystdrac2 ~]# /etc/init.d/oracleasm status
Checking if ASM is loaded: yes
Checking if /dev/oracleasm is mounted: yes
[root@jystdrac2 ~]# 

3.安装GI时选择ASM磁盘

diskstrings设置为ORCL:*,正常就可以看到类似下面这样的ASM盘: