创建lun:
/iscsi/iqn.20...sg:disk1/tpg1> luns/ create /backstores/block/block1
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2015-02.com.sg:diskpasswd
/iscsi/iqn.20...sg:disk1/tpg1> luns/ create /backstores/block/block2
Created LUN 1.
Created LUN 1->1 mapping in node ACL iqn.2015-02.com.sg:diskpasswd
o- luns .......................................................................................................... [LUNs: 2]
| | o- lun0 ....................................................................................... [block/block1 (/dev/sdb7)]
| | o- lun1 ....................................................................................... [block/block2 (/dev/sdb8)]
portal创建共享端口和地址:
/iscsi/iqn.20...sg:disk1/tpg1> portals/ create 10.35.89.32
Using default IP port 3260
Created network portal 10.35.89.32:3260.
exit退出并保存:
Configuration saved to /etc/target/saveconfig.json
配置文件保存在:/etc/target/saveconfig.json,可以直接修改配置文件
三、客户端配置iscsi连接
安装target包:
[root@client ~]# yum install target\* -y
查看fuw服务器端共享的内容:
[root@client ~]# iscsiadm -m discovery -t st -p 10.35.89.32
10.35.89.32:3260,1 iqn.2015-02.com.sg:disk1
编辑/etc/iscsi/initiatorname.iscsi文件,配置服务器端共享的名字和密码:
InitiatorName=iqn.2015-02.com.sg:diskpasswd
重启iscscid服务:
[root@client ~]# systemctl restart iscsid.service
挂载服务器端共享的内容:
[root@client ~]# iscsiadm -m node -T iqn.2015-02.com.sg:disk1 -p 10.35.89.32 -l
挂载成功后,使用fdisk命令即可查看到新增加的两块磁盘:
断开挂载的连接:
[root@client ~]# iscsiadm -m node -T iqn.2015-02.com.sg:disk1 -p 10.35.89.32 -u
使用fdisk命令划分共享的磁盘,格式化,并挂载文件夹,编辑fstab文件设置开机自动挂载:
[root@client ~]# fdisk /dev/sdb
Device Boot Start End Blocks Id System
/dev/sdb1 8192 114687 53248 83 Linux
[root@client ~]# mkfs.xfs /dev/sdb1
[root@client /]# mount /dev/sdb1 /aa