yum install scsi-target-utils -y
dd if=/dev/zero of=iscsi.img bs=1G count=2
chcon -R -t tgtd_var_lib_t /iscsi.img
vi /etc/tgt/targets.conf
<target iqn.2017-02.com.junxi:iscsi>
backing-store /iscsi.img
initiator-address 192.168.1.0/24
write-cache off
</target>
systemctl restart tgtd.service
lsof -i:3260
tgt-admin --show
测试在windows上添加一个磁盘
---------------------------------------------------------------------------------------------------------------------------------------------------------
实现linux的iscsi客户端 并实现chap加密
server端
vi /etc/tgt/targets.conf
<target iqn.2017-02.com.junxi:iscsi>
backing-store /iscsi.img
initiator-address 192.168.1.0/24
incominguser han han
write-cache off
</target>
systemctl restart tgtd.service
tgt-admin --show
客户端
yum install iscsi-initiator-utils -y
vi /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2017-02.com.han:hanlei
vi /etc/iscsi/iscsid.conf
node.session.auth.authmethod = CHAP
node.session.auth.username = han
node.session.auth.password = han
node.session.timeo.replacement_timeout = 20
iscsiadm -m discovery -t sendtargets -p 192.168.1.142
iscsiadm -m node -T iqn.2017-02.com.junxi:iscsi -l
lsblk
iscsiadm -m node -T iqn.2017-02.com.junxi:iscsi -u #卸载