This based on my last post where I documented building a Highly Available NFS/NAS server.
There is not a huge amount that needs to be done in order to add iSCSI functionality as well.
Add a file called /etc/drbd/iscsi.res containing:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
This differs from the previous resource in 2 ways. Obviously it using a different physical disk. Also the port number of the address is incremented; each resource has to have its own port to communicate on.
Add a new resource to /etc/ha.d/haresources:
Same primary host, new IP address, new drbd resource and of course the service to be controlled (tgtd in this case).
I also made a couple of changes to /etc/ha.d/ha.cf:
1 2 3 4
This changes the regularity of the heartbeat packets from every 2 seconds to 2 every second. We also say that a node is dead after only 5 seconds rather than after 30.
Configure an iSCSI Target
Tgtd has a config file that you can use in /etc/tgt/targets.conf. It is an XML file, so add entry like:
1 2 3 4 5 6 7
The target name is by convention iqn.year-month.reverse-domainname:hostname.targetname. Each backing store will be a seperate LUN. A discussion of this is out of the scope of this article.
By default, this config file is disabled. Enable it by un-commenting the line
#TGTD_CONFIG=/etc/tgt/targets.conf in /etc/sysconfig/tgtd. You can now enable the target with service tgtd reload.
Now when you run
tgtadm –mode target –op show you should get something like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Connect An Initiator
Install the iscsi utils:
1 2 3
Discover the targets on the host and login to the target.
If you run
cat /proc/partitions you will see an new partition has appeared. You can do whatever you want with it.