RHEL7 或CentOS7配置共享存储--使用iSCSI
环境: RHEL 7.3
1.LVM创建
2.服务端配置
3.客户端配置
1.LVM创建
在RHEL7.3中,对于lvm操作部分与之前RHEL6版本没有区别,还是创建pv,vg,lv的方法,命令参考如下:
pvcreate /dev/sdb vgcreate vg_storage /dev/sdb lvcreate -L 1g -n lv_lun1 vg_storage lvcreate -L 1g -n lv_lun2 vg_storage lvcreate -L 1g -n lv_lun3 vg_storage lvcreate -L 40g -n lv_lun4 vg_storage lvcreate -L 10g -n lv_lun5 vg_storage lvcreate -L 10g -n lv_lun6 vg_storage lvcreate -L 10g -n lv_lun7 vg_storage lvcreate -L 16g -n lv_lun8 vg_storage
最终可以看到新建的lv信息:
[root@Storage-B yum.repos.d]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert home rhel -wi-ao---- 23.33g root rhel -wi-ao---- 47.79g swap rhel -wi-ao---- 7.88g lv_lun1 vg_storage -wi-a----- 1.00g lv_lun2 vg_storage -wi-a----- 1.00g lv_lun3 vg_storage -wi-a----- 1.00g lv_lun4 vg_storage -wi-a----- 40.00g lv_lun5 vg_storage -wi-a----- 10.00g lv_lun6 vg_storage -wi-a----- 10.00g lv_lun7 vg_storage -wi-a----- 10.00g lv_lun8 vg_storage -wi-a----- 16.00g
2.服务端配置
之前在RHEL6中安装的iscsi服务端rpm包的名字是:scsi-target-utils,这在RHEL7中变成了targetd、targetcli这两个包。
2.1 使用yum安装targetd和targetcli
yum -y install targetd targetcli systemctl status targetd systemctl start targetd systemctl enable targetd systemctl list-unit-files|grep targetd
同时确认targetd服务启动状态和开启启动。
2.2 使用targetcli创建设备
targetcli进入命令行,cd到/backstores/block 目录下,创建设备:
create disk1 /dev/mapper/vg_storage-lv_lun1create disk2 /dev/mapper/vg_storage-lv_lun2create disk3 /dev/mapper/vg_storage-lv_lun3create disk4 /dev/mapper/vg_storage-lv_lun4create disk5 /dev/mapper/vg_storage-lv_lun5create disk6 /dev/mapper/vg_storage-lv_lun6create disk7 /dev/mapper/vg_storage-lv_lun7create disk8 /dev/mapper/vg_storage-lv_lun8
创建完成,可以成功看到:
/backstores/block> ls o- block ...................................................................................................... [Storage Objects: 8] o- disk1 ........................................................ [/dev/mapper/vg_storage-lv_lun1 (1.0GiB) write-thru deactivated] o- disk2 ........................................................ [/dev/mapper/vg_storage-lv_lun2 (1.0GiB) write-thru deactivated] o- disk3 ........................................................ [/dev/mapper/vg_storage-lv_lun3 (1.0GiB) write-thru deactivated] o- disk4 ....................................................... [/dev/mapper/vg_storage-lv_lun4 (40.0GiB) write-thru deactivated] o- disk5 ....................................................... [/dev/mapper/vg_storage-lv_lun5 (10.0GiB) write-thru deactivated] o- disk6 ....................................................... [/dev/mapper/vg_storage-lv_lun6 (10.0GiB) write-thru deactivated] o- disk7 ....................................................... [/dev/mapper/vg_storage-lv_lun7 (10.0GiB) write-thru deactivated] o- disk8 ....................................................... [/dev/mapper/vg_storage-lv_lun8 (16.0GiB) write-thru deactivated]
2.3 使用targetcli创建iqn和LUN
然后cd到/iscsi目录下,创建iqn;cd到/iscsi/iqn.20...0be/tpg1/luns下创建LUN,参考命令如下:
cd /iscsicreatecd /iscsi/iqn.20...0be/tpg1/lunscreate /backstores/block/disk1create /backstores/block/disk2create /backstores/block/disk3create /backstores/block/disk4create /backstores/block/disk5create /backstores/block/disk6create /backstores/block/disk7create /backstores/block/disk8
实际执行过程如下:
/backstores/block> cd /iscsi /iscsi> ls o- iscsi .............................................................................................................. [Targets: 0] /iscsi> create Created target iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be. Created TPG 1.Global pref auto_add_default_portal=trueCreated default portal listening on all IPs (0.0.0.0), port 3260./iscsi> ls o- iscsi .............................................................................................................. [Targets: 1] o- iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be ......................................................... [TPGs: 1] o- tpg1 ................................................................................................. [no-gen-acls, no-auth] o- acls ............................................................................................................ [ACLs: 0] o- luns ............................................................................................................ [LUNs: 0] o- portals ...................................................................................................... [Portals: 1] o- 0.0.0.0:3260 ....................................................................................................... [OK]/iscsi/iqn.20...0be/tpg1/luns> ls o- luns .................................................................................................................. [LUNs: 8] o- lun0 ........................................................................... [block/disk1 (/dev/mapper/vg_storage-lv_lun1)] o- lun1 ........................................................................... [block/disk2 (/dev/mapper/vg_storage-lv_lun2)] o- lun2 ........................................................................... [block/disk3 (/dev/mapper/vg_storage-lv_lun3)] o- lun3 ........................................................................... [block/disk4 (/dev/mapper/vg_storage-lv_lun4)] o- lun4 ........................................................................... [block/disk5 (/dev/mapper/vg_storage-lv_lun5)] o- lun5 ........................................................................... [block/disk6 (/dev/mapper/vg_storage-lv_lun6)] o- lun6 ........................................................................... [block/disk7 (/dev/mapper/vg_storage-lv_lun7)] o- lun7 ........................................................................... [block/disk8 (/dev/mapper/vg_storage-lv_lun8)]/iscsi/iqn.20...0be/tpg1/luns>
2.4 使用targetcli创建acls
cd到acls目录下,创建client;然后cd到portals目录下创建portals, 参考命令如下:
cd /iscsi/iqn.20...0be/tpg1/acls create iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be:client cd /iscsi/iqn.20...0be/tpg1/portals delete 0.0.0.0 3260create 10.10.1.21create 10.10.2.21
实际执行过程如下:
/iscsi/iqn.20.../tpg1/portals> pwd/iscsi/iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be/tpg1/portals/iscsi/iqn.20.../tpg1/portals> ls o- portals ............................................................................................................ [Portals: 2] o- 10.10.1.21:3260 .......................................................................................................... [OK] o- 10.10.2.21:3260 .......................................................................................................... [OK]
2.5 使用targetcli查看当前配置信息
在/下执行ls,或者ls /查看当前配置信息:
/iscsi/iqn.20.../tpg1/portals> ls / o- / ......................................................................................................................... [...] o- backstores .............................................................................................................. [...] | o- block .................................................................................................. [Storage Objects: 8] | | o- disk1 ...................................................... [/dev/mapper/vg_storage-lv_lun1 (1.0GiB) write-thru activated] | | o- disk2 ...................................................... [/dev/mapper/vg_storage-lv_lun2 (1.0GiB) write-thru activated] | | o- disk3 ...................................................... [/dev/mapper/vg_storage-lv_lun3 (1.0GiB) write-thru activated] | | o- disk4 ..................................................... [/dev/mapper/vg_storage-lv_lun4 (40.0GiB) write-thru activated] | | o- disk5 ..................................................... [/dev/mapper/vg_storage-lv_lun5 (10.0GiB) write-thru activated] | | o- disk6 ..................................................... [/dev/mapper/vg_storage-lv_lun6 (10.0GiB) write-thru activated] | | o- disk7 ..................................................... [/dev/mapper/vg_storage-lv_lun7 (10.0GiB) write-thru activated] | | o- disk8 ..................................................... [/dev/mapper/vg_storage-lv_lun8 (16.0GiB) write-thru activated] | o- fileio ................................................................................................. [Storage Objects: 0] | o- pscsi .................................................................................................. [Storage Objects: 0] | o- ramdisk ................................................................................................ [Storage Objects: 0] o- iscsi ............................................................................................................ [Targets: 1] | o- iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be ....................................................... [TPGs: 1] | o- tpg1 ............................................................................................... [no-gen-acls, no-auth] | o- acls .......................................................................................................... [ACLs: 1] | | o- iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be:client ................................... [Mapped LUNs: 8] | | o- mapped_lun0 ................................................................................. [lun0 block/disk1 (rw)] | | o- mapped_lun1 ................................................................................. [lun1 block/disk2 (rw)] | | o- mapped_lun2 ................................................................................. [lun2 block/disk3 (rw)] | | o- mapped_lun3 ................................................................................. [lun3 block/disk4 (rw)] | | o- mapped_lun4 ................................................................................. [lun4 block/disk5 (rw)] | | o- mapped_lun5 ................................................................................. [lun5 block/disk6 (rw)] | | o- mapped_lun6 ................................................................................. [lun6 block/disk7 (rw)] | | o- mapped_lun7 ................................................................................. [lun7 block/disk8 (rw)] | o- luns .......................................................................................................... [LUNs: 8] | | o- lun0 ................................................................... [block/disk1 (/dev/mapper/vg_storage-lv_lun1)] | | o- lun1 ................................................................... [block/disk2 (/dev/mapper/vg_storage-lv_lun2)] | | o- lun2 ................................................................... [block/disk3 (/dev/mapper/vg_storage-lv_lun3)] | | o- lun3 ................................................................... [block/disk4 (/dev/mapper/vg_storage-lv_lun4)] | | o- lun4 ................................................................... [block/disk5 (/dev/mapper/vg_storage-lv_lun5)] | | o- lun5 ................................................................... [block/disk6 (/dev/mapper/vg_storage-lv_lun6)] | | o- lun6 ................................................................... [block/disk7 (/dev/mapper/vg_storage-lv_lun7)] | | o- lun7 ................................................................... [block/disk8 (/dev/mapper/vg_storage-lv_lun8)] | o- portals .................................................................................................... [Portals: 2] | o- 10.10.1.21:3260 .................................................................................................. [OK] | o- 10.10.2.21:3260 .................................................................................................. [OK] o- loopback ......................................................................................................... [Targets: 0]/iscsi/iqn.20.../tpg1/portals>
最后配置防火墙策略,或者直接关闭防火墙,建议后者,视具体要求而定。
--防火墙添加放行tcp 3260端口: firewall-cmd --permanent --add-port=3260/tcpfirewall-cmd --reload--关闭防火墙: systemctl disable firewalld systemctl stop firewalld
3.客户端配置
3.1 使用yum安装iscsi-initiator-utils
yum -y install iscsi-initiator-utils
3.2 编辑/etc/iscsi/initiatorname.iscsi
vi /etc/iscsi/initiatorname.iscsi
#InitiatorName=iqn.1994-05.com.redhat:babc7da33c48InitiatorName=iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be:client
注释之前的示例,添加一行实际的配置。
3.3 使用iscsiadm发现可用存储设备并登陆连接
iscsiadm -m discovery -t st -p 10.10.1.21
[root@db92 yum.repos.d]# iscsiadm -m discovery -t st -p 10.10.1.2110.10.1.21:3260,1 iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be10.10.2.21:3260,1 iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be
登陆连接:
iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be -p 10.10.1.21 --loginiscsiadm -m node -T iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be -p 10.10.2.21 --login
此时使用fdisk -l 查看已经正常显示所有设备:
[root@db90 ~]# fdisk -lDisk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0001b841 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 167772159 82836480 8e Linux LVM Disk /dev/mapper/rhel-root: 51.3 GB, 51308920832 bytes, 100212736 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/rhel-swap: 8455 MB, 8455716864 bytes, 16515072 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/rhel-home: 25.1 GB, 25052577792 bytes, 48930816 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sdc: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sdd: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sde: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sdg: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sdf: 42.9 GB, 42949672960 bytes, 83886080 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sdh: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sdi: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sdj: 42.9 GB, 42949672960 bytes, 83886080 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sdl: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sdk: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sdn: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sdm: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sdo: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sdp: 17.2 GB, 17179869184 bytes, 33554432 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes Disk /dev/sdq: 17.2 GB, 17179869184 bytes, 33554432 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33550336 bytes [root@db90 ~]#
由于是两条链路,所以fdisk看到的存储LUN是两倍,后续再使用多路径软件聚合即可使用。
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ linux 7.4 版本 iscsi搭建共享存储实战
主机:
10.10.6.83 rac1
10.10.6.84 rac2
---版本
[root@rac1 iscsi]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
我在 rac1 主机上划分了一个50G的空间盘,打算用iscsi服务共享给两台主机rac1,rac2 ,下面是操作步骤
1、查看共享存储用的盘
[root@rac1 iscsi]# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000e5720
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 104857599 52222976 8e Linux LVM
/dev/sda3 104857600 209715199 52428800 5 Extended
/dev/sda5 104859648 209715199 52427776 83 Linux
Disk /dev/mapper/centos-root: 49.2 GB, 49178214400 bytes, 96051200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 4294 MB, 4294967296 bytes, 8388608 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
这里我用盘/dev/sda5 来做两台主机的共享存储
2、安装iscsi 客户端软件
yum -y installiscsi-initiator-utils
---重启服务
[root@rac2 iscsi]# systemctl restart iscsi
[root@rac2 iscsi]# systemctl enable iscsi
---修改两台主机iscsi客户识别号
[root@rac1 iscsi]# pwd
/etc/iscsi
[root@rac1 iscsi]# ls
initiatorname.iscsi iscsid.conf
[root@rac1 iscsi]# vi initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:rac1
[root@rac2 iscsi]# cat initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:rac2
注意:客户端的 initiator Node Name 配置成与 target ACL 的一致
3、在rac1 主机上 建立iscsi 服务
3.1 安装iscsi软件
[root@rac1etc]# yum install targetcli*
3.2 启动 target 服务
systemctl start target
systemctl enable target
3.3 进入管理控制台
[root@rac1etc]# targetcli
3.4 建立一个块储存server1,使用上面新添加硬盘/dev/ sda5
/backstores/block create server1 /dev/sda5
创建完成后,会在 /backstores/block 下面可以看出多了server1
3.5 建立target的id :
注意: iqn.1994-05.com.redhat:rac1 名称的选取一定要与server1 磁盘所对应的InitiatorName一样,(或者修改initiatorname.iscsi 文件内容)
建立一个名称iqn为iqn.1994-05.com.redhat:rac1
/> cd iscsi
/iscsi>create iqn.1994-05.com.redhat:rac1
3.6 设置哪些设备可以连接到此iqn上:
cd /iscsi/iqn.1994-05.com.redhat:rac1/tpg1/acls
create iqn.1994-05.com.redhat:rac2
create iqn.1994-05.com.redhat:rac1
3.7 lun 和具体的磁盘联系在一起,前面已经把/dev/sda5 磁盘创建成了server1
Cd /iscsi/ iqn.1994-05.com.redhat:rac1/tpg1/luns
Create /backstores/block/server1
3.8 配置 target 监听 IP 和端口(默认在所有接口 IP 的 3260/tcp 监听)
Cd /iscsi/ iqn.1994-05.com.redhat:rac1/tpg1/portals
delete 0.0 . 0.0 3260
Create 10.10.6.83
Create 10.10.6.84
3.9 保存配置
/iscsi/iqn.20.../tpg1/portals>cd /
/>saveconfig
[root@rac1 iscsi]# iscsiadm -m discovery -t st -p 10.10.6.83
10.10.6.83:3260,1 iqn.1994-05.com.redhat:rac1
[root@rac2 iscsi]# cat initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:rac2
4 客户端登陆服务
[root@rac1iscsi]# iscsiadm -m discovery -t st -p 10.10.6.83
10.10.6.83:3260,1iqn.1994-05.com.redhat:rac1
[root@rac1iscsi]# iscsiadm -m node -T iqn.1994-05.com.redhat:rac1 -p 10.10.6.83:3260 -l
Logging in to[iface: default, target: iqn.1994-05.com.redhat:rac1, portal: 10.10.6.83,3260](multiple)
Login to[iface: default, target: iqn.1994-05.com.redhat:rac1, portal: 10.10.6.83,3260]successful.
[root@rac2iscsi]# iscsiadm -m discovery -t st -p 10.10.6.83
10.10.6.83:3260,1iqn.1994-05.com.redhat:rac1
[root@rac2iscsi]# iscsiadm -m node -T iqn.1994-05.com.redhat:rac1 -p 10.10.6.83:3260 -l
Logging in to[iface: default, target: iqn.1994-05.com.redhat:rac1, portal: 10.10.6.83,3260](multiple)
Login to[iface: default, target: iqn.1994-05.com.redhat:rac1, portal: 10.10.6.83,3260]successful.
[root@rac1 iscsi]# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000e5720
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 104857599 52222976 8e Linux LVM
/dev/sda3 104857600 209715199 52428800 5 Extended
/dev/sda5 104859648 209715199 52427776 83 Linux
Disk /dev/mapper/centos-root: 49.2 GB, 49178214400 bytes, 96051200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 4294 MB, 4294967296 bytes, 8388608 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 53.7 GB, 53686042624 bytes, 104855552 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
磁盘共享成功
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Centos7系列(八)ISCSI网络存储服务
ISCSI 网络存储服务 :
说明:iscsi实现网络存储,提供存储端叫 target,使用存储端叫 initiator。target 上可以提供存储空间,initiator负责连接ISCSI设备,在ISCSI设备中创建文件系统,以及存取数据,在 initiator 上看上去是多了一块硬盘。
服务器端配置target,准备做为LUN发布的ISCSI的存储设备( 可以是一整块磁盘、一个分区、逻辑卷或RAID阵列 )。
虚拟机环境图:
实验步骤( 本实验以一整块磁盘做为iscsi存储 ):
1 )事先准备好一块新磁盘作为ISCSI的存储设备
2 )安装target
3 )启动target服务
4) 设置防火墙,开启3260端口例外,以便客户端连接
5 )执行targetcli工具
下面正式开始做iscsi的共享储存:
基本思路:
先把准备共享的块做出来,创建一个target,在target上创建lun,一个lun连接一个块
6 )创建块即给要发布的存储磁盘起个名字
7 )创建 iqn名字即创建ISCSI对象
8 )创建LUN(即逻辑单元)并绑定块
9 )设置ACL即将ISCSI对象与客户端IP或主机名绑定( initiator 端必须指定ACL的名字才可以连接iscsi存储,就相当于initiator端连接iscsi存储的一个凭证 )
10 )修改监听地址(把默认的0.0.0.0改成本机的地址)
说明:可以查看 /etc/target/saveconfig.json 配置文件,该配置文件保存着ISCSI的配置。
下面是在initiator端的配置:
1 )安装iscsi-initiator-utils
2 )给initiator起一个名字
3 )启动iscsid服务
4 )寻找(发现)target端的存储(即查询target端的iscsi对象)
Iscsi 的用法:
5 )登陆存储(即登陆iscsi对象)
6 )验证客户端ISCSI连接
7) 格式化、创建挂载点、挂载