iscsi共享分区测试
要求:
在服务器端Server0上创建一个分区/dev/sdb1(无需格式化),配置成iscsi target设备,块设备名称为sun1,iqn名称为iqn.2018-01.com.ultrapower:testserverdisk1,并配置acls仅允许desktop1访问。
在客户端服务器desktop1上使用server0上的分区,将其格式化为500MB的xfs分区,并自动挂载到/mydisk目录下。
一、服务端安装配置
安装软件包
# yum install targetcli
配置防火墙策略
firewall-cmd --permanent --add-port=3260/tcp
firewall-cmd –reload
创建共享设备
[root@server0 ~]# targetcli
targetcli shell version 2.1.fb46
Copyright - by Datera, Inc and others.
For help on commands, type 'help'.
/backstores/block> create san1 /dev/sdb1 --把新分区/dev/sdb1创建为一个块设备,名称为san1
Created block storage object san1 using /dev/sdb1.
/backstores/block> /iscsi create iqn.-.com.ultrapower:testServerDisk1 --创建iscsi设备,并指定名称
Created target iqn.-.com.ultrapower:testserverdisk1.
Created TPG .
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port . /> ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- block .................................................................................................. [Storage Objects: ]
| | o- san1 ......................................................................... [/dev/sdb1 ( bytes) write-thru deactivated]
| | o- alua ................................................................................................... [ALUA Groups: ]
| | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
| o- fileio ................................................................................................. [Storage Objects: ]
| o- pscsi .................................................................................................. [Storage Objects: ]
| o- ramdisk ................................................................................................ [Storage Objects: ]
o- iscsi ............................................................................................................ [Targets: ]
| o- iqn.-.com.ultrapower:testserverdisk1 ........................................................................ [TPGs: ]
| o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
| o- acls .......................................................................................................... [ACLs: ]
| o- luns .......................................................................................................... [LUNs: ]
| o- portals .................................................................................................... [Portals: ]
| o- 0.0.0.0: ..................................................................................................... [OK]
o- loopback ......................................................................................................... [Targets: ]
/>
acls:允许谁访问
lun设备:把iscsi设备和block设备sun1进行关联
portals: 设备iqn监听的端口
#设置acl参数,指明网络上“仅允许desktopX.example.com主机访问”主机可以访问该sicsi设备
/> /iscsi/iqn.-.com.ultrapower:testserverdisk1/tpg1/acls create iqn.-.com.ultrapower:desktop1
Created Node ACL for iqn.-.com.ultrapower:desktop1
#设置lun参数,指明lun管理的iscsi设备(iqn.2018-01.com.ultrapower:testserverdisk1)对应的块设备为san1 。
/> /iscsi/iqn.-.com.ultrapower:testserverdisk1/tpg1/luns create /backstores/block/san1
Created LUN .
Created LUN -> mapping in node ACL iqn.-.com.ultrapower:desktop1
#设置portal参数,指明共享iscsi设备的IP和端口号,默认为“0.0.0.0 3260”,删除后,重新配置portal参数。
/> /iscsi/iqn.-.com.ultrapower:testserverdisk1/tpg1/portals create 192.168.100.200
Using default IP port
Could not create NetworkPortal in configFS
/> ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- block .................................................................................................. [Storage Objects: ]
| | o- san1 ........................................................................... [/dev/sdb1 ( bytes) write-thru activated]
| | o- alua ................................................................................................... [ALUA Groups: ]
| | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
| o- fileio ................................................................................................. [Storage Objects: ]
| o- pscsi .................................................................................................. [Storage Objects: ]
| o- ramdisk ................................................................................................ [Storage Objects: ]
o- iscsi ............................................................................................................ [Targets: ]
| o- iqn.-.com.ultrapower:testserverdisk1 ........................................................................ [TPGs: ]
| o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
| o- acls .......................................................................................................... [ACLs: ]
| | o- iqn.-.com.ultrapower:desktop1 .................................................................. [Mapped LUNs: ]
| | o- mapped_lun0 .................................................................................. [lun0 block/san1 (rw)]
| o- luns .......................................................................................................... [LUNs: ]
| | o- lun0 ...................................................................... [block/san1 (/dev/sdb1) (default_tg_pt_gp)]
| o- portals .................................................................................................... [Portals: ]
| o- 0.0.0.0: ..................................................................................................... [OK]
o- loopback ......................................................................................................... [Targets: ]
/>
/iscsi/iqn..../tpg1/portals> delete 0.0.0.0 --把默认的删除。
Deleted network portal 0.0.0.0:
/iscsi/iqn..../tpg1/portals> cd /
/> iscsi/iqn.-.com.ultrapower:testserverdisk1/tpg1/portals create 192.168.100.200
Using default IP port
Created network portal 192.168.100.200:.
/> saveconfig --保存退出。
Last configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
/> exit
服务端配置完成。
[root@server0 ~]# systemctl restart target --重启target服务
二、客户端安装配置
Desktop服务器上安装iscsi-initiator-utils软件包,或者iscsi*
[root@desktop1 home]# yum install -y iscsi-initiator-utils --安装软件包
[root@desktop1 home]# vi /etc/iscsi/initiatorname.iscsi --修改配置文件
InitiatorName=iqn.2018-01.com.ultrapower:desktop1
[root@desktop1 home]# systemctl restart iscsi --重启并设置开机启动
[root@desktop1 home]# systemctl enable iscsi
[root@desktop1 home]# systemctl restart iscsid.service
[root@desktop1 home]# systemctl enable iscsid.service
发现并登入使用server端的iscsi设备(提示:查看man iscsiadm帮助文档中的EXAMPLE示例):
[root@desktop1 ~]# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.100.200 --discover
192.168.100.200:, iqn.-.com.ultrapower:testserverdisk1
[root@desktop1 ~]# iscsiadm --mode node --targetname iqn.-.com.ultrapower:testserverdisk1 --portal 192.168.100.200: --login
Logging in to [iface: default, target: iqn.-.com.ultrapower:testserverdisk1, portal: 192.168.100.200,] (multiple)
Login to [iface: default, target: iqn.-.com.ultrapower:testserverdisk1, portal: 192.168.100.200,] successful.
[root@desktop1 ~]# fdisk -l Disk /dev/sda: 32.2 GB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk label type: dos
Disk identifier: 0x000d2b42 Device Boot Start End Blocks Id System
/dev/sda1 * Linux
/dev/sda2 8e Linux LVM Disk /dev/mapper/ruskyVG-root: 29.9 GB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes Disk /dev/mapper/ruskyVG-swap: MB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes Disk /dev/sdb: MB, bytes, sectors --可以看到/dev/sdb磁盘了。
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes 将/dev/sdb磁盘分区500MB,并挂载使用。(题目中并未要求挂载) [root@desktop1 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.). Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xc17d77c4. Command (m for help): n
Partition type:
p primary ( primary, extended, free)
e extended
Select (default p): p
Partition number (-, default ):
First sector (-, default ):
Using default value
Last sector, +sectors or +size{K,M,G} (-, default ): +500M
Partition of type Linux and of size MiB is set Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.
[root@desktop1 ~]# partprobe --刷新分区
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only. [root@desktop1 ~]# mkfs.xfs /dev/sdb1 --格式化分区
meta-data=/dev/sdb1 isize= agcount=, agsize= blks
= sectsz= attr=, projid32bit=
= crc= finobt=, sparse=
data = bsize= blocks=, imaxpct=
= sunit= swidth= blks
naming =version bsize= ascii-ci= ftype=
log =internal log bsize= blocks=, version=
= sectsz= sunit= blks, lazy-count=
realtime =none extsz= blocks=, rtextents=
[root@desktop1 ~]# mkdir /mydisk --创建挂载目录
[root@desktop1 ~]# mount /dev/sdb1 /mydisk/ ---手动挂载测试
[root@desktop1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/ruskyVG-root 28G .6G 25G % /
devtmpfs 715M 715M % /dev
tmpfs 731M 731M % /dev/shm
tmpfs 731M 36M 696M % /run
tmpfs 731M 731M % /sys/fs/cgroup
/dev/sda1 197M 138M 59M % /boot
tmpfs 147M 12K 147M % /run/user/
tmpfs 147M 147M % /run/user/
192.168.100.200:/home/guests/testldapuser5 28G .7G 25G % /home/guests/testldapuser5
192.168.100.200:/home/guests/testldapuser2 28G .7G 25G % /home/guests/testldapuser2
/dev/sr0 .8G .8G % /mnt/cdrom
/dev/sdb1 509M 26M 483M % /mydisk ---已经挂载成功了
[root@desktop1 ~]# blkid /dev/sdb1 --查看/dev/sdb1的UUID,挂载网络设备一定要使用UUID.
/dev/sdb1: UUID="d69a4140-4622-4dc1-823a-e7cfba80b9fa" TYPE="xfs"
[root@desktop1 ~]# vi /etc/fstab --添加开机自动挂载,增加如下一行。一定要添加_netdev,否则开机会卡死。
UUID=d69a4140--4dc1-823a-e7cfba80b9fa /mydisk xfs defaults,_netdev
iscsi共享分区测试的更多相关文章
- Linux下搭建iSCSI共享存储详细步骤(服务器模拟IPSAN存储)
一.简介 iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够 ...
- Linux下搭建iSCSI共享存储的方法 Linux-IO Target 方式CentOS7-1810下实现
iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速 ...
- Linux下搭建iSCSI共享存储的方法 TGT 方式 CentOS6.9系统下
iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速 ...
- Linux下搭建iSCSI共享存储的方法 Linux-IO Target 方式 Debian9.5下实现
iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速 ...
- Linux下搭建iSCSI共享存储的方法 TGT 方式 Debian9.5系统下
iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速 ...
- Linux下搭建iSCSI共享存储
转至:https://www.linuxidc.com/Linux/2016-09/135655.htm Linux下搭建iSCSI共享存储 拓扑: 实验步骤: ------------------- ...
- 实验:iscsi共享存储
实验名称: iscsi共享存储 实验环境: 我们需要准备一个磁盘,对于这个磁盘我们需要使用,将这个磁盘空间共享给iscsi客户端: 实验需求: 我们这里使用两台服务器来实现iscsi共享存储: 1.指 ...
- ISCSI共享
共享存储 ISCSI共享 服务端 软件安装 Install epel-release: # yum install epel-release Install scsi-target-utils rpm ...
- ubuntu 12.04 配置iscsi共享及挂载iscsi共享
一.配置ubuntu 下iscsi下的target 1.配置iscsi-target: sudo apt-get install iscsi* 2.配置一个简单的iscsi target: iscsi ...
随机推荐
- jquery实现相同事件名称,不同命名空间的调用方法
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> ...
- [leetcode]Subsets II @ Python
原题地址:https://oj.leetcode.com/problems/subsets-ii/ 题意: Given a collection of integers that might cont ...
- 读书笔记,《Java 8实战》,第三章,Lambda表达式
第一节,Lambda管中窥豹 可以把Lambda表达式理解为简洁地表示可传递的匿名函数的一种方式,它没有名称,但它有参数列表.函数主题和返回值. 本节介绍了Lambda表达式的语法,它包括 ...
- 关于如何使用javascript监听滚动条滚动事件
在网页中,通常有一个通往网页顶部的锚点,现在我们就来实现它 Html代码: <a id="scrollup" href="#top" style=&quo ...
- Swift语言从天而降,是否能掀起新一轮的科技革命?
Swift语言从天而降,是否能掀起新一轮的科技革命? Swift语言诞生到如今,才短短一个月多,Swift居然挤进TIOBE排行榜的第16位,相信这发展的速度绝不是不论什么一个语言可与之相提并论,那S ...
- http://blog.csdn.net/u014595019/article/details/52805444
http://blog.csdn.net/u014595019/article/details/52805444 tensorflow笔记系列: (一) tensorflow笔记:流程,概念和简单代码 ...
- z-index的堆叠规则
原文: https://www.cnblogs.com/starof/p/4424926.html 对于所有定位,最后都不免遇到两个元素试图放在同一位置上的情况.显然,其中一个必须盖住另一个.但,如何 ...
- 转: Vim快捷键分类
Vim快捷键分类 http://www.cnblogs.com/jikey/archive/2011/12/28/2304341.html 一. 移动: h,j,k,l: 左,下,上,右. ...
- $(...).modal is not a function
bootstrap中调用$(...).modal 方法 提示一个错误 is not a function 检查HTML结构发现,是因为使用了多个Jquery版本,产生了冲突. 解决办法:删掉一个Jqu ...
- IOCCC(The International Obfuscated C Code Contest)
国际 C 语言混乱代码大赛(IOCCC, The International Obfuscated C Code Contest)是一项国际编程赛事,从 1984 年开始,每年举办一次(1997年.1 ...