Setup iSCSI Target & Initiator on CentOS 6
iSCSI is a network protocol defined to allow scsi commands over TCP/IP stack, allowing to hosts I/O block operations like a device storage attached locally. With iSCSI we’ve to difference to basic concepts:
SAN’s are very used to make storage devices accessible to the servers so that the devices appear like locally attached devices to the OS.
In this scenario I’ll configure on CentOS 6 an iSCSI target sharing an array disk device and other server as an iSCSI initiator that will map this device as local storage.
Configuring the iSCSI target
- Install the software package:
- Edit target iSCSI configuration:
- Start the iSCSI target daemon and configure to startup at boot system:
- Add iptables rule to allow iSCSI traffic:
- check the iSCSI target configuration:
Configuring the iSCSI Initiator
- Install the software package:
- Configure the iqn name for the initiator:
- Edit the iSCSI initiator configuration:
- Start iSCSI initiator daemon:
- Discovering targets in our iSCSI server:
- Trying to login with the iSCSI LUN:
With this command is reponsible of the update of iSCSI targets database for the files located in /var/lib/iscsi/ :
- Checking the status session with the target:
Mounting automatically the iSCSI partitions at system boot
- Create a new partition to our iSCSI disk and format it:
- Checking the UUID for disk:
- Add the next entry in /etc/fstab file:
With the mount option _netdev the script netfs is responsible of the mount to this device. Without this option, Linux will try to mount this device before load the network support. We have to check that netfs is enabled to run in the default runlevels:
- Mounting the new file system:
Initiator parameters configuration: http://www.open-iSCSI.org/docs/README
- iSCSI initiator: is called the scsi client, and can be connected to the server of two ways:
- Software initiator: Normally is implemented as a module that will used by the network interface and emulate scsi devices. Is the most implementation.
- Hardware initiator: It use a dedicated hardware to implement iSCSI. The work load of the iSCSI process is handled by this hardware. - iSCSI target: references a storage resource located in a iSCSI server.
- literal iqn
- date (yyyy-mm) year and month
- reversed domain name of the authority (org.alpinelinux, com.example, to.yp.cr)
- “:” prefixing a storage target name specified by the naming authority.
SAN’s are very used to make storage devices accessible to the servers so that the devices appear like locally attached devices to the OS.
In this scenario I’ll configure on CentOS 6 an iSCSI target sharing an array disk device and other server as an iSCSI initiator that will map this device as local storage.
Configuring the iSCSI target
- Install the software package:
1
| # yum -y install scsi-target-utils |
1
| # vi /etc/tgt/targets.conf |
1
2
3
4
5
| <target iqn.2012-10.net.cpd:san.target01> backing-store /dev/md0 initiator-address 172.16.201.201 incominguser iscsiadm iscsiadm123 < /target > |
1
2
| # /etc/init.d/tgtd start # chkconfig --levels 235 tgtd on |
1
| # vi /etc/sysconfig/iptables |
1
| -A INPUT -m state --state NEW -m tcp -p tcp --dport 3260 -j ACCEPT |
1
| # service iptables restart |
1
| # tgtadm --mode target --op show |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| Target 1: iqn.2012-10.net.cpd:san.target01 System information: Driver: iSCSI State: ready I_T nexus information: LUN information: LUN: 0 Type: controller SCSI ID: IET 00010000 SCSI SN: beaf10 Size: 0 MB, Block size: 1 Online: Yes Removable media: No Prevent removal: No Readonly: No Backing store type : null Backing store path: None Backing store flags: Account information: iSCSIadm ACL information: 172.16.201.201 |
- Install the software package:
1
| # yum -y install iscsi-initiator-utils |
1
| # vi /etc/iscsi/initiatorname.iscsi |
1
2
| InitiatorName=iqn.2012-10.net.cpd:san.initiator01 InitiatorAlias=initiator01 |
1
| # vi /etc/iscsi/iscsid.conf |
1
2
3
4
5
6
7
| # To manually startup the session set to "manual". The default is automatic. node.startup = automatic # To enable CHAP authentication node.session.auth.authmethod = CHAP # To set a CHAP username and password for initiator node.session.auth.username = iscsiadm node.session.auth.password = iscsiadm123 |
1
2
| # /etc/init.d/iscsid start # chkconfig --levels 235 iscsid on |
1
2
| # iscsiadm --mode discovery -t sendtargets --portal 172.16.201.200 172.16.201.200:3260,1 iqn.2012-10.net.cpd:san.target01 |
1
2
3
| # iscsiadm --mode node --targetname iqn.2012-10.net.cpd:san.target01 --portal 172.16.201.200 --login Logging in to [iface: default, target: iqn.2012-10.net.cpd:san.target01, portal: 172.16.201.200,3260] (multiple) Login to [iface: default, target: iqn.2012-10.net.cpd:san.target01, portal: 172.16.201.200,3260] successful. |
1
| # cat /var/lib/iscsi/send_targets/172.16.201.200,3260/st_config |
1
2
3
4
5
6
7
8
9
10
11
12
| discovery.startup = manual discovery. type = sendtargets discovery.sendtargets.address = 172.16.201.200 discovery.sendtargets.port = 3260 discovery.sendtargets.auth.authmethod = None discovery.sendtargets.timeo.login_timeout = 15 discovery.sendtargets.use_discoveryd = No discovery.sendtargets.discoveryd_poll_inval = 30 discovery.sendtargets.reopen_max = 5 discovery.sendtargets.timeo.auth_timeout = 45 discovery.sendtargets.timeo.active_timeout = 30 discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768 |
1
2
| # iscsiadm --mode session --op show tcp: [2] 172.16.201.200:3260,1 iqn.2012-10.net.cpd:san.target01 |
- Create a new partition to our iSCSI disk and format it:
1
2
3
4
5
6
7
| # fdisk -l Disk /dev/sdb : 17.2 GB, 17171480576 bytes 64 heads, 32 sectors /track , 16376 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Sector size (logical /physical ): 512 bytes / 512 bytes I /O size (minimum /optimal ): 512 bytes / 512 bytes Disk identifier: 0x00000000 |
1
| Disk /dev/sdb doesn't contain a valid partition table |
1
2
| # fdisk /dev/sdb # mkfs.ext4 /dev/sdb1 |
1
2
| # blkid /dev/sdb1 /dev/sdb1 : UUID= "71e86162-011d-49f1-9b4a-9f95a277e6b5" TYPE= "ext4" |
1
| UUID=71e86162-011d-49f1-9b4a-9f95a277e6b5 /mnt/data ext4 _netdev,rw 0 0 |
1
2
| # chkconfig --list netfs netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off |
1
| # mount -a -O _netdev |
AinbueYcephiGlendale Kelly Campos https://wakelet.com/wake/9u1TG16jTpdzIPmdLlLds
ResponderEliminarulmicootu