一、 安装iSCSI target/initiator
Linux SCSI target framework (tgt):http://stgt.sourceforge.net/
二、target
/usr/sbin/tgtd
检查tcp端口号有没有被占用:
netstat -tlunp | grep tgt
Create a new target device
Create a target device:
# tgtadm --lld iscsi --mode target --op new --tid=1 --targetname iqn.2017.2.com.gao:for.all
建立一个img
dd if=/dev/zero of=/home/scsi./disk1.img bs=1MB count=20480
添加一个LUN:
Add a logical unit (LUN)
You can add a logical unit to an existing target device by typing:
# tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 -b /home/scsi/disk1.img
开放给192.168.85.0/24网段内的主机访问:
tgtadm -L iscsi -o bind -m target -t 1 -I 10.32.155.0/24
防火墙开放:
iptables -A INPUT -p tcp -s 10.32.155.0/24 --dport 3260 -j ACCEPT
关闭防火墙:
systemctl stop firewalld.service
查看设置的tun:
tgtadm -L iscsi -o show -m target
删除一个tun:
tgtadm --lld iscsi --mode logicalunit --op delete --tid 1 --lun 1
三、initiator
iscsiadm -m discovery -t sendtargets -p 10.32.153.244
iscsiadm -m node -T iqn.2017.2.com.gao:for.all -p 10.32.153.244 -l
fdisk –l 就能看到了
四、qemu使能iscsi功能
要升级libiscsi库,到github下载
https://github.com/sahlberg/libiscsi
Installation
============
./autogen.sh
./configure
make
sudo make install
cp ./local/lib/libiscsi.so.8 /lib/
启动脚本:
qemu-system-x86_64 -m 2G -smp 4 -enable-kvm -vnc localhost:2 \
-iscsi initiator-name=iqn.2017.2.com.gao:for.all \
-drive file=iscsi://10.32.155.244/iqn.2017.2.com.gao:for.all/1 \
-cdrom iscsi://10.32.155.244/iqn.2017.2.com.gao:for.all/2 \
-netdev type=tap,id=eth0,script=/etc/qemu-ifup_backup,downscript=/etc/qemu-ifdown_backup \
-device e1000,netdev=eth0,mac=12:03:04:05:06:08
iscsi设置方法[转朋友的总结]
最新推荐文章于 2024-10-09 09:03:19 发布