Configuring iSCSI servers under Linux for resource sharing

Source: Internet
Author: User

ISCSI (Internet SCSI): Enables the sending of SCSI commands from clients over IP to SCSI storage devices on remote servers


The SCSI fabric is based on the client/server model, and the typical application environment is that the devices are close to each other and the devices are connected by a SCSI bus. The main function of ISCSI is toTCP/IPon the networkHost System(initiator initiator) and storage device (target object) for a large amount of data encapsulation andReliable Transmissionprocess. In addition, ISCSI provides encapsulation of SCSI commands on IP networks and runs inTCPon.


Qualified name format: Iqn.yyyy-mm.{reverse Domain}:label


First, the server-side configuration is as follows:

1. Install and start the service

[[email protected] desktop]# Yum install targetcli-y# installing iSCSI target Package [[email protected] desktop]# systemctl start target# startup t arget service [[email protected] desktop]# Systemctl enable target# set up service boot from


2. Enter iSCSI Interactive configuration mode

[[email protected] desktop]# targetcli# Input TARGETCLI command targetcli shell version 2.1. Fb34copyright 2011-2013 by datera, inc and others. for help on commands, type  ' Help ' ./> lso- /  ..... ..... ..... ..... ..... ..... ..... ....  [..... ..... ..... ..... ..... ....... .............   o- backstores .......................................................... [...]   | o- block .............................................. [Storage  objects: 0]  | o- fileio ............................................. [ storage objects: 0]  | o- pscsi  .............................................. [storage objects: 0]  | o-  ramdisk ............................................ [storage objects: 0]  o-  ISCSI&NBSP, ....... .......................................... [targets: 0]  o- loopback  ..................................................... [targets: 0]/> /backstores/block  create pt.example.disk1 /dev/sda4# creating iSCSI Remote Storage blocks using/DEV/SDA4 pt.example.disk1created block  storage object pt.example.disk1 using /dev/sda4./> /iscsi create  iqn.2016-03.pt.example1:storage# Create the iSCSI file name to share (the format must be Iqn.yyyy-mm.{reverse domain}:label) created  Target iqn.2016-03.pt.example1:storage. created tpg 1./> /iscsi/iqn.2016-03.pt.example1:storage/tpg1/acls create  iqn.2016-03.pt.example2:desktop# specifies ACL permissions to access the iSCSI device block (that is, allow Initiator name to Iqn.2016-03.pt.example2: Desktop clients can access) created node acl for iqn.2016-03.pt.example2:desktop/> /iscsi/ iqn.2016-03.pt.example1:storage/tpg1/luns create /backstores/block/pt.example.disk1 # Join the iSCSI Remote Storage block you created created lun 0.created lun 0->0 mapping in node acl iqn.2016-03.pt.example2:desktop/ > /iscsi/iqn.2016-03.pt.example1:storage/tpg1/portals create 172.25.254.209# the port using used to open access  default IP port 3260Created network portal 172.25.254.209:3260./>  Ls# is completed as follows o- / ..................................................................... [...]   o- backstores .......................................................... [...]   | o- block .............................................. [Storage  objects: 1]  | | o- pt.example.disk1 ............ [/dev/sda4  ( 1.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.2016-03.pt.example1:storage ............................... [tpgs: 1]  |    o- tpg1 ........................................... [no-gen-acls,  no-auth]  |     o- acls  ...................................................... [acls: 1]  |      | o- iqn.2016-03.pt.example2:desktop .................. [mapped luns:  1]  |     |   o- mapped_lun0  .................. [lun0 block/pt.example.disk1  (rw)]  |      o- luns ................................................ [luns: 1]  |      | o- lun0 ......................... [block/pt.example.disk1  (/DEV/SDA4)]   |     O- PORTALS&NBSP: ..... ..... ..... ..... ..... ....................  [portals: 1]  |       o- 172.25.254.209:3260  .......................................... [OK]  o- loopback  ..... ...  [targets: 0]/> exitglobal pref. ..... ....... ..... ....... .......--the ......-.......  auto_save_on_exit=truelast 10 configs saved in /etc/target/backup. Configuration saved to /etc/target/saveconfig.json


Set up a firewall

[[email protected] desktop]# firewall-cmd--permanent--add-port=3260/tcp# will be used to join the firewall allowed Success[[email protected] desktop]# Firewall-cmd--reload #重载防火墙的设置success


Second, the client configuration is as follows:

[[email protected] desktop]# yum install iscsi-initiator-utils -y# Install iSCSI Initiator Package [ [email protected] desktop]# vim /etc/iscsi/initiatorname.iscsi# set Initiator's iqninitiatorname= Iqn.2016-03.pt.example2:desktop[[email protected] desktop]# iscsiadm -m discovery  -t st -p 172.25.254.209   #获得可以访问共享的块172 .25.254.209:3260,1  Iqn.2016-03.pt.example1:storage[[email protected] desktop]# iscsiadm -m node -t  iqn.2016-03.pt.example1:storage -p 172.25.254.209 -l# connecting iSCSI target blocks on the service side to native Logging in  to [iface: default, target: iqn.2016-03.pt.example1:storage, portal:  172.25.254.209,3260]  (multiple) login to [iface: default, target:  Iqn.2016-03.pt.example1:storage, portal: 172.25.254.209,3260] successful. [[email protected] desktop]# fdisk -l# View disk, more/dev/sdbdisk /dev/sda: 21.5 gb, 21474836480 bytes, 41943040 sectorsunits =  sectors of 1 * 512 = 512 bytessector size  (logical/physical):  512 bytes / 512 bytesI/O size  (Minimum/optimal): 512 bytes  / 512 bytesdisk label type: dosdisk identifier: 0x000c235a    Device Boot      Start          End      Blocks   Id  System/dev/sda1    *        2048      411647       204800   83  Linux/dev/sda2           411648     4605951      2097152   82  linux swap / solaris/dev/sda3          4605952    35796991    15595520   83   linuxdisk /dev/sdb: 1073 mb, 1073741824 bytes, 2097152 sectorsunits =  sectors of 1 * 512 = 512 bytesSector size  (logical/physical ): 512 bytes / 512 bytesi/o size  (minimum/optimal):  512 bytes  / 4194304 bytesDisk label type: dosDisk identifier: 0x00000000    Device Boot      Start          end      blocks   id  system



The resulting iSCSI resources can then be used normally, formatted and mounted.




####### #中断使用ISCSI目标 #########

Unmount the mount first to ensure that no devices provided by the target are used

[[email protected] desktop]# iscsiadm-m node-t iqn.2016-03.pt.example1:storage-p 172.25.254.209-u# exit the iSCSI target to temporarily disconnect [ [Email protected] desktop]# iscsiadm-m node-t iqn.2016-03.pt.example1:storage-p 172.25.254.209-o-delete #删除本地连接ISCSI目标的本地记录 to permanently disconnect


This article is from the "ptallrights" blog, make sure to keep this source http://ptallrights.blog.51cto.com/11151122/1793228

Configuring iSCSI servers under Linux for resource sharing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.