ISCSI服务

准备环境:需要两台虚拟机,并且要求IP不同,一台server端,一台做client端 。

首先在SERVER端操作。

第一步:

[root@localhost ~]# yum -y install targetd targetcli

下载这两个软件包。

[root@localhost ~]# systemctl start target 

重新启动这个服务。

[root@localhost ~]# systemctl enable target
Created symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/target.service.

开机自动启动这个服务。

[root@localhost ~]# systemctl status target
● target.service - Restore LIO kernel target configuration
   Loaded: loaded (/usr/lib/systemd/system/target.service; enabled; vendor preset: disabled)
   Active: active (exited) since 四 2022-04-28 20:13:54 CST; 2min 59s ago
 Main PID: 3350 (code=exited, status=0/SUCCESS)

4月 28 20:13:54 localhost.localdomain systemd[1]: Starting Restore LIO ke...
4月 28 20:13:54 localhost.localdomain target[3350]: No saved config file ...
4月 28 20:13:54 localhost.localdomain systemd[1]: Started Restore LIO ker...
Hint: Some lines were ellipsized, use -l to show in full.

查看这个程序的状态。

第二步:

设置防火墙。

[root@localhost ~]# firewall-cmd --add-port=3260/tcp --permanent 
success

添加3260这个端口号。

[root@localhost ~]# firewall-cmd --reload
success

 重新启动。

[root@localhost ~]# firewall-cmd --list-ports
3260/tcp

列出防火墙的端口信息(检测是否添加成功)

第三步:

执行targetcli 这个命令,并指定要发布的磁盘。

[root@localhost ~]# targetcli 
targetcli shell version 2.1.53
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/>  /backstores/block create server0.disk1 /dev/sdc 
Created block storage object server0.disk1 using /dev/sdc.

创建qn。

/> /iscsi create iqn.2020-05.com.bdqn:disk1
Created target iqn.2020-05.com.bdqn:disk1.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.

将创建的qn与客户端IP进行绑定。

/> /iscsi/iqn.2020-05.com.bdqn:disk1/tpg1/acls create iqn.2020-05.com.bdqn:client1
Created Node ACL for iqn.2020-05.com.bdqn:client1

创建LUN并绑定块。

/> /iscsi/iqn.2020-05.com.bdqn:disk1/tpg1/luns create /backstores/block/server0.disk1
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2020-05.com.bdqn:client1

Client 端

第四步:

[root@localhost ~]# yum -y install iscsi-initiator-utils

下载这个服务。

[root@localhost ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2020-05.com.bdqn:client1

编辑这个文件如图所示。

calhost ~]# systemctl enable iscsi 
[root@localhost ~]# systemctl status iscsi 
● iscsi.service - Login and scanning of iSCSI devices
   Loaded: loaded (/usr/lib/systemd/system/iscsi.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
Condition: start condition failed at 四 2022-04-28 20:54:07 CST; 36s ago
     Docs: man:iscsiadm(8)
           man:iscsid(8)

4月 28 20:38:45 localhost.localdomain systemd[1]: Unit iscsi.service cannot be rel....
4月 28 20:38:45 localhost.localdomain systemd[1]: Unit iscsi.service cannot be rel....
Hint: Some lines were ellipsized, use -l to show in full.

启动这个服务。

[root@localhost ~]#  iscsiadm -m discovery -t st -p 192.168.190.128
192.168.190.128:3260,1 iqn.2020-05.com.bdqn:disk1

发现存储

[root@localhost ~]# iscsiadm -m discovery -t st -p 192.168.190.128 -l 
192.168.190.128:3260,1 iqn.2020-05.com.bdqn:disk1
Logging in to [iface: default, target: iqn.2020-05.com.bdqn:disk1, portal: 192.168.190.128,3260] (multiple)
Login to [iface: default, target: iqn.2020-05.com.bdqn:disk1, portal: 192.168.190.128,3260] successful.

登陆存储

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值