1. 安装 open-iscsi 包;
yum install open-iscsi
2. 编辑/etc/iscsi/iscsid.conf,配置iSCSI的行为:
node.startup = automatic
3. 通过iscsiadm,察看当前能看到哪些target:
sudo iscsiadm -m discovery -t st -p 192.168.0.1
注:
-m: 指定iscsiadm执行的什么操作
-t:指定discovery的类型,st指的是static
-p:指定target的ip,请将此处的192.168.0.1换为你自己server 的IP 地址,如果有target,就会显示以下信息。
192.168.0.10:3260,1 iqn.1992-05.com.emc:sl7b92030000520000-2
4. 连接看到的target。
iscsiadm -m node --login
5. 通过dmesg确定是否能发现target上的磁盘。
dmesg | grep sd [ 4.322384] sd 2:0:0:0: Attached scsi generic sg1 type 0
[ 4.322797] sd 2:0:0:0: [sda] 41943040 512-byte logical blocks: (21.4 GB/20.0 GiB)
[ 4.322843] sd 2:0:0:0: [sda] Write Protect is off
[ 4.322846] sd 2:0:0:0: [sda] Mode Sense: 03 00 00 00
[ 4.322896] sd 2:0:0:0: [sda] Cache data unavailable
[ 4.322899] sd 2:0:0:0: [sda] Assuming drive cache: write through
[ 4.323230] sd 2:0:0:0: [sda] Cache data unavailable
[ 4.323233] sd 2:0:0:0: [sda] Assuming drive cache: write through
[ 4.325312] sda: sda1 sda2 < sda5 >
[ 4.325729] sd 2:0:0:0: [sda] Cache data unavailable
[ 4.325732] sd 2:0:0:0: [sda] Assuming drive cache: write through
[ 4.325735] sd 2:0:0:0: [sda] Attached SCSI disk
[ 2486.941805] sd 4:0:0:3: Attached scsi generic sg3 type 0
[ 2486.952093] sd 4:0:0:3: [sdb] 1126400000 512-byte logical blocks: (576 GB/537 GiB)
[ 2486.954195] sd 4:0:0:3: [sdb] Write Protect is off
[ 2486.954200] sd 4:0:0:3: [sdb] Mode Sense: 8f 00 00 08
[ 2486.954692] sd 4:0:0:3: [sdb] Write cache: disabled, read cache: enabled, doesn't
support DPO or FUA
[ 2486.960577] sdb: sdb1
[ 2486.964862] sd 4:0:0:3: [sdb] Attached SCSI disk
6. 如果initiator看不到LU,则可能需要进一步在target端确认是否允许initiator访问。
7. 查看initiator的名字。
-
[root@localhost ~]# cat /etc/iscsi/initiatorname.iscsi
-
InitiatorName=iqn.1988-12.com.oracle:eb162ede5de7
8. 在target端配置完成后,需要在initiator端logout原来的target再login。
-
[root@localhost ~]# iscsiadm -m session
-
tcp: [1] 192.168.68.100:3260,2 iqn.1986-03.com.sun:02:b7d3ae28-f789-4be3-c955-9aee664d92a4 (non-flash)
9. Logout一个target。
-
[root@localhost ~]# iscsiadm -m node -T iqn.1986-03.com.sun:02:b7d3ae28-f789-4be3-c955-9aee664d92a4 -p 192.168.68.100 -u
-
Logging out of session [sid: 1, target: iqn.1986-03.com.sun:02:b7d3ae28-f789-4be3-c955-9aee664d92a4, portal: 192.168.68.100,3260]
-
Logout of [sid: 1, target: iqn.1986-03.com.sun:02:b7d3ae28-f789-4be3-c955-9aee664d92a4, portal: 192.168.68.100,3260] successful.
10. 重新login一个target。
-
[root@localhost ~]# iscsiadm -m node -T iqn.1986-03.com.sun:02:b7d3ae28-f789-4be3-c955-9aee664d92a4 -p 192.168.68.100 -l
-
Logging in to [iface: default, target: iqn.1986-03.com.sun:02:b7d3ae28-f789-4be3-c955-9aee664d92a4, portal: 192.168.68.100,3260] (multiple)
-
Login to [iface: default, target: iqn.1986-03.com.sun:02:b7d3ae28-f789-4be3-c955-9aee664d92a4, portal: 192.168.68.100,3260] successful.
11. 重新查看磁盘(可以安装lsscsi命令来显示当前系统中所有的Lu)
-
<span style="font-size:14px;">[root@localhost ~]# yum install lsscsi
-
Loaded plugins: langpacks
-
Resolving Dependencies
-
--> Running transaction check
-
---> Package lsscsi.x86_64 0:0.27-3.el7 will be installed
-
--> Finished Dependency Resolution
-
-
Dependencies Resolved
-
-
===========================================================================================
-
Package Arch Version Repository Size
-
===========================================================================================
-
Installing:
-
lsscsi x86_64 0.27-3.el7 ol7_latest 46 k
-
-
-
Transaction Summary
-
===========================================================================================
-
Install 1 Package
-
-
-
Total download size: 46 k
-
Installed size: 88 k
-
Is this ok [y/d/N]: y
-
Downloading packages:
-
lsscsi-0.27-3.el7.x86_64.rpm | 46 kB 00:00:01
-
Running transaction check
-
Running transaction test
-
Transaction test succeeded
-
Running transaction
-
Installing : lsscsi-0.27-3.el7.x86_64 1/1
-
Verifying : lsscsi-0.27-3.el7.x86_64 1/1
-
-
Installed:
-
lsscsi.x86_64 0:0.27-3.el7
-
-
Complete!span>
12. lsscsi的运行效果
-
<span style="font-size:14px;">[root@localhost ~]# lsscsi
-
[0:2:0:0] disk LSI MR9261-8i 2.12 /dev/sda
-
[1:0:0:0] disk ORACLE SSM PMAP /dev/sdb
-
[6:0:0:0] cd/dvd TEAC DV-W28SS-W 1.0A /dev/sr0
-
[8:0:0:0] cd/dvd AMI Virtual CDROM 1.00 /dev/sr1
-
[10:0:0:0] disk SUN ZFS Storage 7330 1.0 /dev/sdc
-
[10:0:0:1] disk SUN ZFS Storage 7330 1.0 /dev/sdd
-
[10:0:0:2] disk SUN ZFS Storage 7330 1.0 /dev/sde
-
[10:0:0:3] disk SUN ZFS Storage 7330 1.0 /dev/sdf
-
[10:0:0:4] disk SUN ZFS Storage 7330 1.0 /dev/sdg
-
[10:0:0:5] disk SUN ZFS Storage 7330 1.0 /dev/sdh
-
[10:0:0:6] disk SUN ZFS Storage 7330 1.0 /dev/sdi
-
[10:0:0:7] disk SUN ZFS Storage 7330 1.0 /dev/sdj
-
[10:0:0:8] disk SUN ZFS Storage 7330 1.0 /dev/sdk
-
[10:0:0:9] disk SUN ZFS Storage 7330 1.0 /dev/sdl
-
[10:0:0:10] disk SUN ZFS Storage 7330 1.0 /dev/sdm
-
[10:0:0:11] disk SUN ZFS Storage 7330 1.0 /dev/sdn
-
[10:0:0:12] disk SUN ZFS Storage 7330 1.0 /dev/sdo
-
[10:0:0:13] disk SUN ZFS Storage 7330 1.0 /dev/sdp
-
[10:0:0:14] disk SUN ZFS Storage 7330 1.0 /dev/sdq
-
[10:0:0:15] disk SUN ZFS Storage 7330 1.0 /dev/sdr
-
[10:0:0:16] disk SUN ZFS Storage 7330 1.0 /dev/sds
-
[10:0:0:17] disk SUN ZFS Storage 7330 1.0 /dev/sdt
-
[10:0:0:18] disk SUN ZFS Storage 7330 1.0 /dev/sdu
-
[10:0:0:19] disk SUN ZFS Storage 7330 1.0 /dev/sdv
-
[10:0:0:20] disk SUN ZFS Storage 7330 1.0 /dev/sdw
-
[10:0:0:21] disk SUN ZFS Storage 7330 1.0 /dev/sdx
-
[10:0:0:22] disk SUN ZFS Storage 7330 1.0 /dev/sdy
-
[10:0:0:23] disk SUN ZFS Storage 7330 1.0 /dev/sdz
-
[10:0:0:24] disk SUN ZFS Storage 7330 1.0 /dev/sdaa
-
[10:0:0:25] disk SUN ZFS Storage 7330 1.0 /dev/sdab
-
[10:0:0:26] disk SUN ZFS Storage 7330 1.0 /dev/sdac
-
[10:0:0:27] disk SUN ZFS Storage 7330 1.0 /dev/sdad
-
[10:0:0:28] disk SUN ZFS Storage 7330 1.0 /dev/sdae
-
[10:0:0:29] disk SUN ZFS Storage 7330 1.0 /dev/sdaf
-
[10:0:0:30] disk SUN ZFS Storage 7330 1.0 /dev/sdag
-
[10:0:0:31] disk SUN ZFS Storage 7330 1.0 /dev/sdahspan>
-