카테고리 없음

iscsi vm으로 테스트(서버,클라이언트)

minjunc 2020. 1. 2. 22:43

iSCSI Target 구성하기(Server)

서비스가 설치되었는지 확인/설치한다.

yum install scsi-target-utils

데몬을 기동한다.

/etc/rc.d/init.d/tgtd start

부팅시 자동 실행되도록 등록한다.

chkconfig --level 35 tgtd on

이름을 지정한다. -T 뒤에 이름을 적어주면 된다. tid별로 이름을 하나씩 가짐

tgtadm --lld iscsi --mode target --op new --tid 1 -T iqn.edutotal.com:storage.disk1

설정을 확인

tgtadm --lld iscsi --mode target --op show

설정한 Target에 시스템의 볼륨을 등록

tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 -b /dev/sdb

접근 할수 있도록 bind (-I 옵션이 client의 접근가능)

tgtadm --lld iscsi --mode target --op bind --tid 1 -I ALL

설정 정보를 설정파일로 등록

tgt-admin --dump >> /etc/tgt/targets.conf

tid별 타켓된 binding 리스트 확인

tgtadm --lld iscsi --mode target --op show --tid 1

iSCSI Initiator 구성하기(Client)

유틸이 설치되었는지 확인/설치한다.

yum install iscsi-initiator-utils

환경설정

cat /etc/iscsi/initiatorname.iscsi

환경설정

iscsi-iname

환경설정

vi /etc/iscsi/iscsid.conf

데몬을 가동한다.

/etc/rc.d/init.d/iscsi start

Target 시스템을 찾는다.

iscsiadm --mode discovery --type sendtargets --portal IP주소

로그인한다. ( IP주소:포트 형식이다 )

iscsiadm --mode node --targetname iqn.20201.com:domain.disk1 --portal IP주소:3260 --login

/etc/rc.d/init.d/iscsi restart

연결된 드라이브를 찾는다.

tall -f /var/log/messages

Oct 10 12:42:20 ora9is2 kernel: SCSI device sdd: 41963520 512-byte hdwr sectors (21485 MB)

로그아웃 하는 법

iscsiadm --mode node --targetname iqn.20201.com:domain.disk1 --portal IP주소:3260 --logout

포멧

fdisk /dev/sdd

mk32fs -j -m 0 -O dir_index /dev/sdd1

or

mkfs.ext3 /dev/sdd1

마운트

mkdir /mnt/iscsi

mount /dev/sdd1 /mnt/iscsi

부팅시 활성화

chkconfig --level 35 iscsi on

fatab 등록

vi /etc/fstab

/dev/sdd1 /mnt/iscsi ext3 _netdev 0 0

클라이언트쪽에서 fdisk -l로 디스크가 보이면 서버쪽에서 할 일이 끝났다.

클라이언트쪽에서 multipath 작업을 시작한다.


mpathconf --enable 명령어로 파일생성

multipath -v2 로 mpathX 생성

wwids 내 os디스크 ID를 /etc/multipath.conf 의 블랙리스트에 추가

/etc/multipath/bindings 내용에 mpathX->dataX 이름 바꾸고

multipath -F로 플러시내용 지운다음 -v2로 다시 만들면

원하는 이름으로 다시 만들어짐

이제 pvcreate vgcreate lvcreate 한다.

LVM 작업을 할 때는 담당자와 협의 하거나 미리 보내온 작업 정보에 따라서 한다.



lvcreate 할때 -i 옵션으로 스트라이프 갯수를 지정.

디스크가 보여야 하는데 안보일 경우->바로 말한다. ( 절대 내 생각대로 하지 말것 )



7버전


(1) 서버설정

1. targetcli 설치

serverX# yum -y install targetcli


2. target으로 사용할 LV생성, 디스크파티션생성

# vgcreate target_vg /dev/sdc2

# lvcreate -n target_lv -l +100%FREE target_vg

# lvs

LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert

target_lv target_vg -wi-a----- 1020.00m

- /dev/sde (디스크파티션 생성)

3. 보조스토리지 저장소(파일) 생성

# targetcli

/> cd /backstores

/backstores> fileio/ create file1 /root/disk1_file1 100M


4. 보조스토리지 저장소(block) 생성

# targetcli

/> cd /backstores

/backstores> block/ create block1 /dev/target_vg/target_lv

Created block storage object block1 using /dev/target_vg/target_lv.

/backstores> block/ create block2 /dev/sde

Created block storage object block2 using /dev/sde.


/backstores> ls

o- backstores ................................................................................................................ [...]

o- block .................................................................................................... [Storage Objects: 2]

| o- block1 ........................................................ [/dev/target_vg/target_lv (1020.0MiB) write-thru deactivated]

| o- block2 ........................................................................... [/dev/sde (1.0GiB) write-thru deactivated]

o- fileio ................................................................................................... [Storage Objects: 1]

| o- file1 ................................................................... [/root/disk1_file1 (100.0MiB) write-back activated]

o- pscsi .................................................................................................... [Storage Objects: 0]

o- ramdisk .................................................................................................. [Storage Objects: 0]

5. 대상의 IQN 생성

/> cd /iscsi

/iscsi> create iqn.2015-04.com.example:remotedisk1

Created target iqn.2015-04.com.example:remotedisk1.

Created TPG 1.


6. TPG1에 대한 ACL생성

/iscsi> cd iqn.2015-04.com.example:remotedisk1/

/iscsi/iqn.20...e:remotedisk1> cd tpg1/

/iscsi/iqn.20...otedisk1/tpg1> acls/ create iqn.2015-04.com.example:desktopX

