AS4U6認iscsi硬碟

hooca發表於2014-12-03

轉載:http://blog.chinaunix.net/uid-1806527-id-2839459.html

openfiler一端不說了。就說LINUX操作,OS是AS4U6,整個模擬操作環境是openfiler2.3,2.3版本比2.2版本功能上多了好多,有時間再做一次openfiler2.3的文件,這裡主要是重點介紹linux認iscsi磁碟操作。

1.需要安裝iscsi-initiator-utils-4.0.3.0-6,在linux安裝的時候在network services下面就有這個包

2.vi /etc/iscsi.conf,新增如下,IP就是openfiler的就可以了。
#
Continuous=yes
Subnet=192.168.198.0/24
ImmediateData=no
InitialR2T=yes
SendAsyncText=yes
ConnFailTimeout=5
DiscoveryAddress=192.168.198.102
"/etc/iscsi.conf" 440L, 15226C written
[root@rhel4 ~]# telnet 192.168.198.102 3260
Trying 192.168.198.102...
Connected to 192.168.198.102 (192.168.198.102).
Escape character is '^]'.

^]
telnet> quit
Connection closed.
[root@rhel4 ~]# /etc/init.d/iscsi restart
Searching for iscsi-based multipath maps
Found 0 maps
Stopping iscsid: [  OK  ]
Removing iscsi driver: [  OK  ]
Checking iscsi config:  [  OK  ]
Loading iscsi driver:  [  OK  ]
Starting iscsid: [  OK  ]

[root@rhel4 ~]# 
[root@rhel4 ~]# iscsi-ls 
*******************************************************************************
SFNet iSCSI Driver Version ...4:0.1.11-6(03-Aug-2007)
*******************************************************************************
TARGET NAME             : iqn.2006-01.com.openfiler:tsn.5e9d38eb21d6
TARGET ALIAS            : 
HOST ID                 : 1
BUS ID                  : 0
TARGET ID               : 0
TARGET ADDRESS          : 192.168.198.102:3260,1
SESSION STATUS          : ESTABLISHED AT Tue Oct 28 22:03:53 CST 2008
SESSION ID              : ISID 00023d000001 TSIH 100
*******************************************************************************
[root@rhel4 ~]# dmesg | tail    sdb: unknown partition table
Attached scsi disk sdb at scsi1, channel 0, id 0, lun 0
  Vendor: OPNFILER  Model: VIRTUAL-DISK      Rev: 0   
  Type:   Direct-Access                      ANSI SCSI revision: 04
SCSI device sdc: 6160384 512-byte hdwr sectors (3154 MB)
SCSI device sdc: drive cache: write through
SCSI device sdc: 6160384 512-byte hdwr sectors (3154 MB)
SCSI device sdc: drive cache: write through
 sdc: unknown partition table
Attached scsi disk sdc at scsi1, channel 0, id 0, lun 1
[root@rhel4 ~]# fdisk -l   

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         510     4096543+  83  Linux
/dev/sda2             511         575      522112+  82  Linux swap

Disk /dev/sdb: 234 MB, 234881024 bytes
8 heads, 56 sectors/track, 1024 cylinders
Units = cylinders of 448 * 512 = 229376 bytes

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

Disk /dev/sdc: 3154 MB, 3154116608 bytes
98 heads, 62 sectors/track, 1013 cylinders
Units = cylinders of 6076 * 512 = 3110912 bytes

Disk /dev/sdc doesn't contain a valid partition table     
[root@rhel4 ~]# iscsi-device

Usage: iscsi-device devicename

[root@rhel4 ~]# iscsi-device /dev/sdb
/dev/sdb is an iSCSI device 
[root@rhel4 ~]# iscsi-device /dev/sda
iscsi-device: /dev/sda is not an iSCSI device
[root@rhel4 ~]# 
[root@rhel4 ~]# /etc/init.d/iscsi 
Usage: /etc/init.d/iscsi { start | stop | restart | status | reload }
[root@rhel4 ~]# /etc/init.d/iscsi status
iscsid (pid 5636 5633) is running...
[root@rhel4 ~]# ps -ef | grep iscsi
root      5633     1  0 22:03 ?        00:00:00 /sbin/iscsid
root      5636  5633  0 22:03 ?        00:00:00 /sbin/iscsid
root      5663     6  0 22:03 ?        00:00:00 [iscsi-tx]
root      5664     6  0 22:03 ?        00:00:00 [iscsi-rx]
root      7019  5358  0 22:22 pts/1    00:00:00 grep iscsi


