1. Install the iSCSI target package and start the service :
# yum Install-y targetcli
# Systemctl enable target; Systemctl start target
2. Enter the ISCSI Target Interactive configuration mode :
# TARGETCLI
650) this.width=650; "style=" width:658px;height:195px; "title=" Picture 1.png "src=" http://s3.51cto.com/wyfs02/M02/6E/66/ Wkiom1v612axfj1waahiyw3wc4k963.jpg "width=" 754 "height=" 412 "alt=" wkiom1v612axfj1waahiyw3wc4k963.jpg "/>
4.TARGETCLI for configuration
/>/backstores/block Create SERVER0.DISK1/DEV/ISCSI_VG/DISK1_LV//give the hard drive an alias
Created Block Storage Object Server0.disk1 using/dev/iscsi_vg/disk1_lv.
/>/ISCSI Create Iqn.2014-12.com.example:server0
Created Target Iqn.2014-12.com.example:server0.
Created TPG 1.
/>/iscsi/iqn.2014-12.com.example:server0/tpg1/luns Create/backstores/block/server0.disk1
Created LUN 0.
Created LUN 0->0 Mapping in node ACL iqn.2014-12.com.example:desktop0
/>/iscsi/iqn.2014-12.com.example:server0/tpg1/portals Create 172.25.0.11
Using Default IP Port 3260
Created Network Portal 172.25.0.11:3260.
/> Exit
5. results after a successful configuration
650) this.width=650; "style=" width:568px;height:291px; "title=" Picture 2.png "src=" http://s3.51cto.com/wyfs02/M00/6E/62/ Wkiol1v62vaaxvmwaatfhfcmztk163.jpg "width=" 1008 "height=" 347 "alt=" wkiol1v62vaaxvmwaatfhfcmztk163.jpg "/>
Second, the client
1) yum install iscsi-initiator-utils.x86_64-y
2) iscsiadm-m discovery-t st-p 172.25.254.
3) Edit File Vim/etc/iscsi/initiatorname.iscsi
650) this.width=650; "style=" width:598px;height:75px; "title=" Picture 3.png "src=" http://s3.51cto.com/wyfs02/M00/6E/66/ Wkiom1v62dch_zuuaabyv7h252q413.jpg "width=" 456 "height=" + alt= "wkiom1v62dch_zuuaabyv7h252q413.jpg"/>
Systemctl Restart Iscsid.service
4 ) Find the iSCSI targets provided by the iSCSI Server ( target portal )
Iscsiadm-m discovery-t st-p 172.25.254.120
5) log on to one or more iSCSI targets on the server
Iscsiadm-m node-t iqn.2015-06.com.example:westos-p 172.25.254.120-l
-l: login -m : operation Span style= "font-family: ' Times New Roman ';" >-t:
650) this.width=650; "style=" width:726px;height:188px; "title=" Picture 4.png "src=" http://s3.51cto.com/wyfs02/M02/6E/66/ Wkiom1v62fkdtuavaaggbcifn9w950.jpg "width=" "height=" 184 "alt=" Wkiom1v62fkdtuavaaggbcifn9w950.jpg "/>
6) Fdisk-l
FDISK/DEV/SDA re-partition /dev/vda1
Partprobe
Mkfs.xfs/dev/sda1
mount/dev/sda1/mnt/
vim /etc/fstab /etc/fstab
blkid Span style= "font-family: ' The song Body '; > OK file system uuid uuid mount , /dev/sd* device name. ( every time
The device names displayed at boot time are different , depending on the order in which the ISCSI devices respond over the network.
If you mount by device name , This causes the wrong device to be used. )
2. use _netdev as Mount option in /etc/fstab . ( This ensures that the client does not attempt to mount the file system
to enable networking. Otherwise , The system will fail at boot time. )
3. ensure that the iSCSI service starts at boot time.
Vim/etc/fstab
650) this.width=650; "title=" Picture 5.png "src=" http://s3.51cto.com/wyfs02/M00/6E/62/ Wkiol1v62hkcnggaaadiarrom9i323.jpg "width=" 686 "height=" " the alt=" wkiol1v62hkcnggaaadiarrom9i323.jpg "/>"
7) reboot Client, if not shut down properly, then poweroff can
Interrupt the use of ISCSI targets
Client:
1. Delete /etc/fstab first
2.mount/mnt
3.iscsiadm-m node-t iqn.2015-06.com.example:westos-p 172.25.254.100
Logging out of Session [Sid:1, Target:iqn.2015-06.westos.disk1:storage1,portal:172.25.254.132,3260]logout of [Sid:1, T Arget:iqn.2015-06.westos.disk1:storage1, portal:172.25.254.132,3260] successful. ------- Temporary deletion succeeded
This will only temporarily delete /dev/sda-u: logoff
Systemctl Restart Iscsid.service
systemctl restart Iscsi.service
The/DEV/SDA partition will re-appearwhen the service iSCSI service is heavy:fdisk-l
4.iscsiadm-m node-t iqn.2015-06.com.example:westos-p 172.25.254.120-o Delete
Restart service completely remove /dev/vda
Service side:
1. Delete two files:
650) this.width=650; "style=" WIDTH:653PX;HEIGHT:137PX; "title=" Picture 6.png "src=" http://s3.51cto.com/wyfs02/M00/6E/66/ Wkiom1v62jtsb8gkaagdy5lhily783.jpg "width=" 649 "height=" 185 "alt=" wkiom1v62jtsb8gkaagdy5lhily783.jpg "/>
2.systemctl Restart Target If the service is not restarted, the operation will be re-saved
Can targetcli view:ls after the initial state
iSCSI Storage Modules