iscsi

xiaoxiao2021-02-28  90

1.iscsi概念

1.iSCSI技术是一种由IBM公司研究开发的,是一个供硬件设备使用的可以在IP协议的上层运行SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速千兆以太网上进行路由选择。iSCSI技术是一种新储存技术,该技术是将现有SCSI接口与以太网络(Ethernet)技术结合,使服务器可与使用IP网络的储存装置互相交换资料。

2.iSCSI:Internet 小型计算机系统接口 (iSCSI:Internet Small Computer System Interface)。

3.Internet 小型计算机系统接口(iSCSI)是一种基于 TCP/IP的协议,用来建立和管理 IP 存储设备、主机和客户机等之间的相互连接,并创建存储区域网络(SAN)。SAN 使得 SCSI 协议应用于高速数据传输网络成为可能,这种传输以数据块级别(block-level)在多个数据存储网络间进行。

4.SCSI 结构基于客户/服务器模式,其通常应用环境是:设备互相靠近,并且这些设备由 SCSI 总线连接。iSCSI 的主要功能是在 TCP/IP 网络上的主机系统(启动器 initiator)和存储设备(目标器 target)之间进行大量数据的封装和可靠传输过程。此外,iSCSI 提供了在 IP 网络封装 SCSI 命令,且运行在 TCP 上。

5.iSCSI(Internet SCSI)支持从客户端(发起端)通过IP向远程服务器上的SCSI存储设备(目标)发送SCSI命令。iSCSI限定名称用于确定发起端和目标,并采用iqn.yyyy-mm.{reverse domain}:label的格式。默认情况下,网络通信是至iSCSI目标上的端口3260/tcp的明文。

iSCSI发起端:需要访问原始SAN存储的客户端。  iSCSI目标:从iSCSI服务器提供的远程硬盘磁盘,或“目标门户”  iSCSI目标门户:通过网络向发起端提供目标的服务器。  IQN:“iSCSI限定名称”。每个发起端和目标需要唯一名称进行标识,最好的做法是使用一个在Internet上可能独一无二的名称。

