RHCE --作业六

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

  • 创建两个虚拟机,一个11作为服务端,28作为客户端 ## 一、服务端的配置
  1. 添加一个4G的逻辑卷 //需要创建一个大于4G的硬盘,否则空间不足以创建一个4G的逻辑卷

在这里插入图片描述

在这里插入图片描述

  1. 查看磁盘情况
    在这里插入图片描述

  2. 进行逻辑卷管理操作

[root@localhost ~]# pvcreate /dev/sdb    //创建物理卷
  Physical volume "/dev/sdb" successfully created.
  
[root@localhost ~]# pvs      //查看物理卷
  PV         VG Fmt  Attr PSize   PFree
  /dev/sda2  cl lvm2 a--  <19.00g    0 
  /dev/sdb      lvm2 ---    5.00g 5.00g
  
[root@localhost ~]# vgcreate iscis /dev/sdb  //创建一个名为iscis的卷组
  Volume group "iscis" successfully created
  
[root@localhost ~]# vgs   //查看卷组
  VG    #PV #LV #SN Attr   VSize   VFree 
  cl      1   2   0 wz--n- <19.00g     0 
  iscis   1   0   0 wz--n-  <5.00g <5.00g
  
[root@localhost ~]# lvcreate -n iscsi_lv -L 4G iscis   #在名字叫iscis的卷组上创建一个大小为4G的逻辑卷 
  Logical volume "iscsi_lv" created.
  
[root@localhost ~]# lvs    //查看逻辑卷
  LV       VG    Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root     cl    -wi-ao---- <17.00g                                                    
  swap     cl    -wi-ao----   2.00g                                                    
  iscsi_lv iscis -wi-a-----   4.00g  
  1. 配置iscsi服务,安装包
[root@localhost ~]# yum install -y targetcli
  1. 运行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  //自动保存所有配置

在创建指定本机提供服务的IP地址及端口时,出现错误:
在这里插入图片描述
解决方法:
在这里插入图片描述

6.重启服务配置:

 [root@localhost ~]# systemctl restart target  //重启target服务
[root@localhost ~]# systemctl stop firewalld  //关闭防火墙
[root@localhost ~]# setenforce 0  //关闭selinux

二、客户端的配置

  1. 安装软件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  //查看共享空间

  1. 重启服务
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
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  //查看挂载情况
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值