lsz_qh 发表于 2012-12-30 21:58:38

iscsi+udev做RAC共享磁盘

本帖最后由 lsz_qh 于 2012-12-30 22:04 编辑

配置ipsan
存储节点:
1、安装scsi-target-utils,并确保/etc/hosts没有问题
2、修改配置文件:cat /etc/tgt/targets.conf
default-driver iscsi
<target iqn.2012-12.shardisk:shardisk>-->iqn.当前时间.hostname倒着写:name
        backing-store /dev/sda4-->需要共享的分区或者盘
        vendor_id  sharedisk-->厂商标识
        product_id  sharedisk1-->产品编号
        initiator-address  192.168.244.4-->能访问存储的节点的ip
        initiator-address  192.168.244.5-->能访问存储的节点的ip
</target>3、查看配置信息:# tgt-admin --show
Target 1: iqn.2012-12.shardisk:shardisk
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
        I_T nexus: 1
            Initiator: iqn.1994-05.com.redhat:c342f81751d7
            Connection: 0
                IP Address: 192.168.244.4
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: deadbeaf1:0
            SCSI SN: beaf10
            Size: 0 MB
            Online: Yes
            Removable media: No
            Backing store: No backing store
        LUN: 1
            Type: disk
            SCSI ID: deadbeaf1:1
            SCSI SN: beaf11
            Size: 40970 MB
            Online: Yes
            Removable media: No
            Backing store: /dev/sda4
    Account information:
    ACL information:
        192.168.244.4
        192.168.244.54、启动服务/etc/init.d/tgtd start,并设置为开机启动chkconfig  tgtd  on
5、查看tgt服务监听的端口:netstat -tnlpa | grep tgtd-->tgtd监听的端口为3260


使用存储端:(2台使用存储的机器都需要配置)
1、安装iscsi-initiator-utils
2、启动服务service iscsid start
3、发现并使用
iscsiadm -m discovery -t sendtargets -p 192.168.244.3:3260-->存储端ip和端口
iscsiadm -m node -T iqn.2012-12.shardisk:shardisk -l
4、将服务设置为开机启动:
chkconfig iscsid on
chkconfig iscsi on
5、查看磁盘信息:# fdisk -l

Disk /dev/sda: 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/sda1   *           1          25      200781   83  Linux
/dev/sda2              26        5124    40957717+  83  Linux
/dev/sda3            5125        7680    20531070   82  Linux swap / Solaris

Disk /dev/sdb: 40.9 GB, 40970119680 bytes
64 heads, 32 sectors/track, 39072 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn't contain a valid partition table其中dev/sdb是共享磁盘

为了保证盘符发生变化时共享磁盘还能继续使用,在使用存储端配置udev

1、查看信息:# udevinfo -a -p /sys/block/sdb/

Udevinfo starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/block/sdb':
    KERNEL=="sdb"
    SUBSYSTEM=="block"
    SYSFS{stat}=="     118     1588     1706      105        0        0        0        0        0       88      105"
    SYSFS{size}=="80019765"
    SYSFS{removable}=="0"
    SYSFS{range}=="16"
    SYSFS{dev}=="8:16"

  looking at parent device '/devices/platform/host2/session2/target2:0:0/2:0:0:1':
    ID=="2:0:0:1"
    BUS=="scsi"
    DRIVER=="sd"
    SYSFS{ioerr_cnt}=="0x1"
    SYSFS{iodone_cnt}=="0x92"
    SYSFS{iorequest_cnt}=="0x92"
    SYSFS{iocounterbits}=="32"
    SYSFS{timeout}=="60"
    SYSFS{state}=="running"
    SYSFS{rev}=="0001"
    SYSFS{model}=="VIRTUAL-DISK"-->配置udev的时候需要
    SYSFS{vendor}=="IET     "-->配置udev的时候需要
    SYSFS{scsi_level}=="6"
    SYSFS{type}=="0"
    SYSFS{queue_type}=="none"
    SYSFS{queue_depth}=="32"
    SYSFS{device_blocked}=="0"

  looking at parent device '/devices/platform/host2/session2/target2:0:0':
    ID=="target2:0:0"
    BUS==""
    DRIVER==""

  looking at parent device '/devices/platform/host2/session2':
    ID=="session2"
    BUS==""
    DRIVER==""

  looking at parent device '/devices/platform/host2':
    ID=="host2"
    BUS==""
    DRIVER==""

  looking at parent device '/devices/platform':
    ID=="platform"
    BUS==""
    DRIVER==""
#
2、修改配置文件,配置udev:cd /etc/udev/rules.d
# cat /etc/udev/rules.d/80-scsi-udev.rules(没有的话可以自行创建)
#
# VMware SCSI devices Timeout adjustment
#
# Modify the timeout value for VMware SCSI devices so that
# in the event of a failover, we don't time out.
# See Bug 271286 for more information.
SUBSYSTEM=="block",SYSFS{size}=="40960",SYSFS{vendor}=="IET     ",SYSFS{model}=="VIRTUAL-DISK",SYMLINK="iscsi/sharedisk"3、启动udev
start_udev
4、查看信息# ls -ltr /dev/iscsi
总计 0
lrwxrwxrwx 1 root root 6 12-20 17:36 sharedisk -> ../sdb完成以上配置有,/dev/sdb已经共享到2个RAC节点中,使用时可以根据需求划分不同的lv,划分lv时只需在一个RAC节点创建,另一个节点只需要激活即可,即vgchange -ay vgname

dbatravel 发表于 2012-12-30 22:17:26

支持 下 ~~
页: [1]
查看完整版本: iscsi+udev做RAC共享磁盘