[root@server4 ~]# fdisk /dev/vdb Command (m for help): n Select (default p): p Partition number (1-4, default 1): First sector (2048-20971519, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +1000M Partition 1 of type Linux and of size 1000 MiB is set Command (m for help): t Selected partition 1 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): p Disk /dev/vdb: 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 / 512 bytes Disk label type: dos Disk identifier: 0x4e4c4b93    Device Boot      Start         End      Blocks  Id  System /dev/vdb1            2048     2050047    1024000   8e  Linux LVM [root@server4 ~]# partprobe [root@server4 ~]# pvcreate /dev/vdb1   Physical volume "/dev/vdb1"successfully created [root@server4 ~]# vgcreate vg0 /dev/vdb1   Volume group "vg0"successfully created [root@server4 ~]# lvcreate -l 249 -n iscsi_storage vg0   Logical volume"iscsi_storage" created [root@server4 ~]# lvs   LV            VG  Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert   iscsi_storage vg0  -wi-a----- 996.00m                                             [root@server4 ~]# yum install targetcli -y [root@server4 ~]# systemctl enable target [root@server4 ~]# targetcli targetcli shell version 2.1.fb34 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] /> /backstores/block create server1storage /dev/vg0/iscsi_storage Created block storage object server1storage using /dev/vg0/iscsi_storage. /> /iscsi create iqn.2017-06.com.example:strage1 Created target iqn.2017-06.com.example:strage1. Created TPG 1. /> /iscsi/iqn.2017-06.com.example:strage1/tpg1/luns create  /backstores/block/server1storage Created LUN 0. /> /iscsi/iqn.2017-06.com.example:strage1/tpg1/acls createiqn.2017-06.com.example:server1storagekey Created Node ACL for iqn.2017-06.com.example:server1storagekey Created mapped LUN 0. /> /> /iscsi/iqn.2017-06.com.example:strage1/tpg1/portals create 172.25.4.11 Using default IP port 3260 Created network portal 172.25.4.11:3260. /> exit Global pref auto_save_on_exit=true Last 10 configs saved in /etc/target/backup. Configuration saved to /etc/target/saveconfig.json [root@server4 ~]# systemctl restart firewalld [root@server4 ~]# systemctl stop  firewalld [root@server4 ~]# targetcli targetcli shell version 2.1.fb34 Copyright 2011-2013 by Datera, Inc and others. For help on commands, type 'help'. /> ls o- / ............................................................ [...]   o- backstores .................................................[...]   | o- block..................................... [Storage Objects: 1]   | | o- server1storage  [/dev/vg0/iscsi_storage (996.0MiB) write-thruactivated]   | o- fileio.................................... [Storage Objects: 0]   | o- pscsi..................................... [Storage Objects: 0]   | o- ramdisk................................... [Storage Objects: 0]   o- iscsi............................................... [Targets: 1]   | o- iqn.2017-06.com.example:strage1...................... [TPGs: 1]   |  o- tpg1 .................................. [no-gen-acls, no-auth]   |    o- acls ............................................. [ACLs: 2]   |    | o- iqn.2017-06.com.example:server1storagekey  [Mapped LUNs: 1]   |    |   o- mapped_lun0 ...........[lun0 block/server1storage (rw)]   |    o- luns ............................................. [LUNs: 1]   |    | o- lun0 ..... [block/server1storage (/dev/vg0/iscsi_storage)]   |    o- portals ....................................... [Portals: 1]   |      o- 172.25.4.11:3260 .................................... [OK]   o- loopback............................................ [Targets: 0] /> 测试: [root@desktop4 ~]# vim /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.2017-06.com.example:server1storagekey [root@desktop4 ~]# systemctl restart iscsi [root@desktop4 ~]# systemctl stop firewalld [root@desktop4 ~]# iscsiadm -m discovery -t st -p 172.25.4.11 172.25.4.11:3260,1 iqn.2017-06.com.example:strage1 [root@desktop4 ~]# systemctl restart iscsi[root@desktop4 ~]# iscsiadm -m node-T iqn.2017-06.com.example:strage1 -p 172.25.4.11 -l [root@desktop4 ~]# fdisk -l Disk /dev/vda: 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 / 512 bytes Disk label type: dos Disk identifier: 0x00013f3e    Device Boot      Start         End      Blocks  Id  System /dev/vda1   *        2048   20970332    10484142+ 83  Linux Disk /dev/vdb: 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 / 512 bytes Disk /dev/sda: 1044 MB, 1044381696 bytes, 2039808 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 [root@desktop4 ~]# fdisk  /dev/sda [root@desktop4 ~]# partprobe [root@desktop4 ~]# mkfs.xfs /dev/sda1 meta-data=/dev/sda1             isize=256    agcount=2,agsize=6656 blks          =                       sectsz=512   attr=2, projid32bit=1          =                       crc=0 data     =                       bsize=4096   blocks=13312, imaxpct=25          =                       sunit=0      swidth=0 blks naming   =version 2              bsize=4096   ascii-ci=0 ftype=0 log      =internal log           bsize=4096   blocks=853, version=2          =                       sectsz=512   sunit=0 blks, lazy-count=1 realtime =none                  extsz=4096   blocks=0,rtextents=0 [root@desktop4 ~]# mount /dev/sda1 /mnt [root@desktop4 ~]# df Filesystem          1K-blocks    Used Available Use% Mounted on /dev/vda1            10473900 3871956   6601944 37% / devtmpfs               481120       0   481120   0% /dev tmpfs                  496708     140   496568   1% /dev/shm tmpfs                  496708   19344   477364   4% /run tmpfs                  496708       0   496708   0% /sys/fs/cgroup /dev/sr0              36547203654720         0 100%/run/media/root/RHEL-7.0 Server.x86_64 172.25.4.11:/public     49836    2756    47080   6% /mnt [root@desktop4 ~]# yum install tree.x86_64 -y [root@desktop4 ~]# tree -C /var/lib/iscsi/ /var/lib/iscsi/ ├── ifaces ├── isns ├── nodes │   └── iqn.2017-06.com.example:strage1 │       └──172.25.4.11,3260,1 │           └── default ├── send_targets │   └── 172.25.4.11,3260 │       ├──iqn.2017-06.com.example:strage1,172.25.4.11,3260,1,default -> /var/lib/iscsi/nodes/iqn.2017-06.com.example:strage1/172.25.4.11,3260,1 │       └── st_config ├── slp └── static 10 directories, 2 files [root@server4 ~]# yum install dhcp httpd tftp-server lftp -y [root@server4 ~]# systemctl start dhcpd [root@server4 ~]# systemctl start httpd [root@server4 ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example/etc/dhcp/dhcpd.conf cp: overwrite ‘/etc/dhcp/dhcpd.conf’? y [root@server4 ~]# vim /etc/dhcp/dhcpd.conf [root@server4 ~]# systemctl restart dhcpd [root@server4 ~]# systemctl start dhcpd [root@server4 ~]# systemctl enable dhcpd ln -s '/usr/lib/systemd/system/dhcpd.service''/etc/systemd/system/multi-user.target.wants/dhcpd.service' [root@server4 ~]# vim /etc/xinetd.d/tftp [root@server4 ~]# systemctl restart xinetd.service [root@server4 ~]# chkconfig --list Note: This output shows SysV services only and does not include native       systemd services. SysVconfiguration data might be overridden by native       systemd configuration.       If you want to list systemd servicesuse 'systemctl list-unit-files'.       To see services enabled onparticular target use       'systemctl list-dependencies[target]'. iprdump        0:off   1:off   2:on    3:on    4:on    5:on    6:off iprinit        0:off   1:off   2:on    3:on    4:on    5:on    6:off iprupdate      0:off   1:off   2:on    3:on    4:on    5:on    6:off netconsole     0:off   1:off   2:off   3:off   4:off   5:off   6:off network        0:off   1:off   2:on    3:on    4:on    5:on    6:off rhnsd          0:off   1:off   2:on    3:on    4:on    5:on    6:off xinetd based services:     chargen-dgram: off     chargen-stream: off     daytime-dgram: off     daytime-stream: off     discard-dgram: off     discard-stream: off     echo-dgram:    off     echo-stream:   off     tcpmux-server: off     tftp:          on     time-dgram:    off     time-stream:   off
转载请注明原文地址: https://www.6miu.com/read-73323.html

最新回复(0)