centos7配置iscsi
什么是ISCSI
iscsi--internet small computer system interface互联小型计算机系统接口,将数据包封装在TCP/IP协议中传输,使用普通网线和网络设备即可实现,相对于FC-SAN存储来说更廉价。
ISCSI系统结构
iscsi一般分为服务器端和客户端,服务器端负责管理本地磁盘或磁盘陈列,客户端则是用来发现并连接服务器端获得访问iscsi共享盘。
centos7中服务端和客户端所需要的安装包
centos7 | 软件包 |
---|---|
服务端 | targetcli, targetd,scsi-target-utils |
客户端 | iscsi-initiator-utils |
实验环境
角色 | 主机名 | IP |
---|---|---|
服务端 | master | 192.168.138.200 |
客户端 | slave | 192.168.138.201 |
服务器端配置
- 准备一块磁盘并分好区,先不用格式化
- 运行targetcli命令,给要要共享的磁盘定义名字
# targetcli
targetcli shell version 2.1.fb46
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/> ls
o- / ........................................................... [...]
o- backstores ................................................ [...]
| o- block .................................... [Storage Objects: 0]
| o- fileio ................................... [Storage Objects: 0]
| o- pscsi .................................... [Storage Objects: 0]
| o- ramdisk .................................. [Storage Objects: 0]
o- iscsi .............................................. [Targets: 0]
o- loopback ........................................... [Targets: 0]
/> cd /backstores/block
/backstores/block> create slave /dev/sdb
Created block storage object slave using /dev/sdb.
- 创建iqn
命名在同一子网内确保是唯一的,命名格式为:iqn.yyyy-mm.<主机名反写>:自定义名称
/backstores/block> cd /iscsi
/iscsi> create iqn.2018-02.com.frank.master:slave
Created target iqn.2018-02.com.frank.master:slave.
Created TPG 1.
Default portal not created, TPGs within a target cannot share ip:port.
- 创建acl允许ISCSI客户机连接
/iscsi> cd iqn.2018-02.com.frank.master:slave/tpg1/acls
/iscsi/iqn.20...ave/tpg1/acls> create iqn.2018-02.com.frank.master:slave
Created Node ACL for iqn.2018-02.com.frank.master:slave
/iscsi/iqn.20...ave/tpg1/acls> ls
o- acls .................................................... [ACLs: 1]
o- iqn.2018-02.com.frank.master:slave ............. [Mapped LUNs: 0]
- 创建lun(target块设备的逻辑单元) 把块设备和iqn绑定
/iscsi> cd iqn.2018-02.com.frank.master:slave/tpg1/luns
/iscsi/iqn.20...ave/tpg1/luns> create /backstores/block/slave
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2018-02.com.frank.master:slave
/iscsi/iqn.20...ave/tpg1/luns> ls
o- luns .................................................... [LUNs: 1]
o- lun0 ................ [block/slave (/dev/sdb) (default_tg_pt_gp)]
- 设置监听地址和端口
/iscsi/iqn.20.../tpg1/portals> create 192.168.138.200 ip_port=3260
Using default IP port 3260
Created network portal 192.168.138.200:3260.
这里要注意的是,使用ls查看一下是不是已经有0.0.0.0 3260这个条目,如果有删除掉再创建,不然会报错,还有一点的是如果 tgtd服务正在开启的情况下也无法创建,必须先停掉tgtd这个服务。
- 设置登录验证
/iscsi/iqn.20....master:slave> set auth userid=test
Parameter userid is now 'test'.
/iscsi/iqn.20....master:slave> set auth password=test
Parameter password is now 'test'.
到这里服务器的配置就算完成了,最后看一下配置完成的状态
/> ls
o- / ........................................................................... [...]
o- backstores ................................................................ [...]
| o- block .................................................... [Storage Objects: 1]
| | o- slave ............................. [/dev/sdb (20.0GiB) write-thru activated]
| | o- alua ..................................................... [ALUA Groups: 1]
| | o- default_tg_pt_gp ......................... [ALUA state: Active/optimized]
| o- fileio ................................................... [Storage Objects: 0]
| o- pscsi .................................................... [Storage Objects: 0]
| o- ramdisk .................................................. [Storage Objects: 0]
o- iscsi .............................................................. [Targets: 1]
| o- iqn.2018-02.com.frank.master:slave .................................. [TPGs: 1]
| o- tpg1 ................................................. [no-gen-acls, no-auth]
| o- acls ............................................................ [ACLs: 1]
| | o- iqn.2018-02.com.frank.master:slave ..................... [Mapped LUNs: 1]
| | o- mapped_lun0 ................................... [lun0 block/slave (rw)]
| o- luns ............................................................ [LUNs: 1]
| | o- lun0 ........................ [block/slave (/dev/sdb) (default_tg_pt_gp)]
| o- portals ...................................................... [Portals: 1]
| o- 192.168.138.200:3260 ............................................... [OK]
o- loopback ........................................................... [Targets: 0]
/>
- 启动服务端
# systemctl start tgtd.service
客户端配置
- 发现设备
# iscsiadm -m discovery -t sendtargets -p 192.168.138.200
iscsiadm: This command will remove the record [iface: default,
target: iqn.2018-04.com.frank.www:iscsi1, portal: 192.168.138.200,3260],
but a session is using it. Logout session then rerun command to remove record.
192.168.138.200:3260,1 iqn.2018-02.com.frank.master:slave
- 连接设备
# iscsiadm -m node -T iqn.2018-02.com.frank.master:slave -p 192.168.138.200 --login
Logging in to [iface: default, target: iqn.2018-02.com.frank.master:slave,
portal: 192.168.138.200,3260] (multiple)
Login to [iface: default, target: iqn.2018-02.com.frank.master:slave,
portal: 192.168.138.200,3260] successful.
- 查看设备
fdsik -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytes
Disk label type: gpt
# Start End Size Type Name
# fdisk /dev/sdc
Command (m for help): n
Partition number (1-128, default 1):
First sector (34-41943006, default 8192):
Last sector, +sectors or +size{K,M,G,T,P} (8192-41943006, default 41943006): +10G
Created partition 1
Command (m for help): n
Partition number (2-128, default 2):
First sector (34-41943006, default 20979712):
Last sector, +sectors or +size{K,M,G,T,P} (20979712-41943006, default 41943006):
Created partition 2
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@slave ~]# fdisk /dev/sdc
WARNING: fdisk GPT support is currently new, and therefore in an
experimental phase. Use at your own discretion.
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytes
Disk label type: gpt
# Start End Size Type Name
1 8192 20979711 10G Linux filesyste
2 20979712 41943006 10G Linux filesyste
- 格式化分区并挂载
# mkfs.xfs /dev/sdc1
meta-data=/dev/sdc1 isize=512 agcount=4, agsize=610351 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=2441402, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@slave ~]# mkfs.xfs /dev/sdc2
meta-data=/dev/sdc2 isize=512 agcount=4, agsize=610291 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=2441162, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
# mount /dev/sdc1 /iscsi/
# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/cl-root xfs 37G 11G 27G 28% /
devtmpfs devtmpfs 712M 0 712M 0% /dev
tmpfs tmpfs 723M 12K 723M 1% /dev/shm
tmpfs tmpfs 723M 72M 651M 10% /run
tmpfs tmpfs 723M 0 723M 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 184M 831M 19% /boot
tmpfs tmpfs 145M 0 145M 0% /run/user/0
/dev/sdc1 xfs 9.4G 33M 9.3G 1% /iscsi
centos7配置iscsi的更多相关文章
- CentOS7 配置ISCSI targetcli 共享存储
- CentOS7系列--3.2CentOS7中配置iSCSI服务
CentOS7配置iSCSI服务 在网络上的存贮服务为iSCSI Target,而连接到iSCSI Target服务的叫iSCSI Initiator 1. 直接配置iSCSI Target服务 1. ...
- targetcli配置iSCSI
概述:这篇文章来介绍LIO下的用户态工具targetcli来配置iSCSI服务 虚拟机环境:centos7.x(内核版本3.10.0-862.el7.x86_64) IP分别为192.168.1.20 ...
- 配置iSCSI部署网络存储
iSCSI( Internet Small Computer System Interface 互联网小型计算机系统接口)是由IBM 下属的两大研发机构一一加利福尼亚AImaden和以色列Haifa研 ...
- CentOS 6.5下配置iSCSI网络存储
一.简介 iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行 SCSI协议,使其能 ...
- CentOS 6.3下配置iSCSI网络存储
一.简介 iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够 ...
- Centos7 配置网络步奏详解
Centos7 配置网络步奏详解 编辑网卡配置文件 vi /etc/sysconfig/network-script/ifcfg-ens01 备注:这里的ens01不是所有系统都叫这个,有的可能叫其他 ...
- centos7配置开启无线网卡,重启防火墙
centos7配置无线网卡: 在虚拟机为nat的网络连接下(就是默认的那个),centos7默认网卡未激活. 可以设置 文件 /etc/sysconfig/network-scripts/ifcfg- ...
- CentOS7.4 ISCSI
试验机配置: cat /etc/centos-release CentOS Linux release 7.4.1708 (Core) uname -r 3.10.0-693.el7.x86_64 所 ...
随机推荐
- 问题1:Oracle数据库监听启动失败(重启监听,提示The listener supports no services)
编辑监听文件:/home/DB/oracle/11gR2/db/network/admin/listener.ora 在文件内添加静态监听实例,如下内容: SID_LIST_LISTENER =(SI ...
- 20165214 2018-2019-2 《网络对抗技术》Exp2 后门原理与实践 Week4
<网络对抗技术>Exp2 PC平台逆向破解之"MAL_简单后门" Week4 一.实验内容 本次实验对象为名为pwn1的pwn1的linux可执行文件.程序正常执行流程 ...
- 清华机试中手机键盘问题求解 java 和 c
题目描述:按照手机键盘输入字母的方式,计算所花费的时间 如:a,b,c都在“1”键上,输入a只需要按一次,输入c需要连续按三次.如果连续两个字符不在同一个按键上,则可直接按,如:ad需要按两下,kz需 ...
- ios12更新开发者需要做的
1.StatusBar内部结构改变 现象:crash crash log: -[_UIStatusBarIdentifier isEqualToString:]: unrecognized selec ...
- DateGridView控件与mysql交互
private void dgv() { //Ip+端口+数据库名+用户名+密码 string connectStr = "server=127.0.0.1;port=3306;databa ...
- Python学习之路基础篇--04Python基础+数据类型
1 int 只需知道 i.bit_length() 是算其二进制的位数, 如3 就是2: 5就是 3. 2 bool 要知道 while True == while 1 :除零以外的所有数都为真 ...
- window10单机安装storm集群
适合范围:storm自由开源的分布式实时计算系统,擅长处理海量数据.适合处理实时数据而不是批处理. 安装前的准备 1.安装zookeeper ①下载zookeeperhttps://zookeeper ...
- Mawawa CSS 学习之旅 Display
CSS 类型之 Display 更新时间: 2018-2-10: 一个良好的布局结构从 display 开始! 分类:外部值.内部值.列表值.属性值.混合值.显示值.全局值: 一.外部值 作用:主要用 ...
- final、finally、以及finalize的区别
final ---修饰类.变量和方法,修饰的类不能被继承 .修饰的方法不能被重写 .修饰的成员变量不可更改 另外,修饰成员变量必须立即赋值,修饰局部变量使用之前被赋值就可以. finally通常和tr ...
- Ajaxpro使用的方法
1.下载Ajaxpro.2.dll 程序中引用 2.web.config配置 <?xml version="1.0" encoding="utf-8"?& ...