ISCSI 다중 경로 설정

ISCSI 스토리지 시스템 구축

(1). ISCSI 다중 경로를 이용한 디스크 마운트 고가용성 구현

단일 경로만 존재할 경우, 하나의 경로에 문제가 생기면 전체 시스템이 사용 불가능해집니다. 이를 해결하기 위해 다중 경로를 설정하여 단일 포인트 오류를 방지합니다.

  1. 실험 환경

서버: 서버1 (192.168.5.101, 1.1.5.129)

클라이언트: 클라이언트1 (192.168.5.102, 1.1.5.130)

  1. Target 서버 설정
[root@서버1 ~]# yum -y install targetcli
[root@서버1 ~]# targetcli  // 대화형 설정으로 진입
/> /backstores/block 생성 test_disk /dev/sdb  // /dev/sdb를 사용하여 사용자 정의 저장 객체 test_disk 생성
/> /iscsi 생성 iqn.2021-01.com.server1:storage  // ISCSI 타겟 생성
/> /iscsi/iqn.2021-01.com.server1:storage/tpg1/acls 생성 iqn.2021-01.com.server1:user  // ACL 규칙 목록 이름 생성
/> /iscsi/iqn.2021-01.com.server1:storage/tpg1/luns 생성 /backstores/block/test_disk  // LUN0로 지정된 저장 객체를 타겟의 논리 유닛으로 지정
/> /iscsi/iqn.2021-01.com.server1:storage/tpg1/portals/ 삭제 0.0.0.0 3260  // 기존 리스닝 IP 및 포트 삭제
/> /iscsi/iqn.2021-01.com.server1:storage/tpg1/portals/ 생성 192.168.5.101 3260  // 새로운 리스닝 IP 및 포트 지정
/> saveconfig  // 설정 저장
[root@서버1 ~]# systemctl start target && systemctl enable target  // 서비스 시작 및 부팅 시 자동 실행 설정
[root@서버1 ~]# firewall-cmd --permanent --zone=public --add-port=3260/tcp  // 방화벽에 포트 추가
[root@서버1 ~]# firewall-cmd --reload
  1. 클라이언트 설정
[root@클라이언트1 ~]# yum -y install iscsi-initiator-utils  // 클라이언트 설치
[root@클라이언트1 ~]# vim /etc/iscsi/initiatorname.iscsi  // ACL 규칙 목록 이름 설정
InitiatorName=iqn.2021-01.com.server1:user
[root@클라이언트1 ~]# systemctl start iscsid && systemctl enable iscsid  // 서비스 시작 및 부팅 시 자동 실행 설정
[root@클라이언트1 ~]# iscsiadm -m discovery -t st -p 192.168.5.101  // ISCSI 장치 검색
[root@클라이언트1 ~]# iscsiadm -m node --login  // ISCSI 장치 로그인
[root@클라이언트1 ~]# mkfs.xfs /dev/sdb -f  // 포맷
[root@클라이언트1 ~]# mkdir /mnt/share  // 마운트 디렉토리 생성
[root@클라이언트1 ~]# mount /dev/sdb /mnt/share/  // 마운트
  1. 연결 구조 확인
[root@클라이언트1 ~]# tree /var/lib/iscsi/
/var/lib/iscsi/
├── ifaces
├── isns
├── nodes
│   └── iqn.2021-01.com.server1:storage
│       ├── 1.1.5.129,3260,1
│       │   └── 기본
│       └── 192.168.5.101,3260,1
│           └── 기본
├── send_targets
│   └── 192.168.5.101,3260
│       ├── iqn.2021-01.com.server1:storage,1.1.5.129,3260,1,기본 -> /var/lib/iscsi/nodes/iqn.2021-01.com.server1:storage/1.1.5.129,3260,1
│       ├── iqn.2021-01.com.server1:storage,192.168.5.101,3260,1,기본 -> /var/lib/iscsi/nodes/iqn.2021-01.com.server1:storage/192.168.5.101,3260,1
│       └── st_config
├── slp
└── static