[root@rhel4 ~]# lsmod | grep iscsi
iscsi_sfnet            85073  2 
scsi_transport_iscsi    12737  1 iscsi_sfnet
scsi_mod              120909  6 iscsi_sfnet,libata,mptsas,mptspi,mptscsi,sd_mod
[root@rhel4 ~]# 
注意一下,服務停的話,檢視載入模組沒有了iscsi_sfnet
[root@rhel4 ~]# /etc/init.d/iscsi stop
Searching for iscsi-based multipath maps
Found 0 maps
Stopping iscsid: [  OK  ]
Removing iscsi driver: [  OK  ]
[root@rhel4 ~]# lsmod | grep iscsi
scsi_transport_iscsi    12737  0 
[root@rhel4 ~]# 
檢視這個模組的資訊
[root@rhel4 ~]# modinfo iscsi_sfnet
filename:       /lib/modules/2.6.9-67.ELsmp/kernel/drivers/scsi/iscsi_sfnet/iscsi_sfnet.ko
author:         Mike Christie and Cisco Systems, Inc.
description:    iSCSI initiator
license:        GPL
version:        4:0.1.11-3 F63B8295DD5732B05551E48
parm:           max_initial_login_retries:Max number of times to retry logging into a target for the first time before giving up. The default is 3. Set to -1 for no limit
vermagic:       2.6.9-67.ELsmp SMP 686 REGPARM 4KSTACKS gcc-3.4
depends:        scsi_transport_iscsi,scsi_mod
[root@rhel4 ~]# 


至此已經認到iscsi磁碟了,很簡單吧

