Você está na página 1de 6

ISCSI IN RHEL 7

What is iscsi ?
ISCSI, which stands for Internet Small Computer System Interface
ISCSI is an Internet Protocol based storage networking standard for linking data storage
facilities. By carrying SCSI commands over IP networks, iSCSI can facilitate data transfers
over local area networks (LANs), wide area networks (WANs), or the Internet. Through iSCSI,
the space on storage server will be regarded as local disks by client's operation system. But in
reality, all data transferred to the disk are actually transferred over network to the storage
server.

What is iSCSI Target and LUN?


In SCSI terminology, A LUN (logical unit number) represents an individually
addressable (logical) SCSI device that is part of a physical SCSI device (called "Target"). An
iSCSI environment emulates the connection to a SCSI hard disk. An iSCSI Target is like a
connection interface, and LUNs are essentially numbered disk drives. When an iSCSI Target is
connected by an iSCSI initiator (a client), all the LUNs mapped to the iSCSI Target are
virtually attached to the client's operation system. Therefore, Initiators can establish and
manage file systems on iSCSI LUNs, as they would a raw SCSI or IDE hard drive
ISCSI Configuration :
Server :
IPADDRESS:192.168.3.137
HOSTNAME:storage.linjb.com
ISCSI Target Setup on Server(Storage):
To Install Targetcli:
# yum install targetcli
#yum install iscsi-initiator-utils*
Start the target service :
# systemctl start target.service
Configure target to persistantly start at boot time:
# systemctl enable target.service

To start using targetcli, run targetcli and to get a layout of the tree interface,
run ls:
[root@apache ~]# 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'.
/> 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]
/>
To create a fileio storage object, run the command in backstores/fileio
/> cd backstores/fileio/
/backstores/fileio> create test /tmp/taashee.img 200m
Created fileio test with size 209715200
/backstores/fileio> create lv /dev/vg_iscsi/lv_iscsi
Note: block backstore preferred for best results
Created fileio lv with size 9663676416
Create an iscsi target :
Move into /iscsi and run create command for default target name
/> cd iscsi
/iscsi> create
Created target iqn.2003-01.org.linux-iscsi.apache.x8664:sn.4fa62d024441.
Created TPG 1.
Create an iscsi portal :
Move into portal and run create command
/iscsi> cd iqn.2003-01.org.linux-iscsi.apache.x8664:sn.4fa62d024441/tpg1/portals

/iscsi/iqn.20.../tpg1/portals> create
Using default IP port 3260
Binding to INADDR_ANY (0.0.0.0)
Created network portal 0.0.0.0:3260.

Create LUNs of already created storage objects


Move an into luns run command create /backstores/fileio/test or lv
/iscsi/iqn.20...441/tpg1/luns> create /backstores/fileio/test
Created LUN 0.
/iscsi/iqn.20...441/tpg1/luns> create /backstores/fileio/lv
Created LUN 1

Set attribute run following command


/iscsi/iqn.20...2d024441/tpg1> set attribute authentication=0
Parameter authentication is now '0'.
/iscsi/iqn.20...2d024441/tpg1> set attribute generate_node_acls=1
Parameter generate_node_acls is now '1'.
Run exit command for save and out
/iscsi/iqn.20...2d024441 /tpg1> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
Ckecking port is open using following command
[root@apache ~]# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address
Foreign Address
tcp
0 0 127.0.0.1:25
0.0.0.0:*
LISTEN
tcp
0 0 0.0.0.0:48825
0.0.0.0:*
LISTEN
tcp
0 0 127.0.0.1:6010
0.0.0.0:*
LISTEN
tcp
0 0 127.0.0.1:6011
0.0.0.0:*
LISTEN
tcp
0 0 0.0.0.0:3260
0.0.0.0:*
LISTEN
tcp
0 0 0.0.0.0:445
0.0.0.0:*
LISTEN
tcp
0 0 0.0.0.0:2049
0.0.0.0:*
LISTEN

State

Checking from server side (storage) or local testing


