2021-08-10

作业:在iscsi服务端将大小为4G逻辑卷共享给客户端,在客户端系统启动期间,该iscsi设备自动加载。该块设备上包含一个大小为2300MB的分区,文件系统类型为ext4,此分区在系统启动期间同时自动挂载在/share/disk上
1.首先向系统添加一块5G的硬盘,然后查看
[root@localhost ~]# lsblk
sda 8:0 0 5G 0 disk
2.然后创建大小为4G的逻辑卷
[root@localhost ~]# pvcreate /dev/sda
Physical volume “/dev/sda” successfully created.
[root@localhost ~]# vgcreate iscsi /dev/sda
Volume group “iscsi” successfully created
[root@localhost ~]# lvcreate -n iscsilv -L 4G iscsi
Logical volume “iscsilv” created.
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda iscsi lvm2 a-- <5.00g 1020.00m
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
iscsi 1 1 0 wz–n- <5.00g 1020.00m
[root@localhost ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
iscsilv iscsi -wi-a----- 4.00g
3.配置iscsi服务,首先安装包
[root@localhost ~]# yum install -y targetcli
4.然后配置
5.然后关闭防火墙,selinux,启动服务
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl restart target
6.在当前主机能成功发现此共享
[root@localhost ~]# iscsiadm -m discovery -t st -p 192.168.136.152
192.168.136.152:3260,1 iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.c21ab93a6c75
7.接下来去客户端配置,先装包
[root@client ~]# yum install iscsi-initiator-utils -y
8.然后编辑名字
[root@client ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2021-08.linux.redhat:client
9.关闭防火墙,selinux,启动服务
[root@client ~]# systemctl stop firewalld
[root@client ~]# setenforce 0
[root@client ~]# systemctl restart iscsi iscsid
10.客户端也能成功发现此共享
[root@client ~]# iscsiadm -m discovery -t st -p 192.168.136.152
192.168.136.152:3260,1 iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.c21ab93a6c75
11.然后在客户端登陆
[root@client ~]# iscsiadm -m node -l
Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.c21ab93a6c75, portal: 192.168.136.152,3260] (multiple)
Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.c21ab93a6c75, portal: 192.168.136.152,3260] successful.
12.查看成功出现
[root@client ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 4G 0 disk

[root@client ~]# lsscsi
[33:0:0:0] disk LIO-ORG lun1 4.0 /dev/sdb

13.然后对此设备分区
14. 接下来格式化分区

[root@client ~]# mkfs.ext4 /dev/sdb1
15.创建目录
[root@client ~]# mkdir /share/disk -p
16.查看uuid,编辑配置文件实现自动挂在

[root@client ~]# blkid
/dev/sdb1: UUID=“a39aaaaa-8297-4e82-a240-a06de70a047b” TYPE=“ext4”
[root@client ~]# vim /etc/fstab
UUID=a39aaaaa-8297-4e82-a240-a06de70a047b /share/disk ext4 defaults,_netdev 0 0
[root@client ~]# mount -a
[root@client ~]# df -h
/dev/sdb1 2.2G 6.8M 2.1G 1% /share/disk

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值