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 ...
随机推荐
- RSA加密解密及RSA签名和验证及证书
RSA加密解密及RSA签名和验证及证书 公钥是给别人的 发送密文使用公钥加密 验证签名使用公钥验证 私钥是自己保留的 接受密文使用私钥解密 发送签名使用私钥签名 上述过程逆转是不行的,比如使用私钥加密 ...
- usaco 洛谷 P2694 接金币 题解
题目描述 在二维坐标系里,有N个金币,编号0至N-1.初始时,第i个金币的坐标是(Xi,Yi).所有的金币每秒向下垂直下降一个单位高度,例如有个金币当前坐标是(xf, yf),那么t秒后金币所在的位置 ...
- JVM编译优化
在部分的商用虚拟机中,Java 程序最初是通过解释器(Interpreter )进行解释执行的,当虚拟机发现某个方法或代码块的运行特别频繁的时候,就会把这些代码认定为“热点代码”.为了提高热点代码的执 ...
- Java vs C++ (7)导入
用法 import VS include Java import java.util.regex.Pattern; package com.slim; (1)假设少了; 会warning: C++ ...
- Construct Binary Tree from Inorder and Postorder Traversal Traversal leetcode java
题目: Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume ...
- IntelIj IDEA运行JUnit Test OutOfMemoryError
好久没看到OutOfMemoryError这种错误了,今天跑测试的时候发现总是报错.针对IDEA需要修改几个配置. JUnit Test在运行前,IDEA会build整个项目,这个是喜欢eclipse ...
- java中正则表达式基本用法(转)
https://www.cnblogs.com/xhj123/p/6032683.html 正则表达式是一种可以用于模式匹配和替换的规范,一个正则表达式就是由普通的字符(例如字符a到z)以及特殊字符( ...
- javascript——select 标签的使用
<% String state = (String) request.getAttribute("state"); String day = (String) request ...
- JPA(五):映射关联关系------映射单向多对一的关联关系
映射单向多对一的关联关系 新建Customer.java: package com.dx.jpa.singlemanytoone; import java.util.Date; import java ...
- Windows系统内存分析工具的介绍
Windows系统内存分析工具的介绍(进程管理器,资源管理器,性能监视器, VMMap, RamMap,PoolMon) 微软官方提供多种工具来分析Windows 的内存使用情况,除了系统自带的任 ...