[root@storage ~]# iscsiadm --mode discovery --type sendtargets --portal 127.0.0.1
--discover127.0.0.1:3260,1 iqn.2003-01.org.linux-iscsi.storage.x8664:sn.4fa62d024441
[root@storage ~]# iscsiadm --mode node --targetname iqn.2003-01.org.linuxiscsi.storage.x8664:sn.4fa62d024441 --portal 127.0.0.1 --login
Logging in to [iface: default, target: iqn.2003-01.org.linuxiscsi.storage.x8664:sn.4fa62d024441, portal: 127.0.0.1,3260] (multiple)
Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.storage.x8664:sn.4fa62d024441,
portal: 127.0.0.1,3260] successful.
[root@storage ~]# lsblk
NAME
MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0
2:0 1 4K 0 disk
sda
8:0 0 20G 0 disk
sda1
8:1 0 500M 0 part /boot
sda2
8:2 0 19.5G 0 part
rhel-root
253:0 0 17.5G 0 lvm /
rhel-swap
253:1 0 2G 0 lvm [SWAP]
sdb
8:16 0 10G 0 disk
vg_iscsi-lv_iscsi 253:2 0 9G 0 lvm /data
sdc
8:32 0 200M 1 disk
sr0
11:0 1 1024M 0 rom
Checking from cluster1 node :
IPADDRESS:192.168.3.76
HOSTNAME:cluster1.linjb.com
Install iscsi package
# yum install iscsi-initiator-utils*
Following package will installed :
libiscsi-1.9.0-6.el7.x86_64
iscsi-initiator-utils-iscsiuio-6.2.0.873-21.el7.x86_64
iscsi-initiator-utils-6.2.0.873-21.el7.x86_64
[root@cluster1 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.3.137
192.168.3.137192.168.3.137:3260,1 iqn.2003-01.org.linux-iscsi.storage.x8664:sn.4fa62d024441

For login using following command :


[root@cluster1 ~]# iscsiadm -m node -T iqn.2003-01.org.linux-

iscsi.storage.x8664:sn.4fa62d024441 -p 192.168.3.137:3260 -l
Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.storage.x8664:sn.4fa62d024441,
portal: 192.168.3.137,3260] (multiple)
Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.storage.x8664:sn.4fa62d024441, portal:
192.168.3.137,3260] successful.

After successful login fire following command to check share directory


[root@cluster1 ~]# lsblk
NAME
MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0
2:0 1 4K 0 disk
sda
8:0 0 20G 0 disk
sda1
8:1 0 500M 0 part /boot
sda2
8:2 0 19.5G 0 part
rhel-root 253:0 0 17.5G 0 lvm /
rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb
8:16 0 200M 1 disk
sdd
8:48 0 9G 1 disk
sr0
11:0 1 1024M 0 rom
After login and checking the directory logout from device using below command
[root@cluster1 ~]# iscsiadm -m node -T iqn.2003-01.org.linuxiscsi.storage.x8664:sn.4fa62d024441 -p 192.168.3.137:3260 --logout
Logging out of session [sid: 5, target: iqn.2003-01.org.linuxiscsi.storage.x8664:sn.4fa62d024441, portal: 192.168.3.137,3260]
Logout of [sid: 5, target: iqn.2003-01.org.linux-iscsi.storage.x8664:sn.4fa62d024441, portal:
192.168.3.137,3260] successful.

Checking from cluster2 node :


IPADDRESS:192.168.3.77
HOSTNAME:cluster2.linjb.com
Install iscsi package
# yum install iscsi-initiator-utils*

Following package will installed :


libiscsi-1.9.0-6.el7.x86_64
iscsi-initiator-utils-iscsiuio-6.2.0.873-21.el7.x86_64
iscsi-initiator-utils-6.2.0.873-21.el7.x86_64
[root@cluster2 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.3.137
192.168.3.137192.168.3.137:3260,1 iqn.2003-01.org.linux-iscsi.storage.x8664:sn.4fa62d024441

login using following command :


[root@cluster2 ~]# iscsiadm -m node -T iqn.2003-01.org.linux-

iscsi.storage.x8664:sn.4fa62d024441 -p 192.168.3.137:3260 -l
Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.storage.x8664:sn.4fa62d024441,
portal: 192.168.3.137,3260] (multiple)
Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.storage.x8664:sn.4fa62d024441, portal:
192.168.3.137,3260] successful.

After successful login fire following command to check share directory


[root@cluster2 ~]# lsblk
NAME
MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0
2:0 1 4K 0 disk
sda
8:0 0 20G 0 disk
sda1
8:1 0 500M 0 part /boot
sda2
8:2 0 19.5G 0 part
rhel-root 253:0 0 17.5G 0 lvm /
rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb
8:16 0 200M 1 disk
sdc
8:32 0 9G 1 disk
sr0
11:0 1 1024M 0 rom
After login and checking the directory logout from device using below command
[root@cluster2 ~]# iscsiadm -m node -T iqn.2003-01.org.linuxiscsi.storage.x8664:sn.4fa62d024441 -p 192.168.3.137:3260 --logout
Logging out of session [sid: 5, target: iqn.2003-01.org.linuxiscsi.storage.x8664:sn.4fa62d024441, portal: 192.168.3.137,3260]
Logout of [sid: 5, target: iqn.2003-01.org.linux-iscsi.storage.x8664:sn.4fa62d024441, portal:
192.168.3.137,3260] successful.

Você também pode gostar