Вы находитесь на странице: 1из 10

iSCSI

Internet Small Computer System Interface

SAN Storage Area Network


PROTOCOL 3260/tcp (iscsi)
targetd
RPMS
targetcli
iscsi-initiator-utils
CONF
/etc/iscsi/initiatorname.iscsi
targetd
DAEMON
iscsid
FUCTION


hostname:
ip:
physical:

Client
server.ol.com
172.16.7.1/16
Host-only

Server/Linux
client.ol.com
172.16.7.8/16
Host-only

%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Server iSCSI 3260 iSCSI


Client
iSCSI 1400MB
iqn.2014-06.com.ol:server.zoidberg iSCSI
xfs
/mnt/data

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Server172.16.7.1/16 server.ol.com

Physical
# nmtui
# service network restart
# ifconfig | grep -A1 flag
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.7.1 netmask 255.255.0.0 broadcast 172.16.255.255
...
# hostnamectl set-hostname server.ol.com
# echo 172.16.7.1 server.ol.com >> /etc/hosts
# cat /etc/hosts
...
172.16.7.1 server.ol.com
# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x5f2dafdd.
Command (m for help): n

Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +1400M
Partition 1 of type Linux and of size 1400 MiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

# yum -y install targetd targetcli


# systemctl start targetd
# systemctl enable targetd
ln -s '/usr/lib/systemd/system/targetd.service'
'/etc/systemd/system/multi-user.target.wants/targetd.service'

# 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'.

/> /backstores/block create server.zoidberg /dev/sdb1


Created block storage object server.zoidberg using /dev/sdb1.
/> /iscsi create iqn.2014-06.com.ol:server.zoidberg
Created target iqn.2014-06.com.ol:server.zoidberg.
Created TPG 1.
/> /iscsi/iqn.2014-06.com.ol:server.zoidberg/tpg1/luns create
/backstores/block/server.zoidberg
Created LUN 0.
/> /iscsi/iqn.2014-06.com.ol:server.zoidberg/tpg1/acls create
iqn.2014-06.com.ol:client
Created Node ACL for iqn.2014-06.com.ol:client
Created mapped LUN 0.
/> /iscsi/iqn.2014-06.com.ol:server.zoidberg/tpg1/portals create 172.16.7.1
Using default IP port 3260
Created network portal 172.16.7.1:3260.
/> ls
o- / ............................................ [...]
o- backstores ................................. [...]
| o- block ..................... [Storage Objects: 1]
| | o- server.zoidberg [/dev/sdb1 (1.4GiB) write-thru activated]
| o- fileio .................... [Storage Objects: 0]
| o- pscsi ..................... [Storage Objects: 0]
| o- ramdisk ................... [Storage Objects: 0]
o- iscsi ............................... [Targets: 1]
| o- iqn.2014-06.com.ol:server.zoidberg ... [TPGs: 1]
| o- tpg1 .................. [no-gen-acls, no-auth]
|
o- acls ............................. [ACLs: 1]

|
| o- iqn.2014-06.com.ol:client [Mapped LUNs: 1]
|
| o- mapped_lun0 [lun0 block/server.zoidberg (rw)]
|
o- luns ............................. [LUNs: 1]
|
| o- lun0 . [block/server.zoidberg (/dev/sdb1)]
|
o- portals ....................... [Portals: 1]
|
o- 172.16.7.1:3260 ..................... [OK]
o- loopback ............................ [Targets: 0]
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

# firewall-cmd --permanent --add-port=3260/tcp


success

# firewall-cmd --reload
success

Client172.16.7.8/16 client.ol.com
Physical
# nmtui
# service network restart
# ping -c1 172.16.7.1
PING 172.16.7.1 (172.16.7.1) 56(84) bytes of data.

64 bytes from 172.16.7.1: icmp_seq=1 ttl=64 time=0.882 ms


...

# rpm -qa | grep iscsi


iscsi-initiator-utils-6.2.0.873-21.el7.x86_64
libiscsi-1.9.0-6.el7.x86_64
iscsi-initiator-utils-iscsiuio-6.2.0.873-21.el7.x86_64

# sed -i 's/=.*/=iqn.2014-06.com.ol:client/'
/etc/iscsi/initiatorname.iscsi
# cat /etc/iscsi/initiatorname.iscsi
InitiatorName= iqn.2014-06.com.ol:client

# service iscsid restart


Redirecting to /bin/systemctl restart

iscsi.service

# chkconfig iscsid on
Note: Forwarding request to 'systemctl enable iscsid.service'.
ln -s '/usr/lib/systemd/system/iscsid.service'
'/etc/systemd/system/multi-user.target.wants/iscsid.service'

# systemctl status iscsid | grep -E 'Loaded|Active'


Loaded: loaded (/usr/lib/systemd/system/iscsid.service; enabled)
Active: active (running) since Sun 2014-08-10 22:28:10 CST; 55s ago

# man iscsiadm | grep discovery|node


# iscsiadm -m discovery -t st -p 172.16.7.1
172.16.7.1:3260,1 iqn.2014-06.com.ol:server.zoidberg

# iscsiadm -m node -T iqn.2014-06.com.ol:server.zoidberg -p


172.16.7.1 -l
Logging in to [iface: default, target: iqn.2014-06.com.ol:server.zoidberg, portal:
172.16.7.1,3260] (multiple)
Login to [iface: default, target: iqn.2014-06.com.ol:server.zoidberg, portal:
172.16.7.1,3260] successful.

# ls -l /var/lib/iscsi/{send_targets,nodes}
# fdisk -l | grep sd
Disk /dev/sda: 128.8 GB, 128849018880 bytes, 251658240 sectors
/dev/sda1 *
2048
1026047
512000 83 Linux
/dev/sda2
1026048 251658239 125316096 8e Linux LVM
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Disk /dev/sdc: 2147 MB, 2147483648 bytes, 4194304 sectors

# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xc432d66d.
Command (m for help): n

Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-4194303, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303): +1400M
Partition 1 of type Linux and of size 1.4 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

# mkfs.xfs /dev/sdc1
meta-data=/dev/sdc1
=
=
data
=
=
naming
=version 2
log
=internal log
=
lazy-count=1

isize=256
agcount=4, agsize=89600 blks
sectsz=512
attr=2, projid32bit=1
crc=0
bsize=4096
blocks=358400, imaxpct=25
sunit=0
swidth=0 blks
bsize=4096
ascii-ci=0 ftype=0
bsize=4096
blocks=2560, version=2
sectsz=512
sunit=0 blks,

realtime

=none

extsz=4096

blocks=0, rtextents=0

# blkid /dev/sdc1
/dev/sdc1: UUID="423c522b-7ee8-4372-8df0-56680ca8a0bc" TYPE="xfs"

# mkdir /mnt/data
# echo -e
'UUID=423c522b-7ee8-4372-8df0-56680ca8a0bc\t/mnt/data\txfs\
tdefaults,_netdev\t0 0' >> /etc/fstab
# tail -n 2 /etc/fstab
/dev/mapper/rhel-swap swap
UUID=423c522b-7ee8-4372-8df0-56680ca8a0bc
defaults,_netdev 0 0

swap
defaults
/mnt/data

0 0
xfs

# mount -a
# findmnt /mnt/data
TARGET
SOURCE
/mnt/data /dev/sdc1 xfs

FSTYPE OPTIONS
rw,relatime,seclabel,attr2,inode64,noquota

Вам также может понравиться