RHEL7: Configuration Client/Serveur ISCSI
Présentation
Dans le monde ISCSI, il y a deux types d’agent :
- L’ iSCSI target le serveur de stockage
- L’iSCSI initiator le client qui se connecte sur les cibles iscsi
On dispose donc de deux machines.
Configuration des cibles iSCSI “target”
Avec Red hat 7, L’outil targetcli permet de mettre en oeuvre des cibles
Étape à suivre pour mettre en oeuvre le serveur
Installer targetcli :
# yum install -y targetcli
Activer le service au boot :
# systemctl enable target
Lancer le Shell Targetcli:
# targetcli Warning: Could not load preferences file /root/.targetcli/prefs.bin. targetcli shell version 2.1.fb34 Copyright 2011-2013 by Datera, Inc and others. For help on commands, type 'help'. /;
Deux options pour le stockage:
- On crée un stockage de type fileio, un fichier dans un répertoire . ce fichier se nomme shareIso et fait 10G in repertoire /store :
/; backstores/fileio/ create shareIso /store/shareIso .img 10G Created fileio shareIso with size 1048576000
- On crée un stockage à partir d’un Volume logique (# lvcreate –name lv_vm_rhel –size 100G vg_iscsi):
-
/; backstores/block/ create block1 /dev/vg_iscsi/ lv_vm_rhel Created block storage object block1 using /dev/vg_iscsi/ lv_vm_rhel.
On crée ensuite deux IQN (Iscsi Qualified Name) nommés iqn.2016-01.lan.alphorm avec pour nom de cibles rhel et iso associés au TPG 1 (Target Portal Group) :
/; iscsi/ create iqn.2016-01.lan.alphorm:rhel Created target iqn.2016-01.lan.alphorm:rhel. Created TPG 1. Global pref auto_add_default_portal=true Created default portal listening on all IPs (0.0.0.0), port 3260.
/; iscsi/ create iqn.2016-01.lan.alphorm:iso Created target iqn.2016-01.lan.alphorm:iso. Created TPG 1. Global pref auto_add_default_portal=true Created default portal listening on all IPs (0.0.0.0), port 3260.
L’arborescence pour l’iqn iqn.2016-01.lan.alphorm:rhel est maintenant créée
/; cd iscsi/iqn.2016-01.lan.alphorm:rhel/tpg1 /iscsi/iqn.20...horm:rhel/tpg1; ls o- tpg1 ................................................. [no-gen-acls, no-auth] o- acls ............................................................ [ACLs: 0] o- luns ............................................................ [LUNs: 0] o- portals ...................................................... [Portals: 1] o- 0.0.0.0:3260 ....................................................... [OK]
3 objets disponibles en dessous de tpg1L
- les LUNSs
- Les listes de controle d’access –
- Le portal.
Création d’un portal
/iscsi/iqn.20...phorm:rhel/tpg1; portals/ create Using default IP port 3260 Binding to INADDR_ANY (0.0.0.0) Created network portal 0.0.0.0:3260.
Création des LUNs
- Fileio backstore:
/iscsi/iqn.20...phorm:iso/tpg1; luns/ create /backstores/fileio/shareIso Created LUN 0.
- Block backstore:
/iscsi/iqn.20...phorm:rhel/tpg1; luns/ create /backstores/block/block1 Created LUN 0.
On positionne des acls sur l’iqn , iqn.2016-01.lan.alphorm:rhel :
/iscsi/iqn.20...phorm:rhel/tpg1; acls/ create iqn.2016-01.lan.alphorm:client Created Node ACL for iqn.2016-01.lan.alphorm:client Created mapped LUN 0
On peut mettre l’authentification CHAP
/iscsi/iqn.20...phorm;rhel/tpg1; cd acls/iqn.2016-01.lan.alphorm:client/ /iscsi/iqn.20...alphorm:client; set auth userid=user Parameter userid is now 'usr'. /iscsi/iqn.20...alphorm:client; set auth password=pwd Parameter password is now 'pwd'.
Now, to check the configuration, type:
/iscsi/iqn.20...alphorm:iso; cd ../.. /iscsi/iqn.20...orm:iso/tpg1; ls o- tpg1 ................................................. [no-gen-acls, no-auth] o- acls ............................................................ [ACLs: 1] | o- iqn.2016-01.lan.alphorm:client ......................... [Mapped LUNs: 1] | o- mapped_lun0 ............................. [lun0 fileio/shareiso (rw)] o- luns ............................................................ [LUNs: 1] | o- lun0 .......................... [fileio/shareiso (/store/shareiso.img)] o- portals ...................................................... [Portals: 1] o- 0.0.0.0:3260 ....................................................... [OK]
On peut sortir de targetcli, la configuration est terminée :
/iscsi/iqn.20...alphorm:iso/tpg1; exit Global pref auto_save_on_exit=true Last 10 configs saved in /etc/target/backup. Configuration saved to /etc/target/saveconfig.json
La configuration est sauvée dans un fichier json !
On autorise le port tpc/3260 pour iscsi :
# firewall-cmd --permanent --add-port=3260/tcp Success
Recharge le configuratioin du firewall :
# firewall-cmd --reload Success
Configuration du client – iSCSI initiator
Installation du service initiateur iscsi
# yum install -y iscsi-initiator-utils
Éditer le fichier /etc/iscsi/initiatorname.iscsi et ajouter l’iqn du client
InitiatorName=iqn.2016-01.lan.alphorm:client
Éditer le fichier the /etc/iscsi/iscsid.conffile et ajouter les lignes suivantes :
node.session.auth.authmethod = CHAP node.session.auth.username = user node.session.auth.password = pwd
Démarrer le service iscsi service:
# systemctl start iscsi
Important : le service iscsim n’est pas confondre avec iscsd. LeService ISCSI doit être démarrer pour démonter les cibles lors du reboot de la machine
Découverte des cibles avec iscsiadm (le portal 192.168.10.100):
# iscsiadm --mode discovery --type sendtargets --portal 192.168.10.100 192.168.10.100:3260,1 iqn.2016-01.lan.alphorm:rhel 192.168.10.100:3260,1 iqn.2106-01.lana.alphorm:iso
Lancer iscsiadm em mode node pour se loguer sur les cibles :
# iscsiadm --mode node --targetname iqn.2016-01.lan.alphorm:rhel --portal 192.168.10.100 --login Logging in to [iface: default, target: iqn.2016-01.lan.alphorm:rhel portal: 192.168.10.100,3260] (multiple) Login to [iface: default, target: iqn.2016-01.lan.alphorm:iso, portal: 192.168.10.100,3260] successful.
Afficher les périphériques bloc :
# lsblk --scsi NAME HCTL TYPE VENDOR MODEL REV TRAN sda 2:0:0:0 disk LIO-ORG shareiso 4.0 iscsi
T
# lsblk | egrep "NAME|sdc" NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdc 8:0 0 10G 0 disk
Dump de la session (3=max output, 0=min output):
# iscsiadm -m session -P 3 iSCSI Transport Class version 2.0-870 version 6.2.0.873-28 Target: iqn.2016-06.lan.alphorm:rhel (non-flash) Current Portal: 192.168.10.100:3260,1 Persistent Portal: 192.168.10.100:3260,1 ********** Interface: ********** Iface Name: default Iface Transport: tcp Iface Initiatorname: iqn.2014-08.lan.alphorm:client Iface IPaddress: 192.168.10.10 Iface HWaddress: Iface Netdev: SID: 1 iSCSI Connection State: LOGGED IN iSCSI Session State: LOGGED_IN Internal iscsid Session State: NO CHANGE ********* Timeouts: ********* Recovery Timeout: 120 Target Reset Timeout: 30 LUN Reset Timeout: 30 Abort Timeout: 15 ***** CHAP: ***** username: user password: ******** username_in: password_in: ******** ************************ Negotiated iSCSI params: ************************ HeaderDigest: None DataDigest: None MaxRecvDataSegmentLength: 262144 MaxXmitDataSegmentLength: 262144 FirstBurstLength: 65536 MaxBurstLength: 262144 ImmediateData: Yes InitialR2T: Yes MaxOutstandingR2T: 1 ************************ Attached SCSI devices: ************************ Host Number: 2 State: running scsi2 Channel 00 Id 0 Lun: 0 Attached scsi disk sda State: running