iscsi

简介: iscsi

systemctl stop firewalld
setenforce 0
添加一块10G硬盘
fdisk /dev/sdb(添加的硬盘)

partprobe /dev/sdb
cat /proc/partitions
yum -y install targetcli
targetcli

/> ls
o- / .................................................................. [...]
o- backstores ....................................................... [...]
| o- block ........................................... [Storage Objects: 0]
| o- fileio .......................................... [Storage Objects: 0]
| o- pscsi ........................................... [Storage Objects: 0]
| o- ramdisk ......................................... [Storage Objects: 0]
o- iscsi ..................................................... [Targets: 0]
o- loopback .................................................. [Targets: 0]
/> cd backstores/block
/backstores/block> create iscsi_stores /dev/sdb1
Created block storage object iscsi_stores using /dev/sdb1.
/backstores/block> cd ../../iscsi
/iscsi> create iqn.2020-12.com.example:iscsidisk
Created target iqn.2020-12.com.example:iscsidisk.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi> ls
o- iscsi ....................................................... [Targets: 1]
o- iqn.2020-12.com.example:iscsidisk ............................ [TPGs: 1]
o- tpg1 .......................................... [no-gen-acls, no-auth]
o- acls ..................................................... [ACLs: 0]
o- luns ..................................................... [LUNs: 0]
o- portals ............................................... [Portals: 1]
o- 0.0.0.0:3260 ................................................ [OK]
/iscsi> cd iqn.2020-12.com.example:iscsidisk/tpg1/acls
/iscsi/iqn.20...isk/tpg1/acls> create iqn.2020-12.com.example:desktop
Created Node ACL for iqn.2020-12.com.example:desktop
/iscsi/iqn.20...isk/tpg1/acls> cd ../luns
/iscsi/iqn.20...isk/tpg1/luns> create /backstores/block/iscsi_stores
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2020-12.com.example:desktop
/iscsi/iqn.20...isk/tpg1/luns> cd ../portals/
/iscsi/iqn.20.../tpg1/portals> create 192.168.1.10
Using default IP port 3260
Could not create NetworkPortal in configFS
/iscsi/iqn.20.../tpg1/portals> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

/iscsi/iqn.20.../tpg1/portals> ls
o- portals ..................................................... [Portals: 1]
o- 0.0.0.0:3260 ...................................................... [OK]
/iscsi/iqn.20.../tpg1/portals> cd /

/> ls
o- / .................................................................. [...]
o- backstores ....................................................... [...]
| o- block ........................................... [Storage Objects: 1]
| | o- iscsi_stores ............ [/dev/sdb1 (10.0GiB) write-thru activated]
| o- fileio .......................................... [Storage Objects: 0]
| o- pscsi ........................................... [Storage Objects: 0]
| o- ramdisk ......................................... [Storage Objects: 0]
o- iscsi ..................................................... [Targets: 1]
| o- iqn.2020-12.com.example:iscsidisk .......................... [TPGs: 1]
| o- tpg1 ........................................ [no-gen-acls, no-auth]
| o- acls ................................................... [ACLs: 1]
| | o- iqn.2020-12.com.example:desktop ............... [Mapped LUNs: 1]
| | o- mapped_lun0 ................... [lun0 block/iscsi_stores (rw)]
| o- luns ................................................... [LUNs: 1]
| | o- lun0 .......................... [block/iscsi_stores (/dev/sdb1)]
| o- portals ............................................. [Portals: 1]
| o- 0.0.0.0:3260 .............................................. [OK]
o- loopback .................................................. [Targets: 0]
/>
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

客户端:
systemctl stop firewalld
setenforce 0
iscsiadm -m discovery -t sendtargets -p 192.168.1.10
vim /etc/iscsi/initiatorname.iscsi
添加或修改以下内容:
InitiatorName=iqn.2020-12.com.example:desktop
systemctl restart iscsid
systemctl enable iscsid
iscsiadm -m node -T iqn.2020-12.com.example:iscsidisk 192.168.1.10 -l
fdisk -l

fdisk -l /dev/sdb
mkfs.xfs /dev/sdb1
mkdir /aaa #挂载点
blkid #查看硬盘UUID
vim /etc/fstab
添加以下内容:
UUID=5e37e44f-482c-459e-8046-7e26aab7f8f4 /aaa xfs defaults,_netdev 0 0
mount -a
df -h

相关文章
|
6月前
|
数据安全/隐私保护
|
6月前
|
存储 运维 网络协议
ISCSI详解(二)——ISCSI基础知识
ISCSI详解(二)——ISCSI基础知识
109 4
|
2月前
|
存储 网络协议 固态存储
ubutu上配置iscsi
ubutu上配置iscsi
|
Linux Shell 开发工具
|
Shell Linux 开发工具
|
存储 网络协议 IDE
|
存储 网络协议 开发工具
|
存储 Unix Linux
|
开发工具