iSCSI Initiator 配置
环境:
FreeNAS 8.1,使用CHAP认证(用户和密码均为test)
iSCSI Target 192.168.80.140
CentOS 6.2
iSCSI Initiator 192.168.80.120
1,确认安装iscsi-initiator-utils
[root@liaosnet ~]# rpm -qa | grep iscsi-initiator-utils
如果没有安装,使用yum install iscsi-initiator-utils 安装
2,修改iscsi.conf配置文件,填写CHAP认证用户和密码
[root@liaosnet ~]# vi /etc/iscsi/iscsi.conf
# 去除session.auth.authmethod = CHAP的注释
node.session.auth.authmethod = CHAP
# 修改session.auth的用户和密码
node.session.auth.username = test
node.session.auth.password = test
# 修改sendtargets.auth的用户和密码,并去除注释
discovery.sendtargets.auth.username = test
discovery.sendtargets.auth.password = test
3,发现iSCSI Target
[root@liaonset ~]# iscsiadm -m discovery -t sendtargets -p 192.168.80.139
192.168.80.139:3260,1 iqn.2011-03.org.example.istgt:mynas
4,重启iscsi服务,挂载iscsi设备
[root@liaosnet ~]# service iscsi restart
使用iscsiadm检查会话连接
[root@liaosnet ~]# iscsiadm -m session -o show
tcp: [1] 192.168.80.139:3260,1 iqn.2011-03.org.example.istgt:mynas
在/var/log/messages中,应有类似以下的的信息
Jun 3 15:31:26 liaosnet kernel: scsi3 : iSCSI Initiator over TCP/IP
Jun 3 15:31:28 liaosnet kernel: scsi 3:0:0:0: Direct-Access FreeBSD iSCSI Disk 0123 PQ: 0 ANSI: 5
Jun 3 15:31:28 liaosnet kernel: sd 3:0:0:0: Attached scsi generic sg2 type 0
Jun 3 15:31:28 liaosnet kernel: sd 3:0:0:0: [sdb] 33554432 512-byte logical blocks: (17.1 GB/16.0 GiB)
Jun 3 15:31:28 liaosnet kernel: sd 3:0:0:0: [sdb] Write Protect is off
Jun 3 15:31:28 liaosnet kernel: sd 3:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
Jun 3 15:31:28 liaosnet kernel: sdb: sdb1 sdb2 sdb3 sdb4
Jun 3 15:31:28 liaosnet kernel: sd 3:0:0:0: [sdb] Attached SCSI disk
Jun 3 15:31:28 liaosnet iscsid: Connection1:0 to [target: iqn.2011-03.org.example.istgt:mynas, portal: 192.168.80.139,3260] through [iface: default] is operational now
在/proc/partitions中有新增加的分区
[root@liaosnet ~]# cat /proc/partitions
major minor #blocks name
8 0 20971520 sda
8 1 512000 sda1
8 2 20458496 sda2
253 0 18391040 dm-0
253 1 2064384 dm-1
8 16 16777216 sdb
8 17 511984 sdb1
8 18 512000 sdb2
8 19 6144000 sdb3
8 20 6144000 sdb4
5,设置(或者确认)iSCSI随系统自动启动
[root@liaosnet ~]# chkconfig --list | grep iscsi
确认iscsi 和 iscsid 两个服务是随系统启动的,若是off的
[root@liaosnet ~]# chkconfig iscsi on; chkconfig iscsid on
另: 删除iSCSI Target信息的方法
iSCSI Target信息保存在/var/lib/iscsi/nodes 和 send_target 两个目录下,删除两个目录下对应iSCSI Target目录,然后重启iscsi和iscsid服务。