1. 클라이언트 iSCSI 패키지 설치
iSCSI 클라이언트 노드마다 다음 패키지를 설치합니다.
[root@client-node ~]# yum install -y binutils iscsi-initiator-utils xfsprogs
[root@client-node ~]# systemctl restart iscsi
[root@client-node ~]# systemctl enable iscsi
[root@client-node ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:a1b2c3d4e5f6
2. 스토리지 서버에서 iSCSI 서비스 생성
2.1 블록 스토리지 생성
X-Sky 관리 콘솔에서 필요한 용량의 블록 볼륨을 생성합니다.
2.2 이니시에이터 그룹 구성
클라이언트 접근 제어를 위한 이니시에이터 그룹을 설정합니다.
2.3 클라이언트 그룹 생성
다중 경로 접근을 위한 클라이언트 그룹을 생성합니다.
2.4 접근 경로 설정
생성한 볼륨에 대한 접근 경로를 구성합니다.
3. 클라이언트에서 iSCSI 볼륨 마운트
3.1 스토리지 서버 정보 확인
X-Sky 콘솔에서 스토리지 서버의 IP 주소와 IQN 번호를 확인합니다.
3.2 iSCSI 타겟 탐지
[root@client-node ~]# iscsiadm -m discovery --type sendtargets --portal 192.168.100.10
192.168.100.10:3260,1 iqn.2020-06.com.xsky:storage-pool.volume.abc123def456
3.3 타겟 로그인 및 자동 연결 설정
[root@client-node ~]# iscsiadm -m discovery --type sendtargets --portal 192.168.100.10
192.168.100.10:3260,1 iqn.2020-06.com.xsky:storage-pool.volume.abc123def456
[root@client-node ~]# iscsiadm -m discovery --type sendtargets --portal 192.168.100.11
192.168.100.11:3260,1 iqn.2020-06.com.xsky:storage-pool.volume.abc123def456
[root@client-node ~]# iscsiadm -m node -T iqn.2020-06.com.xsky:storage-pool.volume.abc123def456 -p 192.168.100.10:3260 -l
Logging in to [iface: default, target: iqn.2020-06.com.xsky:storage-pool.volume.abc123def456, portal: 192.168.100.10,3260] (multiple)
Login to [iface: default, target: iqn.2020-06.com.xsky:storage-pool.volume.abc123def456, portal: 192.168.100.10,3260] successful.
[root@client-node ~]# iscsiadm -m node -T iqn.2020-06.com.xsky:storage-pool.volume.abc123def456 -p 192.168.100.11:3260 -l
Logging in to [iface: default, target: iqn.2020-06.com.xsky:storage-pool.volume.abc123def456, portal: 192.168.100.11,3260] (multiple)
Login to [iface: default, target: iqn.2020-06.com.xsky:storage-pool.volume.abc123def456, portal: 192.168.100.11,3260] successful.
[root@client-node ~]# iscsiadm -m node -T iqn.2020-06.com.xsky:storage-pool.volume.abc123def456 -p 192.168.100.10:3260 --op update -n node.startup -v automatic
[root@client-node ~]# iscsiadm -m node -T iqn.2020-06.com.xsky:storage-pool.volume.abc123def456 -p 192.168.100.11:3260 --op update -n node.startup -v automatic
[root@client-node ~]# iscsiadm -m session
tcp: [1] 192.168.100.10:3260,1 iqn.2020-06.com.xsky:storage-pool.volume.abc123def456 (non-flash)
tcp: [2] 192.168.100.11:3260,1 iqn.2020-06.com.xsky:storage-pool.volume.abc123def456 (non-flash)
3.4 파티션 생성 및 포맷
연결된 디바이스가 확인되면 fdisk로 파티션을 생성하고 XFS 파일시스템으로 포맷합니다.
[root@client-node ~]# 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 0x8f3a2b1c.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-629145599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-629145599, default 629145599):
Using default value 629145599
Partition 1 of type Linux and of size 300 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@client-node ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=19660736 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=78642944, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=38399, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@client-node ~]# mkdir /mnt/iscsi-volume
[root@client-node ~]# mount /dev/sdb1 /mnt/iscsi-volume
[root@client-node ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 298G 2.4G 296G 1% /
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 8.7M 7.8G 1% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/vda1 283M 115M 150M 44% /boot
tmpfs 1.6G 0 1.6G 0% /run/user/0
/dev/sdb1 300G 33M 300G 1% /mnt/iscsi-volume
3.5 부팅 시 자동 마운트 설정
blkid 명령으로 파티션 UUID를 확인하고 /etc/fstab에 자동 마운트 항목을 추가합니다.
[root@client-node ~]# blkid /dev/sdb1
/dev/sdb1: UUID="b4c5d6e7-f8a9-4b2c-1d3e-4f5a6b7c8d9e" TYPE="xfs"
[root@client-node ~]# vim /etc/fstab
UUID=b4c5d6e7-f8a9-4b2c-1d3e-4f5a6b7c8d9e /mnt/iscsi-volume xfs defaults,_netdev 0 0
[root@client-node ~]# umount /mnt/iscsi-volume
[root@client-node ~]# df -h
[root@client-node ~]# mount -a
[root@client-node ~]# df -h
참고: /etc/fstab에 _netdev 옵션을 반드시 추가해야 합니다. 이 옵션이 없으면 시스템 부팅 시 네트워크 인터페이스가 준비되기 전에 마운트를 시도하여 시스템이 응답하지 않을 수 있습니다.