---服务端---
1.准备磁盘
在另一台虚拟机上新增一块磁盘sdd
2.安装target包
perl-Config-General-2.40-1.noarch.rpm
scsi-target-utils-0.0-5.20080917snap.ky3.x86_64.rpm
3.修改配置文件,设置存储盘
/etc/tgt/targets.conf
将/dev/sdb设置为IP-SAN的网络存储盘。
iqn:iSCSI Qualified Name (iSCSI 合格名称)
iqn.yyyy-mm.<reversed domain
name>:identifier
# TGTD example targets file
#
# Example iSCSI target with one
LUN.
# This gets read when "service tgtd start" is run.
#
#<target
iqn.2007-04.com.example:tgtd>
#
List of files to export as LUNs
#backing-store /usr/storage/disk_1.img
# Authentication
:
# if no "incominguser" is
specified, it is not used
#incominguser backup secretpass12
# Access control
:
# defaults to ALL if no
"initiator-address" is specified
#initiator-address 192.168.1.2
#</target>
<target
iqn.1992-04.liaoyi.kylin:disk>
direct-store
/dev/sdb
(实际磁盘,不安全)
backing-store
/srv/sicsi/disk1.img (大型文件档案)
backing-store
/dev/sdb1
(磁盘分区)
backing-store /dev/server/iscsi01
(LV)
*initiator-address 10.1.20.183
指定发起者的ip地址
*incominguser liaoyi
qwer1234
发起者所需提供的用户名及密码
*write-cache
off
不启用快取,容易遗失数据
</target>
4.启动tgtd服务
service tgtd start
5.IP、防火墙设置
ifconfig eth0 10.1.20.99
service iptables stop
6 显示taget信息
tgt-admin --show
一个target可以有多个LUN,每个LUN都是相当于一个磁盘。
LUN:logical unit number 逻辑单元序号
Target 1: test
System
information:
Driver:
iscsi
State:
ready
I_T nexus
information:
I_T nexus:
7
Initiator:
iqn.kssd:00000110
Connection:
0
IP Address: 10.1.20.89
I_T nexus:
9
Initiator:
iqn.kssd:00000110
Connection:
0
IP Address: 10.1.20.88
LUN
information:
LUN:
0
Type:
controller
SCSI ID:
deadbeaf1:0
SCSI SN:
beaf10
Size: 0 MB
Online:
Yes
Removable media:
No
Backing
store: No backing store
LUN: 1
Type:
disk
SCSI
ID:
deadbeaf1:1
SCSI SN:
beaf11
Size: 8590
MB
Online:
Yes
Removable media:
No
Backing
store: /dev/sdb
Account information:
ACL information:
ALL
*Account
information:
liaoyi
ACL
information:
10.1.20.183
7.可使用windows中iSCSI发起程序进行连接测试。
目标:10.1.20.99
在磁盘管理中可看到,需要使用则需要进行格式化。(使用者进行一次格式化,服务器系统不用格式化。)
---客户端---
安装
iscsi-initiator-utils-6.2.0.868-0.18.ky3.x86_64.rpm
配置iscsi(可不动)
*客户端配置文件:/etc/iscsi/iscsid.conf
/egrep -v "^#|^$"
/etc/iscsi/iscsid.conf
node.session.auth.username =
liaoyi
node.session.auth.password =
qwer1234
discovery.sendtargets.auth.username =
qewr1324
discovery.sendtargets.auth.password = qewr1324
*修改发起者的名字
vim /etc/iscsi/initiatorname.iscsi
开启服务:
service iscsid start(如开启iscsi,因没有记录,则会只启动iscsid,不启动iscsi)
探测:
iscsiadm -m discovery -t sendtargets - p 10.1.20.183
显示节点记录:
iscsiadm -m node
ll -R /var/lib/iscsi/nodes
登陆所有探测到的targets
service iscsi start
登录某个target(不启动iscsi):
iscsiadm -m node -T test -p 10.1.20.183
--login
注销某个target
iscsiadm -m node -T test --logout
删除节点记录:(/var/lib/iscsi/nodes)
iscsiadm -m node -T test -o delete
显示新设备:
fdisk -l
ls /dev/sd*
初始化卷标,分区,格式化,挂载,使用。。。