Connecting remote storage to your servers is essential task when you work with Virtualized environment like cloud or local vmware environment. There are two common ways to store data on remote location. use ISCSI or NFS share. This article explain how to setup ISCSI allowing your Linux to access remote storage.
What is ISCSI ?
It is an acronym for Internet Small Computer Systems Interface. an IP-based standard for transferring data over the network. In short, iSCSI is a block-level protocol for linking network-based storage to clients.
For example, ISCSI volume appears to the client operating system as a physical hard drive that you can install, configure. That way, your store your data in location-independent storage. for a detailed explanation check Wikipedia iSCSI.
ISCSI vs NFS
NFS and iSCSI are fundamentally different in various ways in which accessing remote storage.
For instance, NFS is built for data sharing among multiple clients. On the other hand, iSCSI is designed for a single client for each volume. Though ISCSI can provide shared multi-client storage, it requires a file system that supports that.
In old days, ISCSI provided more IO performance than NFS. However, with the rapid development in network speed, the gap isn’t noticeable anymore. If your network is 100M or 1G ISCSI, you can observe the performance difference.
File system management
Client OS manages ISCSI-disk’s File system. on the contrary, NFS service handles the file locking, and that allows very efficient concurrent access among multiple clients (for example a VMWare cluster).
ISCSI terms and Keywords
Before we setup ISCSI, We need to understand the following terms:
In simple words, the software installed in client ( in our case a Linux server) that initiates SCSI requests to the iSCSI target.
- Target Portal:
The IP of the device that provide ISCSI storage service.
- Target devices
The iSCSI storage component
The process that presents the initiator with a list of available targets
An iqn (iSCSI qualified name) address is the unique identifier for a device in an iSCSI network
Setup ISCSI on Linux
to enable ISCSI on Debian you need to install the open-iscsi package. in addition to, telnet to check connectivity between the two devices.
apt install -y open-iscsi apt install -y telnet
Configure ISCSI on Linux
In our scenario, the Network-storage has multiple IPs. therefore, to set up ISCSI on our Linux server successfully.
First, check the connectivity between your server and ISCSI provided by using ping, telnet. So, use ping to check connectivity and telnet command to check port reachability. iSCSI normally uses TCP ports 860 and 3260
# ping STORAGE-IP # telnet STORAGE-IP 3260
Second, query ISCSI portal about the available services (target). repeat it with the number of NAS IPs
iscsiadm -m discovery -p 184.108.40.206 -t st iscsiadm -m discovery -p 220.127.116.11 -t st iscsiadm -m discovery -p 18.104.22.168 -t st iscsiadm -m discovery -p 22.214.171.124 -t st
Third, Create a session by login into the storage portal IPs.
iscsiadm -m node -l all
To delete /cleanup discovery Portals. In case of adding wrong IP or NAS IPs has changed. execute the following command and adjust it to the portal IP you want to remove.
iscsiadm -m discovery -o delete -p 126.96.36.199
List assigned LUNs
iscsiadm -m session -P 3
If the server can not connect to storage check the network side first, then try:
sudo iscsiadm -m session -o show
restarting the services to make mount automated
sudo systemctl enable open-iscsi sudo systemctl start open-iscsi
sudo systemctl enable iscsi sudo systemctl start iscsi
Check if iface is hardcoded by removing files in the following folder
EXAMPLE OF iscsi.conf
/etc/iscsi/iscsid.conf iscsid.startup = /usr/sbin/iscsid node.startup = automatic node.leading_login = Yes node.session.auth.authmethod = CHAP node.session.auth.username = iqn.1993-08.org.debian:01:5da1cee3df7b node.session.auth.password = mfcctv01iscsi discovery.sendtargets.auth.authmethod = CHAP discovery.sendtargets.auth.username = iqn.1993-08.org.debian:01:5da1cee3df7b discovery.sendtargets.auth.password = mfcctv01iscsi node.session.timeo.replacement_timeout = 120 node.conn.timeo.login_timeout = 15 node.conn.timeo.logout_timeout = 15 node.conn.timeo.noop_out_interval = 5 node.conn.timeo.noop_out_timeout = 5 node.session.err_timeo.abort_timeout = 15 node.session.err_timeo.lu_reset_timeout = 30 node.session.err_timeo.tgt_reset_timeout = 30 node.session.initial_login_retry_max = 8 node.session.cmds_max = 128 node.session.queue_depth = 32 node.session.xmit_thread_priority = -20 node.session.iscsi.InitialR2T = No node.session.iscsi.ImmediateData = Yes node.session.iscsi.FirstBurstLength = 262144 node.session.iscsi.MaxBurstLength = 16776192 node.conn.iscsi.MaxRecvDataSegmentLength = 262144 node.conn.iscsi.MaxXmitDataSegmentLength = 0 discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768 node.session.nr_sessions = 1 node.session.iscsi.FastAbort = Yes