centos 6.0 安装iscsi笔记
一、安装iscsi-target
1.用光盘里的文件安装yum install scsi-target-utils.i686
2.配置文件在/etc/tgt/targets.conf
default-driver iscsi
<target iqn.2011-11.cn.exampl:server.disk1.host1>
backing-store /dev/mapper/VolGroup-newlv #VolGroup-newlv是划分的lv
</target>
3.启动target:service tgtd start
4.定义target
tgtadm --lld iscsi --op new --mode target --tid 1 --targetname iqn.2011-
11.cn.exampl:server.disk1.host1
5.将空间划分给target lun1:tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 --backing-store /dev/mapper/VolGroup-newlv
6.确定target信息:tgtadm --lld iscsi --op show --mode target
# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2011-11.com.example:server.disk1.host1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: None
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 2147 MB
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: /dev/mapper/VolGroup-newlv
Account information:
ACL information:
ALL
二、安装iscsi initiator
1.yum 安装 iscsi-initiator-utils.i686
2.启动iscsi
service iscsid start (如果运行这个命令后还是stopped,运行server iscsid force-start)
3.查找target
[root@web1 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.60.37
192.168.60.37:3260,1 iqn.2011-11.com.example:storage.disk2.sys1.xyz
4.登陆target
[root@web1 ~]# iscsiadm --mode node --portal -T iqn.2011-11.com.example:storage.disk2.sys1.xyz -p 192.168.60.37 -l
Logging in to [iface: default, target: iqn.2011-11.com.example:storage.disk2.sys1.xyz, portal: 192.168.60.37,3260]
Login to [iface: default, target: iqn.2011-11.com.example:storage.disk2.sys1.xyz, portal: 192.168.60.37,3260] successful.
5.fdisk -l 或者 sfdisk -s 查看
Disk /dev/sdb: 2147 MB, 2147483648 bytes 这个是多出的
6.分区、格式化iSCSI磁盘设备,并挂载使用
1)fdisk /dev/sdb (格式化完为/dev/sdb1) 2) partprobe 3)mkfs.ext4 /dev/sdb1
4)vim /etc/fstab 实现开机自动挂载
/dev/sdb1 /iscsi ext4 _netdev 0 0
5)mkdir /iscsi 6)mount /iscsi
7.查看[root@web1 ~]# df -h
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/VolGroup-lv_root
14G 2.9G 9.7G 23% /
tmpfs 302M 272K 302M 1% /dev/shm
/dev/sda1 485M 29M 431M 7% /boot
/dev/sdb1 2.0G 35M 1.9G 2% /iscsi
如果在连的时候,有连接不上的情况,请检查防火墙
over