Home | Mirror | Search

5. iSCSI

iSCSI 需要與GFS配合使用,其他檔案系統不能實現數據同步。

過程 10.1. iSCSI Example

  1. install.

    # yum install iscsi-initiator-utils -y
    # rpm -ql iscsi-initiator-utils
    # rpm -q --scripts iscsi-initiator-utils
    postinstall scriptlet (using /bin/sh):
    /sbin/ldconfig
    
    if [ ! -f /etc/iscsi/initiatorname.iscsi ]; then
            echo "InitiatorName=`/sbin/iscsi-iname`" > /etc/iscsi/initiatorname.iscsi
    fi
    /sbin/chkconfig --add iscsid
    /sbin/chkconfig --add iscsi
    preuninstall scriptlet (using /bin/sh):
    if [ "$1" = "0" ]; then
        /sbin/chkconfig --del iscsi
        /sbin/chkconfig --del iscsid
    fi
    postuninstall scriptlet (using /bin/sh):
    /sbin/ldconfig
    				
  2. config

    # cat /etc/iscsi/initiatorname.iscsi
    InitiatorName=iqn.1994-05.com.redhat:9b2024102698
    				
  3. starting service.

    # chkconfig iscsi on
    # chkconfig iscsid on
    
    # service iscsi start
    iscsid is stopped
    Starting iSCSI daemon:                                     [  OK  ]
                                                               [  OK  ]
    Setting up iSCSI targets: iscsiadm: No records found!
                                                               [  OK  ]
    # service iscsi status
    iscsid (pid  17501) is running...
    # service iscsid status
    iscsid (pid  17501) is running...
    
    				
  4. discovery targets.

    # iscsiadm -m discovery -t sendtargets -p 172.16.0.30:3260
    172.16.0.30:3260,1 iqn.2010-09.com.openfiler:tsn.c7a241688f35
    				

    or

    iscsiadm --mode discovery --type sendtargets --portal 172.16.0.30:3260
    
    iscsiadm -m discovery -t st -p 172.16.0.30:3260
    
    				
  5. login / logout

    # iscsiadm -m node --loginall=all
    Logging in to [iface: default, target: iqn.2010-09.com.openfiler:tsn.c7a241688f35, portal: 172.16.0.30,3260]
    Login to [iface: default, target: iqn.2010-09.com.openfiler:tsn.c7a241688f35, portal: 172.16.0.30,3260]: successful
    				

    or

    iscsiadm --mode node --targetname iqn.2010-09.com.openfiler:tsn.c7a241688f35 --portal 192.168.0.10:3260 --login
    				

    logout

    # iscsiadm -m node --logoutall=all
    				
  6. 分區設置

    fdisk -l
    fdisk /dev/sdb #依次選p n 1 w
    mkfs.ext4 /dev/sdb1
    
    掛載
    mkdir /iscsi
    mount /dev/sdb1 /iscsi
    
    設自動掛載
    vi /etc/fstab
    /dev/sdb1 /iscsi ext3 _netdev 0 0
    				

auth

# cp /etc/iscsi/iscsid.conf /etc/iscsi/iscsid.conf.old
# vim /etc/iscsi/iscsid.conf

		

show node

]# iscsiadm -m node
172.16.0.30:3260,1 iqn.2006-01.com.openfiler:tsn.0b232d1cc3ee
172.16.0.30:3260,1 iqn.2010-09.com.openfiler:tsn.c7a241688f35

		

delete node

iscsiadm -m node -o delete -T iqn.2006-01.com.openfiler:tsn.0b232d1cc3ee
		

5.1. GFS

[root@dev2 ~]# /etc/init.d/iscsi start
iscsid is stopped
Starting iSCSI daemon:                                     [  OK  ]
                                                           [  OK  ]
Setting up iSCSI targets: iscsiadm: No records found!
                                                           [  OK  ]
[root@dev2 ~]# iscsiadm -m discovery -t st -p 192.168.3.194
192.168.3.194:3260,1 iqn.2007-09.jp.ne.peach.istgt:disk0
[root@dev2 ~]# iscsiadm -m node -l
Logging in to [iface: default, target: iqn.2007-09.jp.ne.peach.istgt:disk0, portal: 192.168.3.194,3260]
Login to [iface: default, target: iqn.2007-09.jp.ne.peach.istgt:disk0, portal: 192.168.3.194,3260]: successful
			
# fdisk -l

Disk /dev/sda: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       30394   244035382+  8e  Linux LVM

Disk /dev/sdb: 499.5 GB, 499558383616 bytes
255 heads, 63 sectors/track, 60734 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table





fdisk /dev/sdb


# fdisk -l /dev/sdb

Disk /dev/sdb: 499.5 GB, 499558383616 bytes
255 heads, 63 sectors/track, 60734 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       60734   487845823+   5  Extended
/dev/sdb5               1       60734   487845792   83  Linux


# mkfs.gfs2 -p lock_dlm -t edb_ha:gfs1 -j 3 /dev/sdb5
This will destroy any data on /dev/sdb5.

Are you sure you want to proceed? [y/n] y

Device:                    /dev/sdb5
Blocksize:                 4096
Device Size                465.25 GB (121961448 blocks)
Filesystem Size:           465.25 GB (121961446 blocks)
Journals:                  3
Resource Groups:           1861
Locking Protocol:          "lock_dlm"
Lock Table:                "edb_ha:gfs1"
UUID:                      A75C4963-85A2-A28B-4099-07FD7E3379D6
			
comments powered by Disqus