ISCSI的基本搭建过程

SCSI协议

SCSI协议主要是在主机和存储设备之间传送命令、状态和块数据。在各类存储技术中,SCSI协议可谓是最重要的脊梁。因为SCSI协议层位于操作系统和外部资源之间,它具有不同的功能组件。

SCSI通信设备
在这里插入图片描述在这里插入图片描述网络存储分类

  • 直连式存储

    将存储设备通过SCSI接口或者光纤通道直接链接到一台服务器
    在这里插入图片描述

  • 网络接入存储

    存储设备与服务器彻底分离,存储设备通过标准的以太网链接到需要存储服务的计算机
    支持常用的NFS,SAMBA等服务
    在这里插入图片描述

  • 存储区域网络
    采用光纤通道或者Ethernet进行远距离传输,使用光纤通道交换机连接存储陈列或服务器主机。成为一个专用存储网络,这个专用存储网络不支持TCP/IP协议
    在这里插入图片描述

配置案例

在这里插入图片描述

  • 服务端

1.安装软件

[root@system1 ~]# yum install targetcli -y

2.开启服务并设置开机自启

[root@system1 ~]# systemctl enable target
[root@system1 ~]# systemctl start target

3.设置防火墙规则

[root@system1 ~]# firewall-cmd --permanent --add-rich-rule 'rule family="ipv4" source address="172.24.8.12/32" port port=3260 protocol=tcp accept'
success
[root@system1 ~]# firewall-cmd --reload

4.创建逻辑卷作为后端存储

[root@system1 ~]# fdisk /dev/sda     
Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 
First sector (24578048-41943039, default 24578048): 
Using default value 24578048
Last sector, +sectors or +size{K,M,G} (24578048-41943039, default 41943039): +3G
Partition 3 of type Linux and of size 3 GiB is set

Command (m for help): t
Partition number (1-3, default 3): 
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): w
[root@system1 ~]# partprobe 
[root@system1 ~]# pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created
[root@system1 ~]# vgcreate iscsi_vg /dev/sda3
  Volume group "iscsi_vg" successfully created
[root@system1 ~]# lvcreate -n iscsi_store -l 100%VG iscsi_vg
  Logical volume "iscsi_store" created

5.配置ISCSI

[root@system1 ~]# targetcli
/> backstores/block create name=iscsi_store dev=/dev/iscsi_vg/iscsi_store
Created block storage object iscsi_store using /dev/iscsi_vg/iscsi_store.
/> cd iscsi 
/iscsi> create iqn.2014-08.com.example.group8:system1
Created target iqn.2014-08.com.example.group8:system1.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi> cd iqn.2014-08.com.example.group8:system1/tpg1/
/iscsi/iqn.20...:system1/tpg1> luns/ create /backstores/block/iscsi_store 
Created LUN 0.
/iscsi/iqn.20...:system1/tpg1> acls/ create iqn.2014-08.com.example.group8:system2
Created Node ACL for iqn.2014-08.com.example.group8:system2
Created mapped LUN 0.
/iscsi/iqn.20...:system1/tpg1> portals/ create 172.24.8.11 3260
Using default IP port 3260
Could not create NetworkPortal in configFS   ------自动忽略,因为某些版本已经默认添加了0.0.0.0的监听入口
/iscsi/iqn.20...:system1/tpg1> set attribute authentication=0
Parameter authentication is now '0'.
/iscsi/iqn.20...:system1/tpg1> set attribute generate_node_acls=0
Parameter generate_node_acls is now '0'.
/> saveconfig
/> exit

6.显示结果

/> ls
o- / ................................................................................ [...]
  o- backstores ..................................................................... [...]
  | o- block ......................................................... [Storage Objects: 1]
  | | o- iscsi_store ............ [/dev/iscsi_vg/iscsi_store (3.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.2014-08.com.example.group8:system1 ................................... [TPGs: 1]
  |   o- tpg1 ...................................................... [no-gen-acls, no-auth]
  |     o- acls ................................................................. [ACLs: 1]
  |     | o- iqn.2014-08.com.example.group8:system2 ...................... [Mapped LUNs: 1]
  |     |   o- mapped_lun0 .................................. [lun0 block/iscsi_store (rw)]
  |     o- luns ................................................................. [LUNs: 1]
  |     | o- lun0 ......................... [block/iscsi_store (/dev/iscsi_vg/iscsi_store)]
  |     o- portals ........................................................... [Portals: 1]
  |       o- 0.0.0.0:3260 ............................................................ [OK]
  o- loopback ................................................................ [Targets: 0]

  • 客户端

1.安装客户端软件包:

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

2.配置iscsi 客户端的名字,根据题目要求修改

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

3.设定服务开启启动并且重启服务

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

4.发现target
[

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

5.登录 target

[root@system2 ~]# iscsiadm -m node -l
[root@system2 ~]# 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

6.分区并格式化

[root@system2 ~]# fdisk /dev/sdb
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
Command (m for help): w
[root@system2 ~]# partprobe 
[root@system2 ~]# mkfs.ext4 /dev/sdb1

7.设置开机自动挂载

[root@system2 ~]# mkdir /mnt/data

根据题目要求,挂载的时候需要添加 _netdev 参数
[root@system2 ~]# blkid
/dev/sdb1: UUID="630dc30c-ffd4-45ff-a05d-2654043cece8" TYPE="ext4"
[root@system2 ~]# vim /etc/fstab
UUID=442250bf-36c4-4e78-a63c-a676fc4235f4  /mnt/data ext4  defaults,_netdev 0 0
[root@system2 ~]# mount -a
[root@system2 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       9.8G  3.1G  6.8G  31% /
……
/dev/sdb1       2.0G  6.2M  1.9G   1% /mnt/data
  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值