Redhat平台配置iscsi共享(RHCE考试题)

1 篇文章 0 订阅
1 篇文章 0 订阅

iscsi简介

iSCSI(Internet Small Computer System Interface,发音为/ˈаɪskʌzi/),Internet小型计算机系统接口,又称为IP-SAN,是一种基于因特网及SCSI-3协议下的存储技术,由IETF提出,并于2003年2月11日成为正式的标准。与传统的SCSI技术比较起来,iSCSI技术有以下三个革命性的变化:

  1. 把原来只用于本机的SCSI协议透过TCP/IP网络发送,使连接距离可作无限的地域延伸;
  2. 连接的服务器数量无限(原来的SCSI-3的上限是15);
  3. 由于是服务器架构,因此也可以实现在线扩容以至动态部署。

iSCSI利用了TCP/IP的port 860 和 3260 作为沟通的渠道。透过两部计算机之间利用iSCSI的协议来交换SCSI命令,让计算机可以透过高速的局域网集线来把SAN模拟成为本地的储存装置。【百度百科】

iscsi安装

安装软件并启动服务

[root@system1 ~]# yum install targetcli ‐y
[root@system1 ~]# systemctl enable target
[root@system1 ~]# systemctl start target

设置防火墙

[root@system1 Desktop]# firewall-cmd --permanent --add-rich-rule 'rule family="ipv4" source address="172.24.8.12/32" port port=3260 protocol=tcp accept'	#允许来自172.24.8.12/32的IP端口为3260访问
success

创建逻辑卷作为共享卷

[root@system1 ~]# fdisk /dev/sda
Command (m for help): n
Partition type:
p primary (3 primary, 0 extended, 1 free)
e extended
Select (default p): e
Partition number (1-4, default 4): 直接回车
First sector (32917504-41943039, default 32917504): 直接回车
Using default value 32917504
Last sector, +sectors or +size{K,M,G} (32917504-41943039, default 41943039): 
Partition 4 of type Linux and of size 4.3 GiB is set
Command (m for help): n
All primary partitions are in use
Adding logical partition 5
First sector (32919552-41943039, default 32919552): 
Using default value 32919552
Last sector, +sectors or +size{K,M,G} (32919552-41943039, default 41943039): +3G
Partition 5 of type Linux and of size 3 GiB is set
Command (m for help): t
Partition number (1‐5, default 5): 直接回车
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): w

更新内核分区表

[root@system1 Desktop]# partprobe /dev/sda

创建PV物理卷

[root@system1 Desktop]# pvcreate /dev/sda5
  Physical volume "/dev/sda5" successfully created

创建逻辑卷组

[root@system1 Desktop]# vgcreate iscsi_vg /dev/sda5
  Volume group "iscsi_vg" successfully created

创建逻辑卷

[root@system1 Desktop]# lvcreate -n iscsi_store -l 100%VG iscsi_vg
  Logical volume "iscsi_store" created

配置iscsi服务器端

[root@system1 Desktop]# targetcli
targetcli shell version 2.1.fb41
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/> backstores/block/ create name=iscsi_store1 dev=/dev/iscsi_vg/iscsi_store	#定义一个块设备
Created block storage object iscsi_store1 using /dev/iscsi_vg/iscsi_store.
/> cd iscsi/
/iscsi> create iqn.2019-10.com.example.group8:system1	#定义一个iscsi
Created target iqn.2019-10.com.example.group8:system1.
Created TPG 1.
Default portal not created, TPGs within a target cannot share ip:port.
/iscsi> cd iqn.2019-10.com.example.group8:system1/tpg1/
/iscsi/iqn.20...:system1/tpg1> luns/ create /backstores/block/iscsi_store	#把定义好的块设备通过iscsi共享出去
Created LUN 0.
/iscsi/iqn.20...:system1/tpg1> acls/ create iqn.2019-10.com.example.group8:system2
Created Node ACL for iqn.2019-10.com.example.group8:system2	#创建基于 iqn 的 acl:允许该名字的客户端访问本 iscsi 的 tagert
Created mapped LUN 0.
/iscsi/iqn.20...:system1/tpg1> portals/ create 172.24.8.11 3260	#定义 target 的入口(客户使用什么 IP 和端口访问)
Using default IP port 3260
Created network portal 172.24.8.11:3260.
/backstores> cd /
/> saveconfig 	#保存设置
/> exit	#退出
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

