CentOS6.4+Cman+RGManager+iSCSI+GFS2+cLVM 实现廉价的可扩展(2)

二、iscsi 安装与配置
1.安装target
1 [root@target ~]# yum install -y scsi-target-utils

2.配置target

12345678910111213 [root@target ~]# vim /etc/tgt/targets.conf
#<target iqn.2008-09.com.example:server.target2>
#    direct-store /dev/sdd 
#    incominguser someuser secretpass12 
#</target>
<target iqn.2013-08.com.test:teststore.sdb> #配置target名称
    <backing-store /dev/sdb> #配置共享磁盘 
            vendor_id test #配置发行商(任意) 
            lun 6 #配置LUN号 
      </backing-store> 
      incominguser iscsiuser iscsiuser #配置认证的用户名和密码
      initiator-address 192.168.18.0/24 #配置允许的网段
</target>

3.启动target并设置为开机自启动

1234 [root@target ~]# service tgtd start 
[root@target ~]# chkconfig tgtd on 
[root@target ~]# chkconfig tgtd --list 
tgtd              0:关闭    1:关闭    2:启用    3:启用    4:启用    5:启用    6:关闭

4.查看配置的target
1234567891011121314151617181920212223 [root@target ~]# tgtadm --lld iscsi --mode target --op show 
Target 1: iqn.2013-08.com.test:teststore.sdb 
    System information: 
        Driver: iscsi 
        State: ready 
    I_T nexus information: 
    LUN information: 
        LUN: 0 
            Type: controller 
            SCSI ID: IET    00010000 
            SCSI SN: beaf10 
            Size: 0 MB, Block size: 1 
            Online: Yes 
            Removable media: No 
            Prevent removal: No 
            Readonly: No 
            Backing store type: null 
            Backing store path: None 
            Backing store flags:   
    Account information: 
        iscsiuser 
    ACL information: 
        192.168.18.0/24

5.在各节点上安装initiator
1 [root@target ~]# ha ssh node$I 'yum install -y initiator'; done