下面是兩臺LINUX設定同時認到一塊磁碟。用RAC和HA共享磁碟需要的。
下面是A伺服器
[root@rhel4-6 ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:0C:25:39  
          inet addr:192.168.198.104  Bcast:192.168.198.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe0c:2539/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:545 errors:0 dropped:0 overruns:0 frame:0
          TX packets:446 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:333654 (325.8 KiB)  TX bytes:47268 (46.1 KiB)
          Interrupt:193 Base address:0x2000

[root@rhel4-6 ~]# tail /etc/iscsi.conf 
# 6) TCP Settings
# 7) Enable/Disable targets
#
Continuous=yes
Subnet=192.168.198.0/24
ImmediateData=no
InitialR2T=yes 
SendAsyncText=yes
ConnFailTimeout=5
DiscoveryAddress=192.168.198.102
[root@rhel4-6 ~]# iscsi-ls 
*******************************************************************************
SFNet iSCSI Driver Version ...4:0.1.11-6(03-Aug-2007)
*******************************************************************************
TARGET NAME             : iqn.2006-01.com.openfiler:tsn.5e9d38eb21d6
TARGET ALIAS            : 
HOST ID                 : 1
BUS ID                  : 0
TARGET ID               : 0
TARGET ADDRESS          : 192.168.198.102:3260,1
SESSION STATUS          : ESTABLISHED AT Tue Oct 28 22:57:53 CST 2008
SESSION ID              : ISID 00023d000001 TSIH 400
*******************************************************************************
[root@rhel4-6 ~]# dmesg | tail -20
iscsi-sfnet: Loading iscsi_sfnet version 4:0.1.11-3
iscsi-sfnet: Control device major number 254
iscsi-sfnet:host1: Session established
scsi1 : SFNet iSCSI driver
  Vendor: OPNFILER  Model: VIRTUAL-DISK      Rev: 0   
  Type:   Direct-Access                      ANSI SCSI revision: 04
SCSI device sdb: 458752 512-byte hdwr sectors (235 MB)
SCSI device sdb: drive cache: write through
SCSI device sdb: 458752 512-byte hdwr sectors (235 MB)
SCSI device sdb: drive cache: write through
 sdb: unknown partition table
Attached scsi disk sdb at scsi1, channel 0, id 0, lun 0
  Vendor: OPNFILER  Model: VIRTUAL-DISK      Rev: 0   
  Type:   Direct-Access                      ANSI SCSI revision: 04
SCSI device sdc: 6160384 512-byte hdwr sectors (3154 MB)
SCSI device sdc: drive cache: write through
SCSI device sdc: 6160384 512-byte hdwr sectors (3154 MB)
SCSI device sdc: drive cache: write through
 sdc: unknown partition table
Attached scsi disk sdc at scsi1, channel 0, id 0, lun 1
[root@rhel4-6 ~]# fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         510     4096543+  83  Linux
/dev/sda2             511         575      522112+  82  Linux swap

Disk /dev/sdb: 234 MB, 234881024 bytes
8 heads, 56 sectors/track, 1024 cylinders
Units = cylinders of 448 * 512 = 229376 bytes

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

Disk /dev/sdc: 3154 MB, 3154116608 bytes
98 heads, 62 sectors/track, 1013 cylinders
Units = cylinders of 6076 * 512 = 3110912 bytes

Disk /dev/sdc doesn't contain a valid partition table
[root@rhel4-6 ~]# 



下面是B伺服器
[root@rhel4-6 ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:A5:74:19  
          inet addr:192.168.198.105  Bcast:192.168.198.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fea5:7419/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:518 errors:0 dropped:0 overruns:0 frame:0
          TX packets:431 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:331947 (324.1 KiB)  TX bytes:49408 (48.2 KiB)
          Interrupt:193 Base address:0x2000

[root@rhel4-6 ~]# tail /etc/iscsi.conf 
# 6) TCP Settings
# 7) Enable/Disable targets
#
Continuous=yes
Subnet=192.168.198.0/24
ImmediateData=no
InitialR2T=yes 
SendAsyncText=yes
ConnFailTimeout=5
DiscoveryAddress=192.168.198.102
[root@rhel4-6 ~]# iscsi-ls 
*******************************************************************************
SFNet iSCSI Driver Version ...4:0.1.11-6(03-Aug-2007)
*******************************************************************************
TARGET NAME             : iqn.2006-01.com.openfiler:tsn.5e9d38eb21d6
TARGET ALIAS            : 
HOST ID                 : 1
BUS ID                  : 0
TARGET ID               : 0
TARGET ADDRESS          : 192.168.198.102:3260,1
SESSION STATUS          : ESTABLISHED AT Tue Oct 28 22:54:43 CST 2008
SESSION ID              : ISID 00023d000001 TSIH 300
*******************************************************************************
[root@rhel4-6 ~]# dmesg | tail -20
iscsi-sfnet: Loading iscsi_sfnet version 4:0.1.11-3
iscsi-sfnet: Control device major number 254
iscsi-sfnet:host1: Session established
scsi1 : SFNet iSCSI driver
  Vendor: OPNFILER  Model: VIRTUAL-DISK      Rev: 0   
  Type:   Direct-Access                      ANSI SCSI revision: 04
SCSI device sdb: 458752 512-byte hdwr sectors (235 MB)
SCSI device sdb: drive cache: write through
SCSI device sdb: 458752 512-byte hdwr sectors (235 MB)
SCSI device sdb: drive cache: write through
 sdb: unknown partition table
Attached scsi disk sdb at scsi1, channel 0, id 0, lun 0
  Vendor: OPNFILER  Model: VIRTUAL-DISK      Rev: 0   
  Type:   Direct-Access                      ANSI SCSI revision: 04
SCSI device sdc: 6160384 512-byte hdwr sectors (3154 MB)
SCSI device sdc: drive cache: write through
SCSI device sdc: 6160384 512-byte hdwr sectors (3154 MB)
SCSI device sdc: drive cache: write through
 sdc: unknown partition table
Attached scsi disk sdc at scsi1, channel 0, id 0, lun 1
[root@rhel4-6 ~]# fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         510     4096543+  83  Linux
/dev/sda2             511         575      522112+  82  Linux swap

Disk /dev/sdb: 234 MB, 234881024 bytes
8 heads, 56 sectors/track, 1024 cylinders
Units = cylinders of 448 * 512 = 229376 bytes

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

Disk /dev/sdc: 3154 MB, 3154116608 bytes
98 heads, 62 sectors/track, 1013 cylinders
Units = cylinders of 6076 * 512 = 3110912 bytes

Disk /dev/sdc doesn't contain a valid partition table
[root@rhel4-6 ~]# 

上面主機名雖然一樣,但IP是不一樣的。以證明是兩臺機器。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22621861/viewspace-1355576/,如需轉載,請註明出處,否則將追究法律責任。

相關文章