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