Configuring iSCSI and adding iSNS Servers |
Desktop - OpenSUSE |
In previous tutorials we've learned SUSE has made life very easy for System Administrators having developed graphical tools to manage many system components including the iSCSI target. As with most things in life there is a price to pay for this ease: YaST only writes to the configuration files and the changes do not come into force until the service is restarted. Command Line knowledge lifts us out of troublesome pit and gives us full control of our systems. Additionally we will add in ISNS (Internet Storage Name Service) to locate ISCSI Targets on our network. What we will look at1. Why Use iSCSI command line tools 2. Configuring the ISCSI Target ( Server ) using ietadm 3. Connect to the target with an iSCSI Initiator ( Client ) using iscsiadm 4. Mounting iSCSI Drives into the /etc/fstab 5. Configuring the use of iSNS Why Use iSCSI command line toolsManaging your iSCSI Target Server via YaST allows you to share disk space to servers or desktops on your local network. Any target and its associated LUNs are written to the configuration file /etc/ietd.conf. This file is only read when the ISCSI Target Service starts. This means a restart of the service is required to allow the changes to become effective. Additionally registration with iSNS servers of the targets is not triggered from definitions in the configuration files, only those made with ietadm. All around this is not a perfect solution even with its’ ease. Consider, for a moment, why you use Linux. Many folk start using Linux as they do not like reboots that are required with, let’s say, a Windows System. Maybe these restarts are required because the management effected through GUI tools. To move into a better management model, we too have to manage our systems in a better way. The iSCSi target can be managed with the command ietadm and the initiator iscsiadm.
Configuring the ISCSI Target (Server) using ietadmThis tutorial starts with the iscsi-target installed but not configured on SUSE Linux Enterprise 11 Server, but these commands are consistent across many distributions of Linux. As before, we first need to define a target and then create LUNs or Logical Units. Define New Target 1. Start the iscsitarget server: service iscsitarget start 2. Create the target or logical disk-controller on the server: ietadm –op new –tid 1 –params Name=2011-07.com.beginlinux.iTarget:datastore
On SUSE we can use control services with the rc symlinks, however this example we keep to the more traditional service command to start the target server. The server will start but does not have any targets or LUNs defined so we will add them while the server is running. These commands can be easily added to the /etc/init.d/iscsitarget script so they are created as the iscsi server starts. The command as you can see is ietadm but let’s break the options down to manageable elements : 1. –op new : We are defining a new element 2. –tid 1 : We are defining a target with the ID of 1. The target ID must be unique on the system and numbering starts at 1. We could use 0 (zero) as the ID and that would use the next available ID but we would not know what it was. 3. –params Name=iqn.2011-07.com.beginlinux.iTarget:datastore : This is where we create the name of the target and how it will show to clients. The Target name must be unique so there is a process used in the naming. All names start with iqn (ISCSI Qualified Name), then the reverse date that the target was created (always keep the date the same as when it was first created, do not change it as the year or month changes), followed by the reverse dns name of the target system. Finally we add a colon to separate the name of the target on this system; I call it here “datastore”. Remember we are really naming the HBA, (host bus adaptor) here not the actual disk storage itself.
The naming of the target is not unique to the command line. The GUI will create a randomized name for you when you go create a target. Now, though, we have a little understanding of what is required to build a target correctly in the GUI or from the command line.
Define a New LUN
1. ietadm –op new –tid 1 –lun=0 –params Path=/dev/vg0/data
Again you see we are using the ietadm command to define the new LUN on the target 1 we just created:
1. –tid 1 : This has to be the target ID of an existing target that we wish to add the LUN to. 2. –lun=0 : define the Logical Unit Number on this bus. This has to be unique in the bus (targetID). 3. –params Path=/dev/vg0/data : The parameters here point to the path of the disk that you wish to share. This example is using an LVM Volume.
Note: These settings are not persistent, a reboot of the server and the target and LUN are lost. You can add the settings to the /etc/ietd.conf so they are read on start up or add them to the init script that starts the service, on SUSE /etc/init.d/iscsitarget. For reference the corresponding /etc/ietd.conf settings are shown.
Connect to the target with an iSCSI Initiator (Client) using iscsiadm As before, you will need to add the iscsi initiator package to your Linux desktop or server, open-iscsi. With this installed we can manage the client through the GUI YaST tool or from the command line. If we are to manage it from the command line we can use the iscsiadm tool. With this we can discover and connect to targets in the same way as with the GUI, just quicker. 1. zypper in open-iscsi (installs the client) 2. service open-iscsi start (starts the service) 3. DISCOVER TARGETS: iscsiadm –m discovery –t st –p 172.17.1.2 a. –m discovery sets the mode to discovery so we can detect targets b. –t st The discovery type is “Send Targets” rather than ISNS or SLP. Send Targets represent a connection directly to the iSCSI Target. c. –p 172.17.1.1 Sets the portal or what we would call the address of the iSCSI Target.
4. CONNECT TO TARGETS : iscsiadm –T iqn.2011-07.beginlinux.iTarget:datastore –l here we login into the target, no authentication is needed as we never set it on the target.
If we now check the output of the command: dmesg we should see the device being created on the client machine. From the output graphic included we see that the iSCSI connection has been made and has been connected as sda on the client machine.
Mounting drives into /etc/fstabNow of course we know we could create a partition and format it. In this case it would become /dev/sda1. This in turn could be used to mount the device in /etc/fstab of the initiator. However, we must be very careful using device names. This currently is /dev/sda1 but if we mounted other drives iSCSI or USB devises whilst this was not mounted then they also may become the sda device; we need to be sure that when we mount this disk to the desired directory it is done so reliably each time. To effect this we use the UUID, (unique identifier), of the partition when mounting with the /etc/fstab file. To detect the UUID we use the command blkid /dev/sda1 as in the graphic. (Use this command when you have created the filesystem, here it is ext3).
Now we can create an entry in the /etc/fstab that makes use of this UUID so only this partition will be mounted rather than using /dev/sda1 which may result in the wrong filesystem be mounted. UUID=<YourUUID> /data ext3 _netdev 0 2 Note: The use of the _netdev mount option then waits to mount this filesystem until the network service is loaded.
Configuring the use of iSNS Servers
Finally, if we have more than one iSCSI Target we may find that adding an iSNS (Internet Storage Name Service) Server to our network may help. With this in place, iSCSI Targets register with the iSNS Server and iSCSI Initiators discover from the iSNS Server. It becomes the single server to locate iSCSI Targets on the network. Once installed configuration is needed on the targets and the initiators so the know the iSNS server to use. Targets: /etc/ietd.conf >> iSNSServer x.x.x.x This is in the file but just commented out. Point your record to the server hosting your iSNS. If Access Control in needed then add in a user name and password, again this is documented in the file.
Initiators: /etc/iscsi/iscsi.conf >> isns.address = x.x.x.x isns.port = 3205 Again the file is very well documented and contains sample settings.
To discover from the iSNS server the corresponding iscsiadm command would be iscsiadm –m Discovery –t iSNS
|