6.配置initiator
node1:
1234567 [root@node1 ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2013-08.com.test:node1
[root@node1 ~]# vim /etc/iscsi/iscsid.conf
#修改下面三项
node.session.auth.authmethod = CHAP #开启CHAP认证
node.session.auth.username = iscsiuser #配置认证用户名 
node.session.auth.password = iscsiuser #配置认证密码

node2:
1234567 [root@node2 ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2013-08.com.test:node2
[root@node2~]# vim /etc/iscsi/iscsid.conf
#修改下面三项
node.session.auth.authmethod = CHAP #开启CHAP认证
node.session.auth.username = iscsiuser #配置认证用户名 
node.session.auth.password = iscsiuser #配置认证密码

node3:
1234567 [root@node3 ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2013-08.com.test:node3
[root@node3 ~]# vim /etc/iscsi/iscsid.conf
#修改下面三项
node.session.auth.authmethod = CHAP #开启CHAP认证
node.session.auth.username = iscsiuser #配置认证用户名 
node.session.auth.password = iscsiuser #配置认证密码

7.各节点启动initiator并设置为开机自启动
123456 [root@target ~]# ha ssh node$I 'service iscsi start'; done
[root@target ~]# ha ssh node$I 'chkconfig iscsi on'; done
[root@target ~]# ha ssh node$I 'chkconfig iscsi --list'; done 
iscsi              0:关闭    1:关闭    2:启用    3:启用    4:启用    5:启用    6:关闭 
iscsi              0:关闭    1:关闭    2:启用    3:启用    4:启用    5:启用    6:关闭 
iscsi              0:关闭    1:关闭    2:启用    3:启用    4:启用    5:启用    6:关闭

8.在各节点上发现一下target
1234 [root@target ~]# ha ssh node$I 'iscsiadm -m discovery -t st -p 192.168.18.208:3260'; done 
192.168.18.208:3260,1 iqn.2013-08.com.test:teststore.sdb 
192.168.18.208:3260,1 iqn.2013-08.com.test:teststore.sdb 
192.168.18.208:3260,1 iqn.2013-08.com.test:teststore.sdb

9.各节点登录一下target并查看一下磁盘

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 [root@target ~]# ha ssh node$I 'iscsiadm -m node -T iqn.2013-08.com.test:teststore.sdb -p 192.168.18.208 -l'; done 
[root@target ~]# ha ssh node$I 'fdisk -l'; done
Disk /dev/sda: 21.5 GB, 21474836480 bytes 
255 heads, 63 sectors/track, 2610 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: 0x000dfceb
  Device Boot      Start        End      Blocks  Id  System 
/dev/sda1  *          1          26      204800  83  Linux 
Partition 1 does not end on cylinder boundary. 
/dev/sda2              26        1301    10240000  83  Linux 
/dev/sda3            1301        1938    5120000  83  Linux 
/dev/sda4            1938        2611    5405696    5  Extended 
/dev/sda5            1939        2066    1024000  82  Linux swap / Solaris
Disk /dev/sdb: 21.5 GB, 21474836480 bytes 
255 heads, 63 sectors/track, 2610 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: 0x5f3b697c
  Device Boot      Start        End      Blocks  Id  System
Disk /dev/sdd: 21.5 GB, 21474836480 bytes 
64 heads, 32 sectors/track, 20480 cylinders 
Units = cylinders of 2048 * 512 = 1048576 bytes 
Sector size (logical/physical): 512 bytes / 512 bytes 
I/O size (minimum/optimal): 512 bytes / 512 bytes 
Disk identifier: 0x0c68b5e3
  Device Boot      Start        End      Blocks  Id  System
Disk /dev/sda: 21.5 GB, 21474836480 bytes 
255 heads, 63 sectors/track, 2610 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: 0x000dfceb
  Device Boot      Start        End      Blocks  Id  System 
/dev/sda1  *          1          26      204800  83  Linux 
Partition 1 does not end on cylinder boundary. 
/dev/sda2              26        1301    10240000  83  Linux 
/dev/sda3            1301        1938    5120000  83  Linux 
/dev/sda4            1938        2611    5405696    5  Extended 
/dev/sda5            1939        2066    1024000  82  Linux swap / Solaris
Disk /dev/sdb: 21.5 GB, 21474836480 bytes 
255 heads, 63 sectors/track, 2610 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/sdd: 21.5 GB, 21474836480 bytes 
64 heads, 32 sectors/track, 20480 cylinders 
Units = cylinders of 2048 * 512 = 1048576 bytes 
Sector size (logical/physical): 512 bytes / 512 bytes 
I/O size (minimum/optimal): 512 bytes / 512 bytes 
Disk identifier: 0x0c68b5e3
  Device Boot      Start        End      Blocks  Id  System
Disk /dev/sda: 21.5 GB, 21474836480 bytes 
255 heads, 63 sectors/track, 2610 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: 0x000dfceb
  Device Boot      Start        End      Blocks  Id  System 
/dev/sda1  *          1          26      204800  83  Linux 
Partition 1 does not end on cylinder boundary. 
/dev/sda2              26        1301    10240000  83  Linux 
/dev/sda3            1301        1938    5120000  83  Linux 
/dev/sda4            1938        2611    5405696    5  Extended 
/dev/sda5            1939        2066    1024000  82  Linux swap / Solaris
Disk /dev/sdb: 21.5 GB, 21474836480 bytes 
255 heads, 63 sectors/track, 2610 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/sdd: 21.5 GB, 21474836480 bytes 
64 heads, 32 sectors/track, 20480 cylinders 
Units = cylinders of 2048 * 512 = 1048576 bytes 
Sector size (logical/physical): 512 bytes / 512 bytes 
I/O size (minimum/optimal): 512 bytes / 512 bytes 
Disk identifier: 0x0c68b5e3
  Device Boot      Start        End      Blocks  Id  System

好了,到这里iscsi配置全部完成,下面我们来配置一下,集群。 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/80873e88ee0cbbd3c1a0b9966c1375c9.html