안녕하세요. 썬구루입니다. 이 게시물에서는 CentOS 7.3 리눅스를 iSCSI Target으로 구성 방법에 대해 간단하게 알아보도록 하겠습니다.
디스크 스토리지 연결 방식은 DAS, NAS, SAN으로 나누어지는데 여기서 요즘 NAS 디스크 스토리지는 NFS, CIFS, iSCSI를 지원합니다. NFS나 CIFS는 이미 앞에서 언급하고 구성해보았기 때문에 기억하고 있을 것이라 생각됩니다. 이는 스토리지에서 지원하는 파일시스템을 사용하는 것이죠.
저희가 CentOS 7.3을 사용했었고 그 기반에 NFS 서버와 Samba 서버를 구성한 것이기 때문에 CentOS 7.3의 EXT과 XFS 파일시스템을 사용한 것입니다. iSCSI는 Internet SCSI(Smail Computer System Interface)를 나타내며 SCSI 프로토콜을 IP 패킷에 실어 전달할 수 있는 다시 말해 IP 기반 스토리지 네트워킹 기술을 사용할 수 있도록 해주는 기술입니다.
이는 이미 파일시스템이 만들어진 파일시스템 공유가 아닌 Raw Device를 네트워크를 통해 공유할 수 있도록 만들어주는 기술입니다.
서버의 하드 디스크, 테이프 드라이브, 로봇 디바이스 등을 iSCSI를 통해 다른 서버로 공유해줄 수 있는 것입니다. 만약 iSCSI를 통해 공유 받은 하드디스크를 리눅스(Linux)가 사용한다면 EXT, XFS 파일시스템을 만들어 사용할 수 있고 윈도우(Windows)가 사용한다면 NTFS, 솔라리스(Solaris)가 사용한다면 UFS 또는 ZFS 파일시스템을 만들어 사용할 수 있습니다. 왜? Raw Device를 공유하는 것이기 때문입니다.
그래서 여러분들은 VMware Workstation 환경에서 아래와 같은 공유 디바이스(또는 파일시스템)를 만들어 사용할 수 있습니다
▶ NFS
▶ CIFS
▶ Shared SCSI
▶ iSCSI
▶ Tape drive
▶ Changer (Tape Library Robot)
이러한 공유 디바이스(또는 파일시스템)을 가지고 아래와 같은 서비스를 테스트할 수 있습니다.
▶ WEB/WAS 이중화
▶ 클러스터 파일시스템 (Cluster Filesystem)
▶ 클러스터 서버 (Cluster Server)
▶ 서버 가상화 (Server Virtualization)
▶ 데스크톱 가상화 (Desktop Virtualization)
▶ 클라우드 서비스 (Cloud Service)
▶ Oracle RAC
▶ 백업 솔루션 (Veritas NetBackup, Dell NetVault, Legato Networker)
어잇~!!! iSCSI 설명하다가 배가 산으로 갔군요. CentOS 7.3 리눅스에서 CentOS 6.x 버전과 달리 iSCSi 구성하는 것이 많이 달라졌습니다. 일단 이 게시물에선 간단하게 iSCSI Targer과 Initiator를 구성해보도록 하겠습니다. 테스트를 위한 가상머신 환경은 아래와 같습니다.
사양
|
iSCSI Target
|
iSCSI Initiator
|
CPU
|
1 CPU / 2 Cores
|
1 CPU / 2 Cores |
MEM
|
2GB
|
2GB |
HDD
|
20GB /dev/sda OS
10GB /dev/sdb iSCSI Device
10GB /dev/sdc iSCSI Device
|
20GB /dev/sda OS |
NIC
|
1 Gbps
|
1Gbps |
OS
|
CentOS 7.3
|
CentOS 7.3 |
Hostname / IP
|
target01 / 192.168.80.13
|
initiator01 / 192.168.80.14 |
■ CentOS 7.3 리눅스에 iSCSI Target 패키지 설치
아래와 같이 명령을 실행하여 iSCSI Target 관련 패키지를 설치한다.
[root@target01 ~]# vi /etc/yum.repos.d/CentOS-Media.repo
You have mail in /var/spool/mail/root [root@target01 ~]# [root@target01 ~]# more /etc/yum.repos.d/CentOS-Media.repo # CentOS-Media.repo # # This repo can be used with mounted DVD media, verify the mount point for # CentOS-7. You can use this repo and yum to install items directly off the # DVD ISO that we release. # # To use this repo, put in your DVD and use it with the other repos too: # yum --enablerepo=c7-media [command] # # or for ONLY the media repo, do this: # # yum --disablerepo=\* --enablerepo=c7-media [command] [c7-media] name=CentOS-$releasever - Media baseurl=file:///media/CentOS/ file:///media/cdrom/ file:///run/media/root/CentOS\ 7\ x86_64/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 [root@target01 ~]# [root@target01 ~]# df -h | grep sr0 /dev/sr0 7.8G 7.8G 0 100% /run/media/root/CentOS 7 x86_64 [root@target01 ~]# [root@target01 ~]# yum --disablerepo=\* --enablerepo=c7-media -y install targetcli Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * c7-media: Resolving Dependencies --> Running transaction check ---> Package targetcli.noarch 0:2.1.fb41-3.el7 will be installed --> Processing Dependency: python-rtslib >= 2.1.fb41 for package: targetcli-2.1.fb41-3.el7.noarch --> Processing Dependency: python-configshell for package: targetcli-2.1.fb41-3.el7.noarch --> Running transaction check ---> Package python-configshell.noarch 1:1.1.fb18-1.el7 will be installed --> Processing Dependency: python-urwid for package: 1:python-configshell-1.1.fb18-1.el7.noarch --> Processing Dependency: pyparsing for package: 1:python-configshell-1.1.fb18-1.el7.noarch ---> Package python-rtslib.noarch 0:2.1.fb57-5.el7 will be installed --> Processing Dependency: python-kmod for package: python-rtslib-2.1.fb57-5.el7.noarch --> Running transaction check ---> Package pyparsing.noarch 0:1.5.6-9.el7 will be installed ---> Package python-kmod.x86_64 0:0.9-4.el7 will be installed ---> Package python-urwid.x86_64 0:1.1.1-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================== Package Arch Version Repository Size ======================================================================================================== Installing: targetcli noarch 2.1.fb41-3.el7 c7-media 61 k Installing for dependencies: pyparsing noarch 1.5.6-9.el7 c7-media 94 k python-configshell noarch 1:1.1.fb18-1.el7 c7-media 67 k python-kmod x86_64 0.9-4.el7 c7-media 57 k python-rtslib noarch 2.1.fb57-5.el7 c7-media 88 k python-urwid x86_64 1.1.1-3.el7 c7-media 654 k Transaction Summary ======================================================================================================== Install 1 Package (+5 Dependent packages) Total download size: 1.0 M Installed size: 4.5 M Downloading packages: warning: /run/media/root/CentOS 7 x86_64/Packages/pyparsing-1.5.6-9.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Public key for pyparsing-1.5.6-9.el7.noarch.rpm is not installed -------------------------------------------------------------------------------------------------------- Total 26 MB/s | 1.0 MB 00:00:00 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Importing GPG key 0xF4A80EB5: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>" Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 Package : centos-release-7-3.1611.el7.centos.x86_64 (@anaconda) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : python-kmod-0.9-4.el7.x86_64 1/6 Installing : python-rtslib-2.1.fb57-5.el7.noarch 2/6 Installing : pyparsing-1.5.6-9.el7.noarch 3/6 Installing : python-urwid-1.1.1-3.el7.x86_64 4/6 Installing : 1:python-configshell-1.1.fb18-1.el7.noarch 5/6 Installing : targetcli-2.1.fb41-3.el7.noarch 6/6 Verifying : python-urwid-1.1.1-3.el7.x86_64 1/6 Verifying : python-rtslib-2.1.fb57-5.el7.noarch 2/6 Verifying : 1:python-configshell-1.1.fb18-1.el7.noarch 3/6 Verifying : targetcli-2.1.fb41-3.el7.noarch 4/6 Verifying : pyparsing-1.5.6-9.el7.noarch 5/6 Verifying : python-kmod-0.9-4.el7.x86_64 6/6 Installed: targetcli.noarch 0:2.1.fb41-3.el7 Dependency Installed: pyparsing.noarch 0:1.5.6-9.el7 python-configshell.noarch 1:1.1.fb18-1.el7 python-kmod.x86_64 0:0.9-4.el7 python-rtslib.noarch 0:2.1.fb57-5.el7 python-urwid.x86_64 0:1.1.1-3.el7 Complete! [root@target01 ~]# |
iSCSI 디바이스로 사용할 10GB 디스크 두 개를 추가한 후 디스크를 인식시킨다.
[root@target01 ~]# find /sys/devices/ -name scan
/sys/devices/pci0000:00/0000:00:07.1/ata1/host0/scsi_host/host0/scan /sys/devices/pci0000:00/0000:00:07.1/ata2/host1/scsi_host/host1/scan /sys/devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2/scan [root@target01 ~]# [root@target01 ~]# echo "- - -" > /sys/devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2/scan [root@target01 ~]# [root@target01 ~]# lsblk | grep disk fd0 2:0 1 4K 0 disk sda 8:0 0 20G 0 disk sdb 8:16 0 10G 0 disk sdc 8:32 0 10G 0 disk [root@target01 ~]# |
■ iSCSI Target 디바이스 구성
targetcli 명령을 사용하여 iSCSI Target 디바이스를 구성한다.
[root@target01 ~]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin. targetcli shell version 2.1.fb41 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] /> /> cd /backstores/ /backstores> ls o- backstores .................................................................................... [...] o- block ........................................................................ [Storage Objects: 0] o- fileio ....................................................................... [Storage Objects: 0] o- pscsi ........................................................................ [Storage Objects: 0] o- ramdisk ...................................................................... [Storage Objects: 0] /backstores> /backstores> block/ create name=iscsi_disk1 dev=/dev/sdb Created block storage object iscsi_disk1 using /dev/sdb. /backstores> block/ create name=iscsi_disk2 dev=/dev/sdc Created block storage object iscsi_disk2 using /dev/sdc. /backstores> /backstores> ls o- backstores .................................................................................... [...] o- block ........................................................................ [Storage Objects: 2] | o- iscsi_disk1 ......................................... [/dev/sdb (10.0GiB) write-thru deactivated] | o- iscsi_disk2 ......................................... [/dev/sdc (10.0GiB) write-thru deactivated] o- fileio ....................................................................... [Storage Objects: 0] o- pscsi ........................................................................ [Storage Objects: 0] o- ramdisk ...................................................................... [Storage Objects: 0] /backstores> /backstores> cd /iscsi /iscsi> ls o- iscsi .................................................................................. [Targets: 0] /iscsi> create iqn.2017-02.com.localdcv.iscsi1:server Created target iqn.2017-02.com.localdcv.iscsi1:server. Created TPG 1. Global pref auto_add_default_portal=true Created default portal listening on all IPs (0.0.0.0), port 3260. /iscsi> ls o- iscsi .................................................................................. [Targets: 1] o- iqn.2017-02.com.localdcv.iscsi1:server .................................................. [TPGs: 1] 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] /iscsi> cd iqn.2017-02.com.localdcv.iscsi1:server/tpg1/luns /iscsi/iqn.20...ver/tpg1/luns> create /backstores/block/iscsi_disk1 Created LUN 0. /iscsi/iqn.20...ver/tpg1/luns> create /backstores/block/iscsi_disk2 Created LUN 1. /iscsi/iqn.20...ver/tpg1/luns> ls o- luns ...................................................................................... [LUNs: 2] o- lun0 ............................................................... [block/iscsi_disk1 (/dev/sdb)] o- lun1 ............................................................... [block/iscsi_disk2 (/dev/sdc)] /iscsi/iqn.20...ver/tpg1/luns> cd .. /iscsi/iqn.20...1:server/tpg1> cd acls /iscsi/iqn.20...ver/tpg1/acls> create iqn.2017-02.com.localdcv.iscsi1:initiator01 <== iSCSI Initiator Created Node ACL for iqn.2017-02.com.localdcv.iscsi1:initiator01 Created mapped LUN 1. Created mapped LUN 0. /iscsi/iqn.20...ver/tpg1/acls> cd / /> ls o- / ............................................................................................. [...] o- backstores .................................................................................. [...] | o- block ...................................................................... [Storage Objects: 2] | | o- iscsi_disk1 ......................................... [/dev/sdb (10.0GiB) write-thru activated] | | o- iscsi_disk2 ......................................... [/dev/sdc (10.0GiB) write-thru activated] | o- fileio ..................................................................... [Storage Objects: 0] | o- pscsi ...................................................................... [Storage Objects: 0] | o- ramdisk .................................................................... [Storage Objects: 0] o- iscsi ................................................................................ [Targets: 1] | o- iqn.2017-02.com.localdcv.iscsi1:server ................................................ [TPGs: 1] | o- tpg1 ................................................................... [no-gen-acls, no-auth] | o- acls .............................................................................. [ACLs: 1] | | o- iqn.2017-02.com.localdcv.iscsi1:initiator01 .............................. [Mapped LUNs: 2] | | o- mapped_lun0 ............................................... [lun0 block/iscsi_disk1 (rw)] | | o- mapped_lun1 ............................................... [lun1 block/iscsi_disk2 (rw)] | o- luns .............................................................................. [LUNs: 2] | | o- lun0 ....................................................... [block/iscsi_disk1 (/dev/sdb)] | | o- lun1 ....................................................... [block/iscsi_disk2 (/dev/sdc)] | o- portals ........................................................................ [Portals: 1] | o- 0.0.0.0: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 [root@target01 ~]# [root@target01 ~]# firewall-cmd --permanent --add-service=iscsi-target success [root@target01 ~]# firewall-cmd --reload success [root@target01 ~]# |
■ iSCSI Target 서비스 시작
아래와 같이 systemctl 명령을 사용하여 iSCSI Target 서비스를 실행한다.
[root@target01 ~]# systemctl enable target
Created symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/target.service. [root@target01 ~]# systemctl start target [root@target01 ~]# systemctl status target ● target.service - Restore LIO kernel target configuration Loaded: loaded (/usr/lib/systemd/system/target.service; enabled; vendor preset: disabled) Active: active (exited) since Sun 2017-02-05 05:31:41 EST; 12min ago Process: 3978 ExecStart=/usr/bin/targetctl restore (code=exited, status=0/SUCCESS) Main PID: 3978 (code=exited, status=0/SUCCESS) CGroup: /system.slice/target.service Feb 05 05:31:40 target01 systemd[1]: Starting Restore LIO kernel target configuration... Feb 05 05:31:41 target01 systemd[1]: Started Restore LIO kernel target configuration. [root@target01 ~]# |
■ iSCSI Initiator 구성 및 디스크 구성
CentOS 7.3 리눅스를 Server with GUI로 설치하면 기본적으로 iSCSI Initiator 패키지가 같이 설치된다. 이를 이용하여 iSCSI Target 디바이스를 연결 후 연결된 디바이스를 확인한다. 또한 파티션 분할 후 파일시스템을 생성해본다.
[root@initiator01 iscsi]# lsblk | grep disk
fd0 2:0 1 4K 0 disk sda 8:0 0 20G 0 disk [root@initiator01 iscsi]# [root@localhost ~]# rpm -qa | grep scsi-ini iscsi-initiator-utils-6.2.0.873-35.el7.x86_64 iscsi-initiator-utils-iscsiuio-6.2.0.873-35.el7.x86_64 [root@localhost ~]# [root@initiator01 iscsi]# more initiatorname.iscsi InitiatorName=iqn.1994-05.com.redhat:278879972a52 [root@initiator01 iscsi]# vi initiatorname.iscsi InitiatorName=iqn.2017-02.com.localdcv.iscsi1:initiator01 <== 매우 중요. iSCSI Target 디바이스 구성시 ACLs 허용 정보 [root@initiator01 iscsi]# [root@initiator01 iscsi]# systemctl restart iscsi [root@initiator01 iscsi]# systemctl restart iscsid [root@initiator01 iscsi]# cd [root@initiator01 ~]# iscsiadm -m discovery -t st -p 192.168.80.13:3260 192.168.80.13:3260,1 iqn.2017-02.com.localdcv.iscsi1:server [root@initiator01 iscsi]# iscsiadm -m node -T iqn.2017-02.com.localdcv.iscsi1:server --login Logging in to [iface: default, target: iqn.2017-02.com.localdcv.iscsi1:server, portal: 192.168.80.13,3260] (multiple) Login to [iface: default, target: iqn.2017-02.com.localdcv.iscsi1:server, portal: 192.168.80.13,3260] successful. [root@initiator01 iscsi]# lsblk | grep disk fd0 2:0 1 4K 0 disk sda 8:0 0 20G 0 disk sdb 8:16 0 10G 0 disk sdc 8:32 0 10G 0 disk [root@initiator01 iscsi]# [root@initiator01 iscsi]# parted /dev/sdb mklabel gpt Information: You may need to update /etc/fstab. [root@initiator01 iscsi]# parted /dev/sdb unit GB mkpart 1st xfs 0 100% Information: You may need to update /etc/fstab. [root@initiator01 iscsi]# lsblk /dev/sdb NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 0 10G 0 disk └─sdb1 8:17 0 10G 0 part [root@initiator01 iscsi]# [root@initiator01 iscsi]# mkfs -t xfs /dev/sdb1 meta-data=/dev/sdb1 isize=512 agcount=4, agsize=654848 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=2619392, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 [root@initiator01 iscsi]# [root@initiator01 iscsi]# mkdir /data01 [root@initiator01 iscsi]# [root@initiator01 iscsi]# mount /dev/sdb1 /data01 [root@initiator01 iscsi]# [root@initiator01 iscsi]# df -h /data01 Filesystem Size Used Avail Use% Mounted on /dev/sdb1 10G 33M 10G 1% /data01 [root@initiator01 iscsi]# [root@initiator01 iscsi]# blkid | grep sdb1 /dev/sdb1: UUID="4fa16cc7-a082-49ce-b36c-8cda48b195f9" TYPE="xfs" PARTLABEL="1st" PARTUUID="115de10d-52c2-43dc-bb85-05afb8fbbf3c" [root@initiator01 iscsi]# |
잘 구성되죠. 여기까지 iSCSI 간단 구성에 대해 알아보았습니다. 설명이 엄청 많이 부족한 감이 있네요. 시간을 지배하지 못해서.. 흠흠.. 좀 더 상세한 내용은 다음에 올리도록 하겠습니다. 그럼..
No comments:
Post a Comment