12 directories, 3 files

(2). 클라이언트에서 다중 경로 장치 설정

다중 경로 소프트웨어 Device Mapper Multipath (DM-Multipath)를 통해 동일한 장치의 여러 경로를 통합하여 단일 장치 형태로 제공합니다.

  1. DM-Multipath 특징

데이터 중복성을 제공하며, active/passive 모드에서는 장애 발생 시 다른 경로로 전환됩니다. 또한, active/active 모드에서는 모든 경로에 대해 라운드 로빈 방식으로 I/O 작업을 분산시켜 성능을 향상시킵니다.

  1. 클라이언트에서 DM-Multipath 설치 및 설정
[root@클라이언트1 ~]# yum -y install device-mapper-multipath
[root@클라이언트1 ~]# cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc/
[root@클라이언트1 ~]# systemctl start multipathd.service
[root@클라이언트1 ~]# umount /mnt/share  // 마운트 해제
[root@클라이언트1 ~]# systemctl restart iscsid
[root@클라이언트1 ~]# systemctl restart multipathd.service
[root@클라이언트1 ~]# multipath -ll  // 다중 경로 정보 확인
mpatha (36001405179b62d3082e4604ae5326cd6) dm-2 LIO-ORG ,test_disk           
|-+- policy='service-time 0' prio=1 status=active
| `- 33:0:0:0 sdb 8:16 active ready running
`-+- policy='service-time 0' prio=1 status=enabled
  `- 34:0:0:0 sdc 8:32 active ready running
[root@클라이언트1 ~]# ll /dev/mapper/mpatha  // 생성된 장치 파일 확인
  1. 고가용성 및 부하 균형 모드 설정
[root@클라이언트1 ~]# vim /etc/multipath.conf
multipaths {
        multipath {
                wwid                    36001405179b62d3082e4604ae5326cd6  // WWID 지정
                alias                   WebStorage  // 별칭 지정
                path_grouping_policy    multibus  // 경로 그룹 정책
                path_selector           "round-robin 0"  // 라운드 로빈 선택
                failback                manual
                rr_weight               priorities
                no_path_retry           5
        }       
}
[root@클라이언트1 ~]# systemctl restart multipathd.service
[root@클라이언트1 ~]# systemctl restart iscsid
[root@클라이언트1 ~]# multipath -ll  // 다시 확인
WebStorage (36001405179b62d3082e4604ae5326cd6) dm-2 LIO-ORG ,test_disk           
`-+- policy='round-robin 0' prio=1 status=active
  |- 33:0:0:0 sdb 8:16 active ready running
  `- 34:0:0:0 sdc 8:32 active ready running
[root@클라이언트1 ~]# ll /dev/mapper/WebStorage  // 별칭 확인
[root@클라이언트1 ~]# mount /dev/mapper/WebStorage /mnt/share  // 마운트 가능 여부 확인

(3). Udev 규칙을 이용한 각 타겟에 대한 고정된 이름의 심볼릭 링크 생성

udev는 Linux 커널 2.6 시리즈의 장치 관리자입니다. 주요 기능은 /dev 디렉토리 하위의 장치 노드를 관리하는 것입니다.

Udev 규칙 예:

[root@클라이언트1 ~]# vim /etc/udev/rules.d/10-mydisk.rules
KERNEL=="sdb", SUBSYSTEM=="block", PROGRAM="/usr/lib/udev/scsi_id -g -u /dev/sdb", RESULT=="36001405179b62d3082e4604ae5326cd6", SYMLINK+="my-disk", MODE="0660"

이 규칙은 /dev/my-disk라는 심볼릭 링크를 생성하고, 권한을 설정합니다.

태그: iSCSI Multipath DeviceMapper Udev linux

6월 4일 23:51에 게시됨