Chinaunix首页 | 论坛 | 博客
  • 博客访问: 180473
  • 博文数量: 54
  • 博客积分: 3129
  • 博客等级: 中校
  • 技术积分: 618
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-20 22:49
文章分类

全部博文(54)

文章存档

2012年(2)

2010年(1)

2009年(8)

2008年(43)

我的朋友

分类: LINUX

2008-10-27 23:03:59

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是不一样的。以证明是两台机器。




阅读(1491) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~