配置iscsi客户端

安装客户端软件包

[root@system2 ~]# yum install iscsi‐initiator‐utils ‐y

配置 iscsi 客户端的名字

[root@system2 ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2019-10.com.example.group8:system2

启动服务并设置开机启动

[root@system2 ~]# systemctl enable iscsi iscsid
[root@system2 ~]# systemctl restart iscsi iscsid

发现iscsi

[root@system2 Desktop]# iscsiadm -m discovery -t st -p 172.24.8.11
172.24.8.11:3260,1 iqn.2014-08.com.example.group8:system1
172.24.8.11:3260,1 iqn.2019-10.com.example.group8:system1

连接iscsi

[root@system2 Desktop]# iscsiadm -m node -l

查看本地是否多了块设备(sdc下的sdc1就是system1上共享出来的)

[root@system2 Desktop]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   20G  0 disk 
├─sda1   8:1    0  9.8G  0 part /
└─sda2   8:2    0    2G  0 part [SWAP]
sdb      8:16   0    3G  0 disk 
└─sdb1   8:17   0  2.1G  0 part /mnt/data
sdc      8:32   0    3G  0 disk 
└─sdc1   8:33   0  2.1G  0 part

挂载iscsi

分区并格式化

[root@system2 ~]# fdisk /dev/sdc
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1‐4, default 1): 直接回车
First sector (8192‐6283263, default 8192): 直接回车
Using default value 8192
Last sector, +sectors or +size{K,M,G} (8192‐6283263, default 6283263): +2100M
Partition 1 of type Linux and of size 2.1 GiB is set
Command (m for help): w

格式化

[root@system2 Desktop]# partprobe /dev/sdc
[root@system2 Desktop]# mkfs
mkfs         mkfs.cramfs  mkfs.ext3    mkfs.fat     mkfs.msdos   mkfs.xfs     
mkfs.btrfs   mkfs.ext2    mkfs.ext4    mkfs.minix   mkfs.vfat    
[root@system2 Desktop]# mkfs
mkfs         mkfs.cramfs  mkfs.ext3    mkfs.fat     mkfs.msdos   mkfs.xfs     
mkfs.btrfs   mkfs.ext2    mkfs.ext4    mkfs.minix   mkfs.vfat    
[root@system2 Desktop]# mkfs.ext4 /dev/sdc1

创建挂载点

[root@system2 Desktop]# mkdir /mnt/data1

设置开机自动挂载

[root@system2 Desktop]# vim /etc/fstab 
/dev/sdc1       /mnt/data1      ext4    defaults,_netdev        0       0

注意:这里因为是网络块设备要加_netdev否则重启系统起不来

挂载

[root@system2 Desktop]# mount -a
[root@system2 Desktop]# df -h
Filesystem          Size  Used Avail Use% Mounted on
/dev/sda1           9.8G  3.1G  6.7G  32% /
devtmpfs            765M     0  765M   0% /dev
tmpfs               773M  140K  773M   1% /dev/shm
tmpfs               773M  8.9M  765M   2% /run
tmpfs               773M     0  773M   0% /sys/fs/cgroup
/dev/sdb1           2.0G  6.2M  1.9G   1% /mnt/data
//system1/devops    9.8G  3.3G  6.5G  34% /mnt/dev
system1:/public     9.8G  3.3G  6.5G  34% /mnt/nfsmount
system1:/protected  9.8G  3.3G  6.5G  34% /mnt/nfssecure
/dev/sdc1           2.0G  6.2M  1.9G   1% /mnt/data1

至此,iscsi已经配置完成,iscsi考试形式类似。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值