[RHEL7] iSCSI 사용방법
- iSCSI 를 이용한 원격 블록 스토리지 사용방법
(1) 서버설정 1. targetcli 설치 serverX# yum -y install targetcli - /dev/sde (디스크파티션 생성) /iscsi> cd iqn.2015-04.com.example:remotedisk1/ 7. file1, block1,2 에대한 LUN생성 # yum -y install iscsi-initiator-utils 3. iscsi 서비스 활성화 및 시작 # systemctl enable iscsi 4. 포털검색 5. 포털 로그인 6. 디바이스 확인 # lsblk # iscsiadm -m session -P 3 Attached scsi disk sdd State: running 7. 영구노드 레코드 확인 # cd /var/lib/iscsi/nodes/ #ls -Rl ./iqn.2015-04.com.example:remotedisk1: ./iqn.2015-04.com.example:remotedisk1/165.213.246.94,3260,1: 9. 연결끊기 10. 노드 레코드 확인 #ls -Rl
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
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/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.
/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 설치
2. 클라이언트의 이니시에이터 네임설정
#vi /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2015-04.com.example:desktopX
# systemctl start iscsi
# iscsiadm -m iscsiadm -m discovery -t sendtargets -p 165.213.246.94
165.213.246.94:3260,1 iqn.2015-04.com.example:remotedisk1
# 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.
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
...
.:
drw-------. 3 root root 34 4월 29 16:43 iqn.2015-04.com.example:remotedisk1
drw-------. 2 root root 20 4월 29 16:43 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
..........................
# 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
(영구)
# cd /var/lib/iscsi/nodes/
11. 디바이스 확인
# lsblk
'IT > LINUX' 카테고리의 다른 글
[LINUX][RHEL7] NTP설정(chronyd 사용) (0) | 2016.12.16 |
---|---|
[LINUX][RHEL7] LVM 사용하기 (0) | 2016.12.16 |
[LINUX][RHEL6] LINK UP된 NIC 찾기 (0) | 2016.12.14 |
[LINUX][RHEL6] AutoFS를 활용하여 ISO마운트 후 yum Repository로 활용하기 (0) | 2014.08.19 |
[LINUX][RHEL6] yum repository 구성 (0) | 2014.08.19 |
댓글