Target配置(提供存储)
Target的IP地址是192.168.122.243
1.安装所需软件;
[root@s1 ~]# yum install targetcli -y
2. 用targetcli进入交互式配置;
[root@s1 ~]# targetcli
3. 在targetcli中,添加块设备;
/> ls /> cd /backstores/ /backstores> block/ create block1 /dev/vda
4. 创建node
/backstores> cd /iscsi /iscsi> create iqn.2015-01.com.example:remotedisk1
5. 添加ACL
/iscsi> cd iqn.2015-01.com.example:remotedisk1/tpg1/ /iscsi/iqn.20...otedisk1/tpg1> acls/ create iqn.2015-01.com.example:desktop0 Created Node ACL for iqn.2015-01.com.example:desktop0
6. 在Node中添加block
/iscsi/iqn.20...otedisk1/tpg1> luns/ create /backstores/block/block1 Created LUN 0. Created LUN 0->0 mapping in node ACL iqn.2015-01.com.example:desktop0
7. 创建入口(portals),create后面不跟IP的话默认是0.0.0.0
/iscsi/iqn.20...otedisk1/tpg1> portals/ create Using default IP port 3260 Binding to INADDR_ANY (0.0.0.0) Created network portal 0.0.0.0:3260.
8. 保存退出
/> exit Global pref auto_save_on_exit=true Last 10 configs saved in /etc/target/backup. Configuration saved to /etc/target/saveconfig.json
9. 添加防火墙规则,重启服务
[root@s1 ~]# firewall-cmd --add-port=3260/tcp --permanent [root@s1 ~]# firewall-cmd --reload [root@s1 ~]# systemctl enable target [root@s1 ~]# systemctl restart target.service
Initiator配置(访问iscsi存储)
1. 安装所需软件 iscsi-initiator-utils
[root@r7-h1 ~]# yum install iscsi-initiator-utils -y
2. 修改 /etc/iscsi/initiatorname.iscsi (修改后要重启iscsid才能生效)
把Node改成Target中ACL的IQN.
iqn.2015-01.com.example:desktop0
3. 重启iscsi服务
[root@r7-h1 ~]# systemctl restart iscsi [root@r7-h1 ~]# systemctl restart iscsid
4. Descovery
[root@r7-h1 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.122.243 192.168.122.243:3260,1 iqn.2015-01.com.example:remotedisk1
5. Login
[root@r7-h1 ~]# iscsiadm --mode node --targetname iqn.2015-01.com.example:remotedisk1 --portal 192.168.122.243:3260 --login Logging in to [iface: default, target: iqn.2015-01.com.example:remotedisk1, portal: 192.168.122.243,3260] (multiple) Login to [iface: default, target: iqn.2015-01.com.example:remotedisk1, portal: 192.168.122.243,3260] successful.
6. 检查
[root@r7-h1 ~]# iscsiadm -m session -P 3
7. 确认iscsi开机启动;
[root@r7-h1 ~]# systemctl enable iscsid.service [root@r7-h1 ~]# systemctl enable iscsi.service