實驗裝置:
用虛拟機虛拟兩個 redhat linux 6.3 -64bit 系統,并配置好yum
ip設定:
scsi服務端:10.1.1.222
scsi用戶端(挂載端):10.1.1.1
實驗開始:
1、在服務端安裝軟體并配置好共享的磁盤,首先在虛拟機中新加入一塊硬碟,大小随意。(這裡添加100G)
[root@localhost ~]# fdisk -l
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: 0x0005bb6c
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 281 2048000 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 281 2611 18717696 83 Linux
Disk /dev/sdb: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 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: 0x00077087
Device Boot Start End Blocks Id System
2、安裝scsi服務端軟體
yum install scsi-target-utils -y
共享磁盤(在配置檔案中加入以下代碼即可)
vim /etc/tgt/targets.conf
<target iqn.2008-09.com.example:server.target1>
backing-store /dev/sdb
</target>
啟動服務
service tgtd restart
關閉防火牆和selinux
3、在用戶端安裝用戶端軟體,并設定挂載
安裝用戶端軟體
yum install iscsi-initiator-utils -y
檢視是否有共享磁盤
iscsiadm --mode discoverydb --type sendtargets --portal 10.1.1.222 --discover
出現以下則表示有共享磁盤 10.1.1.222:3260,1 iqn.2008-09.com.example:server.target1
挂載磁盤
iscsiadm --mode node --targetname iqn.2008-09.com.example:server.target1 --portal 10.1.1.222:3260 --login
注意:中間2008-09這段是填寫上面查詢出來的那個磁盤名
成功挂載後有以下提示
[root@localhost ~]# iscsiadm --mode node --targetname iqn.2008-09.com.example:server.target1 --portal 10.1.1.222:3260 --login
Logging in to [iface: default, target: iqn.2008-09.com.example:server.target1, portal: 10.1.1.222,3260] (multiple)
Login to [iface: default, target: iqn.2008-09.com.example:server.target1, portal: 10.1.1.222,3260] successful.
檢視以下挂載成功沒有
[root@localhost ~]# fdisk -l
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: 0x00036380
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 281 2048000 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 281 2611 18717696 83 Linux
Disk /dev/sdb: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 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: 0x00077087
Device Boot Start End Blocks Id System
iscsiadm -m node -U all