ISCSI Target and Initiator Configuration In Linux
Configure ISCSI Target(Server):
First we’ll start by configuring the iSCSI target on our server, which will be offering its disk space over the network to our client which is the iSCSI initiator.
We want to install the ‘targetcli’ package on the server, this provides a shell for viewing and modifying the target configuration so that we can export local storage resources such as files, volumes or RAM disks to external systems. The layout is tree based and navigation works in a similar way to moving through the file system with commands such as ‘cd’ and ‘ls’ available.
NOTE: You need to one external blank DISK added in server(Target) for this configuration.
check my youtube video "ISCSI Target and Initiator Configuration" for your reference.
Install targetcli and open-iscsi package on Target and Initiator server:
#yum install targetcli (For RedHat)
#apt-get install targetcli (For Ubuntu)
#zypper in targetcli (For SUSE)
Once installed we want to start the target service, and enable it so that it automatically starts up on system boot for both server.
#systemctl start target
#systemctl enable target
Now we can run the targetcli command, followed by ls from within the targetcli prompt to get an idea of what is available.
#targetcli
Creating a Backstore
#backstores/iblock create block_MD /dev/vdb
Creating ISCSI initiatorname
Run below command on same Sever and copy iqn name (Use duplicate SSH session)
#cat /etc/iscsi/initiatorname.iscsi
#iscsi/ create iqn.1996-04.de.suse:01:c719dab17ca5
Creating ACL for ISCSI Initiator(Client)
Run below command on Initiator(Client) and copy iqn name
#cat /etc/iscsi/initiatorname.iscsi
Go back to Target server and give to access Initiator(Client) with below command
#iscsi/iqn.1996-04.de.suse:01:c719dab17ca5/tpg1/acls create iqn.1996-04.de.suse:01:b33b213403d
Creating LUNs from created block
#iscsi/iqn.1996-04.de.suse:01:c719dab17ca5/tpg1/luns create /backstores/iblock/block_MD
Creating Portals for give permission to access from all IPs
#iscsi/iqn.1996-04.de.suse:01:c719dab17ca5/tpg1/portals create 0.0.0.0
#/iscsi/iqn.19...dab17ca5/tpg1> set attribute authentication=0
#iscsi/iqn.1996-04.de.suse:01:bf5d8383425/tpg1/ set attribute generate_node_acls=1
All set, Now save the configuration and restart service with below command:
#saveconfig
#exit
#systemctl restart targetcli.service
#systemctl restart iscsid.service
#systemctl restart iscsid.socket
Configure ISCSI Initiator(Client):
Go to Client machine and follow below steps, if you have not installed required in client(Initiator) need to install first.
Edit iscsid.conf file and set node startup automatic.
#vim /etc/iscsi/iscsid.conf
node.startup = automatic
node.leading_login = No
Now try to connect Target(server) with below commands:
#iscsiadm --mode discovery --type sendtargets --portal 10.142.8.57 <=== Server IP
#iscsiadm -m node -T iqn.1996-04.de.suse:01:c719dab17ca5 -l <=== copy and pest here output of iqn number.
Now you can check, Disk is added
#lsblk
After all done, now you can use this disk as filesystem.
#mkfs.ext4 /dev/sdb
#mkdir /meetdarji
#mount /dev/sdb /meeddarji
Comments
Post a Comment