Created Node ACL for iqn.2015-04.com.example:desktopx

Created mapped LUN 0.

 

7. file1, block1,2 에대한 LUN생성

/iscsi/iqn.20...otedisk1/tpg1> luns/ create /backstores/fileio/file1

Created LUN 0.

/iscsi/iqn.20...otedisk1/tpg1> luns/ create /backstores/block/block1

Created LUN 1.

Created LUN 1->1 mapping in node ACL iqn.2015-04.com.example:desktopx

/iscsi/iqn.20...otedisk1/tpg1> luns/ create /backstores/block/block2

Created LUN 2.

Created LUN 2->2 mapping in node ACL iqn.2015-04.com.example:desktopx


8. Portal 생성 (서버의 if주소로 생성)

/iscsi/iqn.20...otedisk1/tpg1> portals/ create 165.213.246.94

Using default IP port 3260

Created network portal 165.213.246.94:3260.


9. 전체 구성확인

/iscsi/iqn.20...otedisk1/tpg1> cd /

/> ls

o- / ......................................................................................................................... [...]

o- backstores .............................................................................................................. [...]

| o- block .................................................................................................. [Storage Objects: 2]

| | o- block1 ........................................................ [/dev/target_vg/target_lv (1020.0MiB) write-thru activated]

| | o- block2 ........................................................................... [/dev/sde (1.0GiB) write-thru activated]

| o- fileio ................................................................................................. [Storage Objects: 1]

| | o- file1 ................................................................. [/root/disk1_file1 (100.0MiB) write-back activated]

| o- pscsi .................................................................................................. [Storage Objects: 0]

| o- ramdisk ................................................................................................ [Storage Objects: 0]

o- iscsi ............................................................................................................ [Targets: 1]

| o- iqn.2015-04.com.example:remotedisk1 ............................................................................... [TPGs: 1]

| o- tpg1 ............................................................................................... [no-gen-acls, no-auth]

| o- acls .......................................................................................................... [ACLs: 1]

| | o- iqn.2015-04.com.example:desktopx ..................................................................... [Mapped LUNs: 3]

| | o- mapped_lun0 ................................................................................ [lun0 fileio/file1 (rw)]

| | o- mapped_lun1 ................................................................................ [lun1 block/block1 (rw)]

| | o- mapped_lun2 ................................................................................ [lun2 block/block2 (rw)]

| o- luns .......................................................................................................... [LUNs: 3]

| | o- lun0 ............................................................................... [fileio/file1 (/root/disk1_file1)]

| | o- lun1 ........................................................................ [block/block1 (/dev/target_vg/target_lv)]

| | o- lun2 ........................................................................................ [block/block2 (/dev/sde)]

| o- portals .................................................................................................... [Portals: 1]

| o- 165.213.246.94: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


10. 방화벽 등록 및 재시작

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

# firewall-cmd --reload

# systemctl restart target.service









(2) 클라이언트 설정

1. iscsi-initiator-utils 설치

# yum -y install iscsi-initiator-utils


2. 클라이언트의 이니시에이터 네임설정

#vi /etc/iscsi/initiatorname.iscsi

InitiatorName=iqn.2015-04.com.example:desktopX


 

3. iscsi 서비스 활성화 및 시작

# systemctl enable iscsi

# systemctl start iscsi


 

4. 포털검색

# iscsiadm -m iscsiadm -m discovery -t sendtargets -p 165.213.246.94

165.213.246.94:3260,1 iqn.2015-04.com.example:remotedisk1


 

5. 포털 로그인

# iscsiadm -m iscsiadm -m node -T "iqn.2015-04.com.example:remotedisk1" -p 165.213.246.94:3260 -l

Logging in to [iface: default, target: iqn.2015-04.com.example:remotedisk1, portal: 165.213.246.94,3260] (multiple)

Login to [iface: default, target: iqn.2015-04.com.example:remotedisk1, portal: 165.213.246.94,3260] successful.

 

6. 디바이스 확인

# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

fd0 2:0 1 4K 0 disk

sda 8:0 0 40G 0 disk

├─sda1 8:1 0 500M 0 part /boot

sdd 8:48 0 100M 0 disk

# iscsiadm -m session -P 3

...

Attached scsi disk sdd State: running


 

7. 영구노드 레코드 확인

# cd /var/lib/iscsi/nodes/

#ls -Rl

.:

drw-------. 3 root root 34 4월 29 16:43 iqn.2015-04.com.example:remotedisk1

./iqn.2015-04.com.example:remotedisk1:

drw-------. 2 root root 20 4월 29 16:43 165.213.246.94,3260,1

./iqn.2015-04.com.example:remotedisk1/165.213.246.94,3260,1:

-rw-------. 1 root root 2049 4월 29 16:43 default


8. 매개변수 기본값 확인

# less iqn.2015-04.com.example\:remotedisk1/165.213.246.94\,3260\,1/default

# BEGIN RECORD 6.2.0.873-21

node.name = iqn.2015-04.com.example:remotedisk1

node.tpgt = 1

node.startup = automatic

node.leading_login = No

..........................

 

9. 연결끊기

# iscsiadm -m node -T "iqn.2015-04.com.example:remotedisk1" -p 165.213.246.94:3260 -u

# iscsiadm -m node -T "iqn.2015-04.com.example:remotedisk1" -p 165.213.246.94:3260 -o delete

(영구)


10. 노드 레코드 확인

# cd /var/lib/iscsi/nodes/

#ls -Rl


11. 디바이스 확인

# lsblk