本文转载于 http://ylw6006.blog.51cto.com/470441/580568

近日辉总整理了在VMware环境下安装RAC的文档,没有涉及共享存储这层概念,有点美中不足,于是我向前推进一层,使用ISCSI模拟共享存储的盘阵,研究了一翻,整理笔记内容如下,相关脚本来自唐SIR,我狗尾续貂了一把,哈哈…
环境介绍:
服务器端:RHEL5.4 64位, IP地址:192.168.50.7
客户端1: REHL6.0 64位,IP地址:192.168.50.4
客户端2: REHL5.4 64位,IP地址:192.168.50.195
一:服务器端:
首先需要安装scsi-target-utils工具包,然后将tgtd服务设置成开机自动启动,然后划出一个100G的LVM做共享盘阵,LVM的名称为data
[root@rhel5 ~]# yum -y install scsi-target-utils.x86_64
[root@rhel5 ~]# service tgtd start
Starting SCSI target daemon: Starting target framework daemon
[root@rhel5 ~]# chkconfig tgtd on
[root@rhel5 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
data VolGroup00 -wi-ao 100.00G
lv_data VolGroup00 -wi-ao 50.00G
lv_root VolGroup00 -wi-ao 29.28G
oracle10g_1 VolGroup00 -wi-ao 100.00G
每次重启tgtd服务的时候,之前使用tgtdadmin绑定的target和logicalunit都会失效,因而写了个脚本用于简化操作
IQN命名规范:iqn.date. reverse.domain.name:optional name,例如:iqn.2011-06-01.com.766.rac:shareddisk
这里设置允许所有的IP进行进行挂载,取消target绑定的时候需要先取消logicalunit然后取消target
- [root@rhel5 ~]# cat /etc/init.d/tgtdrules
- #!/bin/sh
- # /etc/rc.d/init.d/oracle
- # chkconfig: - 59 85
- # description: oracle10g is meant to run under Linux Oracle Server
- # Source function library.
- . /etc/rc.d/init.d/functions
- start() {
- echo -e "Starting Tgtdrules Server:\n"
- # Target
- tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2011-06-01.com.766.rac:shareddisk
- # Lun
- tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/VolGroup00/data
- # Init
- #tgtadm --lld iscsi --op bind --mode target --tid 1 -I 192.168.50.191
- #tgtadm --lld iscsi --op bind --mode target --tid 1 -I 192.168.50.192
- tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
- }
- stop() {
- echo -e "Stopping Tgtdrules Server:\n"
- # Lun
- tgtadm --lld iscsi --op delete --mode logicalunit --tid 1 --lun 1
- # Target
- tgtadm --lld iscsi --op delete --mode target --tid 1
- # Init
- #tgtadm --lld iscsi --op unbind --mode target --tid 1 -I 192.168.50.191
- #tgtadm --lld iscsi --op unbind --mode target --tid 1 -I 192.168.50.192
- tgtadm --lld iscsi --op unbind --mode target --tid 1 -I ALL
- }
- status() {
- tgtadm --lld iscsi -o show -m target}
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- status
- ;;
- *)
- echo $"Usage: tgtdrules {start|stop|status}"
- ;;
- esac
- exit 0
- 服务器端测试:
- [root@rhel5 ~]# service tgtd status
- tgtd (pid 2943 2942) is running...
- [root@rhel5 ~]# netstat -ntpl |grep :3260
- tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 2942/tgtd
- tcp 0 0 :::3260 :::* LISTEN 2942/tgtd
- [root@rhel5 ~]# service tgtdrules start
- Starting Tgtdrules Server:
- [root@rhel5 ~]# service tgtdrules status
- Target 1: iqn.2011-06-01.com.766.rac:shareddisk
- System information:
- Driver: iscsi
- State: ready
- I_T nexus information:
- I_T nexus: 1
- Initiator: iqn.1994-05.com.redhat:b1beb63e2617
- Connection: 0
- IP Address: 192.168.50.4
- LUN information:
- LUN: 0
- Type: controller
- SCSI ID: IET 00010000
- SCSI SN: beaf10
- Size: 0 MB
- Online: Yes
- Removable media: No
- Backing store type: null
- Backing store path: None
- Backing store flags:
- LUN: 1
- Type: disk
- SCSI ID: IET 00010001
- SCSI SN: beaf11
- Size: 107374 MB
- Online: Yes
- Removable media: No
- Backing store type: rdwr
- Backing store path: /dev/VolGroup00/data
- Backing store flags:
- Account information:
- ACL information:
- ALL
二:客户端,RHEL6和RHEL5.4的配置基本一致,故这里以RHEL6配置为样例,省略RHEL5上的配置
安装iscsi-initiator-utils软件包,设置iscsi进程开机自动启动
[root@rhel6 /]# rpm -qa |grep iscsi
iscsi-initiator-utils-6.2.0.872-10.el6.x86_64
iscsi-initiator-utils-6.2.0.872-10.el6.i686
[root@rhel6 /]# service iscsi start
Starting iscsi: [ OK ]
[root@rhel6 /]# chkconfig iscsi on
[root@rhel6 /]# service iscsi status
No active sessions
自动挂载iscsi脚本内容如下,挂载和卸载之前先发现,探测一次服务器端的共享是否正常
- [root@rhel6 /]# cat /etc/init.d/iscsiadmrules
- #!/bin/bash
- # /etc/rc.d/init.d/oracle
- # chkconfig: - 20 85
- # description: oracle9id is meant to run under Linux Oracle Server
- # Source function library.
- . /etc/rc.d/init.d/functions
- start() {
- echo -e "Starting Iscsiadmrules Server:\n"
- iscsiadm --mode discovery --type sendtargets --portal 192.168.50.7
- iscsiadm --mode node --targetname iqn.2011-06-01.com.766.rac:shareddisk --portal 192.168.50.7:3260 --login
- }
- stop() {
- echo -e "Stopping Iscsiadmrules Server:\n"
- iscsiadm --mode discovery --type sendtargets --portal 192.168.50.7
- iscsiadm --mode node --targetname iqn.2011-06-01.com.766.rac:shareddisk --portal 192.168.50.7:3260 --logout
- }
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- esac
- exit 0
- 挂载并查看状态
- [root@rhel6 /]# service iscsiadmrules start
- Starting Iscsiadmrules Server:
- 192.168.50.7:3260,1 iqn.2011-06-01.com.766.rac:shareddisk
- Logging in to [iface: default, target: iqn.2011-06-01.com.766.rac:shareddisk, portal: 192.168.50.7,3260]
- Login to [iface: default, target: iqn.2011-06-01.com.766.rac:shareddisk, portal: 192.168.50.7,3260] successful.
- [root@rhel6 /]# service iscsi status
- iSCSI Transport Class version 2.0-870
- version 2.0-872
- Target: iqn.2011-06-01.com.766.rac:shareddisk
- Current Portal: 192.168.50.7:3260,1
- Persistent Portal: 192.168.50.7:3260,1
- **********
- Interface:
- **********
- Iface Name: default
- Iface Transport: tcp
- Iface Initiatorname: iqn.1994-05.com.redhat:b1beb63e2617
- Iface IPaddress: 192.168.50.4
- Iface HWaddress: <empty>
- Iface Netdev: <empty>
- SID: 11
- iSCSI Connection State: LOGGED IN
- iSCSI Session State: LOGGED_IN
- Internal iscsid Session State: NO CHANGE
- ************************
- Negotiated iSCSI params:
- ************************
- HeaderDigest: None
- DataDigest: None
- MaxRecvDataSegmentLength: 262144
- MaxXmitDataSegmentLength: 8192
- FirstBurstLength: 65536
- MaxBurstLength: 262144
- ImmediateData: Yes
- InitialR2T: Yes
- MaxOutstandingR2T: 1
- ************************
- Attached SCSI devices:
- ************************
- Host Number: 18 State: running
- scsi18 Channel 00 Id 0 Lun: 0
- scsi18 Channel 00 Id 0 Lun: 1
- Attached scsi disk sdb State: running
三:验证共享存储是否正常
- RHEL6
- [root@rhel6 /]# fdisk -l
- Disk /dev/sda: 160.0 GB, 160041885696 bytes
- 255 heads, 63 sectors/track, 19457 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 512 bytes
- Disk identifier: 0x00080dc2
- Device Boot Start End Blocks Id System
- /dev/sda1 * 1 13 102400 83 Linux
- /dev/sda2 13 523 4096000 82 Linux swap / Solaris
- /dev/sda3 523 778 2048000 83 Linux
- /dev/sda4 778 19458 150042624 5 Extended
- /dev/sda5 778 19458 150041600 8e Linux LVM
- Disk /dev/sdb: 107.4 GB, 107374182400 bytes
- 255 heads, 63 sectors/track, 13054 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 512 bytes
- Disk identifier: 0x00000000
- Disk /dev/sdb doesn't contain a valid partition table
- [root@rhel6 /]# service iscsiadmrules stop
- Stopping Iscsiadmrules Server:
- 192.168.50.7:3260,1 iqn.2011-06-01.com.766.rac:shareddisk
- Logging out of session [sid: 11, target: iqn.2011-06-01.com.766.rac:shareddisk, portal: 192.168.50.7,3260]
- Logout of [sid: 11, target: iqn.2011-06-01.com.766.rac:shareddisk, portal: 192.168.50.7,3260] successful.
- [root@rhel6 /]# service iscsi status
- No active sessions
- RHEL5.4
- [root@ora10g ~]# fdisk -l
- Disk /dev/vda: 107.3 GB, 107374182400 bytes
- 255 heads, 63 sectors/track, 13054 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Device Boot Start End Blocks Id System
- /dev/vda1 * 1 13 104391 83 Linux
- /dev/vda2 14 523 4096575 82 Linux swap / Solaris
- /dev/vda3 524 778 2048287+ 83 Linux
- /dev/vda4 779 13054 98606970 5 Extended
- /dev/vda5 779 13054 98606938+ 8e Linux LVM
- Disk /dev/sda: 107.3 GB, 107374182400 bytes
- 255 heads, 63 sectors/track, 13054 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Disk /dev/sda doesn't contain a valid partition table
本文出自 “斩月” 博客,谢绝转载!