Linux 部署 iSCSI 客户端配置(Linux)

Linux 部署 iSCSI 客户端配置(Linux)

客户端环境

Client :RHEL8
IP : 192.168.121.11

一、测试与服务端的连通性

[root@Client-linux ~]# ping 192.168.121.10
PING 192.168.121.10 (192.168.121.10) 56(84) bytes of data.
64 bytes from 192.168.121.10: icmp_seq=1 ttl=64 time=0.833 ms
64 bytes from 192.168.121.10: icmp_seq=2 ttl=64 time=0.454 ms
64 bytes from 192.168.121.10: icmp_seq=3 ttl=64 time=0.395 ms
^C
--- 192.168.121.10 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 16ms
rtt min/avg/max/mdev = 0.395/0.560/0.833/0.195 ms

二、安装 ISCSI 客户端程序 :iscsi-initiator-utils

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

三、客户端修改 ISCSI 配置文件 :/etc/iscsi/ 目录下俩个的文件

  1. initiatorname.iscsi :定义客户端连接的名称(iqn.2020-12.linux.iscsi.server:client)
[root@Client-linux ~]# vim /etc/iscsi/initiatorname.iscsi
[root@Client-linux ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2020-12.linux.iscis.server:client
  1. iscsid.conf :启用 CHAP 认证

Linux 部署 iSCSI 客户端配置(Linux)

四、启动 iscsid 服务

[root@Client-linux ~]# systemctl start iscsid
[root@Client-linux ~]# systemctl enable iscsid
Created symlink /etc/systemd/system/multi-user.target.wants/iscsid.service → /usr/lib/systemd/system/iscsid.service.
[root@Client-linux ~]# systemctl status iscsid
● iscsid.service - Open-iSCSI
Loaded: loaded (/usr/lib/systemd/system/iscsid.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2020-12-17 03:39:46 CST; 14s ago
Docs: man:iscsid(8)
man:iscsiuio(8)
man:iscsiadm(8)
Main PID: 2063 (iscsid)
Status: "Ready to process requests"
Tasks: 1 (limit: 11340)
Memory: 7.8M
CGroup: /system.slice/iscsid.service
└─2063 /usr/sbin/iscsid -f Dec 17 03:39:46 Client-linux systemd[1]: Starting Open-iSCSI...
Dec 17 03:39:46 Client-linux systemd[1]: Started Open-iSCSI.

五、客户端发现存储服务器(服务端共享的存储设备)

[root@Client-linux ~]# iscsiadm -m discovery -t st -p 192.168.121.10
192.168.121.10:3260,1 iqn.2020-12.linux.iscis.server:server

或者

[root@Client-linux ~]# iscsiadm -m discovery -t sendtargets -p 192.168.121.10
192.168.121.10:3260,1 iqn.2020-12.linux.iscis.server:server

五、客户端登陆存储服务器

  1. 首先查看本地所拥有的磁盘
[root@Client-linux ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 7.3G 0 rom
nvme0n1 259:0 0 80G 0 disk
├─nvme0n1p1 259:1 0 1G 0 part /boot
└─nvme0n1p2 259:2 0 79G 0 part
├─rhel-root 253:0 0 50G 0 lvm /
├─rhel-swap 253:1 0 2G 0 lvm [SWAP]
└─rhel-home 253:2 0 27G 0 lvm /home
  1. 登陆存储服务器
[root@Client-linux ~]# iscsiadm -m node -T iqn.2020-12.linux.iscis.server:server -p 192.168.121.10 --login   (用 -l 选项也可以)
Logging in to [iface: default, target: iqn.2020-12.linux.iscis.server:server, portal: 192.168.121.10,3260]
Login to [iface: default, target: iqn.2020-12.linux.iscis.server:server, portal: 192.168.121.10,3260] successful.

六、查看 ISCSI 在本地映射的磁盘

[root@Client-linux ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk //映射的第一块磁盘
sdb 8:16 0 1G 0 disk //映射的第二块磁盘
sr0 11:0 1 7.3G 0 rom
nvme0n1 259:0 0 80G 0 disk
├─nvme0n1p1 259:1 0 1G 0 part /boot
└─nvme0n1p2 259:2 0 79G 0 part
├─rhel-root 253:0 0 50G 0 lvm /
├─rhel-swap 253:1 0 2G 0 lvm [SWAP]
└─rhel-home 253:2 0 27G 0 lvm /home
上一篇:[转]Delphi中QuotedStr介绍及使用


下一篇:005.iSCSI客户端配置示例-Windows