A. Install boot iSCSI target under Linux
1. Install Start iSCSI Service
[root@wjb10000 ~]# yum-y Install Targetcli.noarch
2. Set up a directory as an iSCSI device
[root@wjb10000 ~]# Mkdir/iscsi_disks
3. Set Target
[root@wjb10000 ~]# targetcli warning:could not load preferences file/root/.targetcli/prefs.bin.
TARGETCLI Shell version 2.1.fb41 Copyright 2011-2013 by Datera, Inc. and others.
For help on commands, type ' help '. /> CD backstores/fileio/backstores/fileio> Create disk01/iscsi_disks/disk01.img 20G Created FileIO disk01 with Siz E 21474836480/backstores/fileio> cd/iscsi/iscsi> Create iqn.2016-06.wjb.com:storage.target0 Created target
Iqn.2016-06.wjb.com:storage.target0.
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.2016-06.wjb.com:storage.target0/tpg1/portals//iscsi/iqn.20.../tpg1/portals> Create 192.168.1.50 Using default IP port 3260 could not create networkportal in configfs/iscsi/iqn.20.../tpg1/portals> delet E 0.0.0.0 3260 Deleted Network portal 0.0.0.0:3260/iscsi/iqn.20.../tpg1/portals> create 192.168.1.50 Using default IP Port 3260 Created Network Portal 192.168.1.50:3260./iscsi/iqn.20.../tpg1/portals> CD.
/luns/iscsi/iqn.20...et0/tpg1/luns> create/backstores/fileio/disk01 Created LUN 0. /iscsi/iqn.20...et0/tpg1/luns> CD ... /acls/iscsi/iqn.20...et0/tpg1/acls> Create iqn.2016-06.wjb.com:www.server.com Created Node ACL for
iqn.2016-06.wjb.com:www.server.com Created mapped LUN 0. /iscsi/iqn.20...et0/tpg1/acls> CD iqn.2016-06.wjb.com:www.server.com//iscsi/iqn.20...ww.server.com> set auth
Userid=username Parameter userid is now ' username '.
/iscsi/iqn.20...ww.server.com> set auth password=password Parameter password is now ' password '.
/iscsi/iqn.20...ww.server.com> exit Global pref auto_save_on_exit=true last configs saved In/etc/target/backup. Configuration saved To/etc/target/saveconfig.json
4. Set up a firewall
[root@wjb10000 ~]# vim/etc/firewalld/services/iscsi.xml <?xml version= "1.0" encoding= "Utf-8"?>
< service>
<short>ISCSI</short>
<description>iscsi protocal</description>
<port protocal= "tcp" port= "3260" >
</service>
[root@wjb10000 ~]# firewall-cmd---permanent- ADD-SERVICE=ISCSI
[root@wjb10000 ~]# firewall-cmd--reload
5. Start Service
[root@wjb10000 ~]# systemctl enable Target.service
Created symlink from/etc/systemd/system/ Multi-user.target.wants/target.service To/usr/lib/systemd/system/target.service.
[root@wjb10000 ~]# systemctl start Target.service
6. View Port
[root@wjb10000 ~]# NETSTAT-LNP | grep 3260
TCP 0 0 192.168.1.50:3260 0.0.0.0:* LISTEN -
Two. Install the start iSCSI initiator under Linux
1. Installation of Iscsi-initiator-utils Service
[root@wjb10000 ~]# Yum Install iscsi-initiator-utils
2. Modify the configuration file
[root@wjb10000 ~]# vim/etc/iscsi/initiatorname.iscsi
initiatorname=iqn.2016-06.wjb.com:www.server.com
[root@wjb10000 ~]# vim/etc/iscsi/iscsid.conf
#node. Session.auth.authmethod = CHAP
# Node.session.auth.username = Username
#node. Session.auth.password = password //Remove Comment
3. Start Service
[root@wjb10000 ~]# systemctl start Iscsid
[root@wjb10000 ~]# Systemctl Enable Iscsid
4. Target Detected
[root@wjb10000 ~]# iscsiadm-m discovery-t sendtargets-p 192.168.1.50
5. View status
[root@wjb10000 ~]# iscsiadm-m node-o Show
6. Sign in target to establish a connection
[root@wjb10000 ~]# iscsiadm-m node--login
Logging in to [Iface:default, Target:iqn.2016-06.wjb.com:storage.target0, portal:192.168.1.50,3260] (multiple)
Login to [Iface:default, Target:iqn.2016-06.wjb.com:storage.target0, portal:192.168.1.50,3260] successful.
7. View connection Status
[root@wjb10000 ~]# iscsiadm-m session-o Show
TCP: [1] 192.168.1.50:3260,1 iqn.2016-06.wjb.com:storage.target0 (Non-flash)
8. Disk operation
[root@wjb10000 ~]# fdisk-l disk/dev/sda:107.4 GB, 107374182400 bytes, 209.7152 million sectors Units = Sector of 1 *-The bytes sector size ( Logical/Physical): 512 Bytes/512 bytes I/o size (min/best): 512 Bytes/512 bytes disk label type: DOS disk identifier: 0X000B2BA1 device Boot Start end Blocks Id SYSTEM/DEV/SDA1 * 2048 1026047 512000-linux/dev/sda2 1026048 62466047 30720000-Linux/dev/sda3 62466048 103426047 20480000 linux/dev/sda4 103426048 209715199 53144576 5 extended/dev/sda5 103428096 14 4388095 20480000 linux/dev/sda6 144390144 152582143 4096000 2 Linux swap/solaris/dev/sda7 152584192 09715199 28565504 gigabyte Linux disk/dev/sdb:21.5 GB, 21474836480 bytes, 41,943,040 sectors Units = Sector of 1 * = the bytes sector size (logical/ Physics): 512 bytes/512 bytes I/o size (min/best): 512 bytes/8388608 bytes [root@wjb10000 ~]# parted--script/dev/sdb "Mklabel msdos" [root@ wjb10000 ~]# parted--script/dev/sdb "Mkpart primary 0% 100%" [root@wjb10000 ~]# mkfs.xfs-i size=1024-s size=4096/dev/ SDB1 META-DATA=/DEV/SDB1 isize=1024 agcount=4, agsize=1310208 blks = sectsz=4096 attr=2, projid32bit=1 = cr c=0 finobt=0 data = bsize=4096 blocks=5240832 imaxpct=25 sunit=0 = swidth=0 blks namin G =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=4096 sunit=1 Blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 [root@wjb10000 ~]# mount/dev/sdb1/mnt/[root@wjb10000 ~]# df-ht file system type capacity used available% mount point/dev/sda3 xfs 20G 68M 20G 1%/devt Mpfs Devtmpfs 904M 0 904M 0%/dev Tmpfs tmpfs 913M 0 913M 0%/dev/shm tmpfs tmpfs 913M 8.7M 904M 1% /run Tmpfs tmpfs 913M 0 913M 0%/sys/fs/cgroup/dev/sda5 xfs 20G 1.5G 19G 8%/usr/dev/sda7 xfs 28G 33M 28G 1%/home/dev/sda2 xfs 30G 694M 29G 3%/var/dev/sda1 xfs 497M 128M 370M 26%/boot tmpfs TMPFS 183M 0 183M 0%/run/user/0/dev/sdb1 xfs 20G 33M 20G 1%/mnt
The above is a small set of Linux for everyone to configure the iSCSI server method full content, I hope that we support cloud-Habitat Community ~