1003作业

本文档详细介绍了如何在服务端配置iSCSI服务,包括创建4G逻辑卷,设置targetcli,开启服务,并关闭防火墙和SELinux。接着在客户端安装iscsi-initiator-utils,设置 initiator name,发现并登录共享存储,创建并格式化2300MB ext4分区,实现自动挂载。此外,还设置了时间服务器,以便客户端在每天9:00更新时间。
摘要由CSDN通过智能技术生成

题目:
1、在iscsi服务端将大小为4G逻辑卷共享给客户端,在客户端系统启动期间,该iscsi设备自动加载。该块设备上包含一个大小为2300MB的分区,文件系统类型为ext4,此分区挂载在/share/disk上。
2、搭建时间服务器,客户端可在每天早晨的9:00整从ntp服务器更新自己的时间。

一.向系统添加一块大小为5G的硬盘

[root@localhost ~]# lsblk
sda           8:0    0    5G  0 disk

二.创建大小为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      

三.装包

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

四.运行targetcli命令进行配置

[root@localhost ~]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.53
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/> ls

/> backstores/block create name=bai dev=/dev/iscis/iscsi_lv   //生成及指定后端存储(backstore,后端存储
出现绿色行指令无误成功;红色指令表示错误 

/> ls

/>  iscsi/ create iqn.2021-08.com.example:bai  //生成target磁盘组
出现绿色行指令无误成功;红色指令表示错误 

/> ls

/> iscsi/iqn.2021-08.com.example:bai/tpg1/luns create /backstores/block/bai   //进行lun关联
出现绿色行指令无误成功;红色指令表示错误 

/> ls

/> iscsi/iqn.2021-08.com.example:bai/tpg1/acls create  iqn.2021-08.com.example:abc  //设置ACL验证,设置客户端声称的名字
出现绿色行指令无误成功;红色指令表示错误 

/> ls

/> iscsi/iqn.2021-08.com.example:bai/tpg1/portals create ip_address=192.168.19.130  //指定本机提供服务的IP地址及端口,如果不指定端口和ip默认为所有的IP和端口都能进行服务
出现绿色行指令无误成功;红色指令表示错误 

/> ls

/> exit  //自动保存所有配置

五.关闭防火墙,selinux,启动服务

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl restart target

六.安装软件iscsi-initiator-utils

[root@localhost ~]# yum -y install iscsi-initiator-utils 
[root@localhost ~]# vi /etc/iscsi/initiatorname.iscsi  //设置客户端声称的名字,使其与服务端设置的名字一致
修改的内容为:
InitiatorName=iqn.2021-08.com.example:abc

[root@localhost ~]# systemctl restart iscsid  //客户端刷新声称名字的服务

[root@localhost ~]# iscsiadm --mode discovery --type sendtargets --portal 192.168.19.130 --discover//客户端发现共享存储

[root@client ~]# iscsiadm -m node -l  //在客户端登录

[root@client ~]# lsblk  //查看共享空间

七.重启服务

systemctl restart iscsi
systemctl enable iscsi 
[root@client ~]# fdisk /dev/sdb  //创建一个大小为2300M的ext4的分区

[root@client ~]# mkfs.ext4 /dev/sdb1  //格式化分区

[root@client ~]# blkid /dev/sdb1   //查看分区详细信息

[root@client ~]# mkdir /share/disk -p  //创建目录/share/disk

[root@client ~]# blkid  //查看uuid,等会vi要用
/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  //#开机自动挂载使用UUID,UUID可使用blkid进行查看

[root@client ~]# mount -a //测试刚刚写入文件是否正确

[root@client ~]# systemctl enable iscsid  //设为开机自动,这块共享硬盘也能一直使用

[root@client ~]# df -h  //查看挂载情况

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值