Configure Storage Server with iSCSI.
Configure iSCSI Target:-
Now we can run the targetcli command.
[root@server ~]# targetcli
/> ls
o- / .................................... [...]
o- backstores ......................... [...]
| o- block ............. [Storage Objects: 0]
| o- fileio ............ [Storage Objects: 0]
| o- pscsi ............. [Storage Objects: 0]
| o- ramdisk ........... [Storage Objects: 0]
o- iscsi ....................... [Targets: 0]
o- loopback .................... [Targets: 0]
Creating a Backstore
/> backstores/fileio create filetest /tmp/fileio 500M write_back=false
Created fileio filetest with size 524288000
/> backstores/block create name=block dev=/dev/sdb
Created block storage object block using /dev/sdb.
By ‘ls’ command the backstores should be listed.
/> ls
o- / ...................................................... [...]
o- backstores ........................................... [...]
| o- block ............................... [Storage Objects: 1]
| | o- block ....... [/dev/sdc (1.0GiB) write-thru deactivated]
| o- fileio .............................. [Storage Objects: 1]
| | o- filetest .. [/tmp/filetest (500.0MiB) write-thru deactivated]
| o- pscsi ............................... [Storage Objects: 0]
| o- ramdisk ............................. [Storage Objects: 0]
o- iscsi ......................................... [Targets: 0]
o- loopback ...................................... [Targets: 0]
Create the iSCSI Target and Portal
Create an ACL
Now we need to configure an access control list (ACL) to define the initiators that are actually allowed to connect to the iSCSI target.
To do this, go to the client system that will be our iSCSI initiator and get the contents of the /etc/iscsi/initiatorname.iscsi file – you can edit this file if you want, otherwise the default is fine.
Now that we have the name of our initiator from the client system, we enter the ACL section on the server within the TPG.
Saving Changes
To save the configuration, simply exit
iSCSI Firewall Rules
Configure iSCSI Initiator:-
Now we need to discover iSCSI targets then login
we can view all active iSCSI sessions as shown below.
format with XFS
In order to log out of the iSCSI target, first unmount the disks then perform the actual log out
/iscsi/iqn.20...get/tpg1/acls> cd ../..
/iscsi/iqn.20...m:target> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
[root@server ~]# netstat -antup | grep 3260
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN -
[root@server ~]# firewall-cmd --permanent --add-port=3260/tcp
success
[root@server ~]# firewall-cmd --reload
success
[root@client ~]# yum install iscsi-initiator-utils -y
[root@client ~]# systemctl enable iscsid iscsi
[root@client ~]# systemctl start iscsid iscsi
[root@client ~]# iscsiadm --mode discovery --type sendtargets --portal 192.0.0.0
192.0.0.0:3260,1
iqn.2020-04.example.com
[root@client ~]# iscsiadm -m node -T iqn.2020-04.example.com -l
Logging in to [iface: default, target: iqn.2020-04.example.com, portal: 192.0.0.0,3260] (multiple)
Login to [iface: default, target: iqn.2020-04.example.com, portal: 192.0.0.0,3260] successful.
[root@client]# iscsiadm -m session -P 0
tcp: [1] 192.0.0.0:3260,1 iqn.2020-04.example.com:target (non-flash)
[root@client ~]# mkfs.xfs /dev/sdb
[root@client ~]# mount /dev/sdb /mnt
[root@client ~]# df -h | grep mnt
Filesystem Size Used Avail Use% Mounted on
/dev/sdb 500M 11M 489M 4% /mnt
[root@client /]# umount /mnt
[root@client ~]# iscsiadm -m node -u
Logging out of session [sid: 1, target: iqn.2020-04.example.com:target, portal: 192.0.0.0,3260]
Logout of [sid: 1, target: iqn.2020-04.example.com:target, portal: 192.0.0.0,3260] successful.
Please email me if you face any issue.