본문 바로가기

Technical/Devices

OCFS2 & iSCSI shared storage - Opensuse 12.1 & Open iSCSI


iSCSI storage 를 OCFS2 를 이용하여 여러 대의 서버에서 사용하는 공유디스크로 설정하는 방법을 아래에 정리한다.


본 내용의 방법을 응용하여 iSCSI 와 유사한, 다른 Network 방식의 Block storage 를 OCFS2 파일시스템을 적용하여 공유 스토리지로 사용할 수 있으며, Oracle DBMS를 위한 RAC(Real Application Cluster)구성시에도 응용 가능하다(단, CRS, ASM 등의 Clusterware를 적용하는 방법은 약간씩 상이하며 - RAC를 위한 공유메모리, 세마포 등의 Kernel 설정은 제외하고 - 공유 스토리지에 대한 기본 개념은 유사함). 

* 참고로 DRBD(Distributed Replicated Block Device) 를 이용한 양방향(Active-active) OCFS2 설정에 관한 설명은 다음 포스팅에서 다룰 예정이다.


구성을 진행할 목표의 논리적 구성도는 아래와 같다.




1. iSCSI 스토리지 장치의 준비


  Server-side 의 iSCSI target device 는 시중의 NAS 스토리지 장비인 Synology(TM) NAS 장비를 이용하여 설정한다.

  스토리지 장비의 기본적인 설정 방법에 대해서는 따로 설명하지 않으며, 본 설명에서는 iSCSI 스토리지를 아래와 같이

  설정하여 사용한다.


IQN: iqn.2000-01.com.synology:wtnas.bryanstest

ip: 10.10.250.250

port: 3260


  단일 iSCSI 스토리지 장치(대상, target)에 대해 여러 개의 iSCSI 초기자(개시자, initiator)로부터의 접속이 가능하여야

  하므로, 반드시 아래의 그림과 같이 다중 접속이 가능하도록 설정하여야 한다.




2. iSCSI 초기자(개시자, initiator)와 OCFS2 를 통한 공유 스토리지 설정


  iSCSI 초기자를 통하여 OCFS2 디스크를 사용할 2대의 서버를 준비한다. 본 내용에서는 Machine1, Machine2 로 칭하며,

  아래와 같이 2대의 머신에 공통적으로 설치 및 설정 작업을 수행한다.


2.1 iSCSI 스토리지 준비 절차


  2.1.1 Machine 준비


  iSCSI 대상 장비에 network access가 가능한, OpenSUSE 12.x 이 설치된 2대의 머신을 준비한다.


* Machine1

  IP: 10.10.253.253

  hostname: ocfsnode1


* Machine2

  IP: 10.10.253.254

  hostname: ocfsnode2


2대의 머신내에 /etc/hosts 설정에 아래 내용을 추가한다.

10.10.253.253 ocfsnode1

10.10.253.254 ocfsnode2


  2.1.2 iSCSI 장치 연결을 위한 설정


  준비된 2대의 머신에 다음와 같은 과정을 설치 & 설정을 진행한다.


# zypper search iscsi

i | open-iscsi              | Linux* Open-iSCSI Software Initiator                | package   

i | yast2-iscsi-client      | YaST2 - iSCSI Client Configuration                  | package

만약 open-iscsi 패키지가 설치되어 있지 않다면 zypper install 명령으로 설치를 진행한다(yast2-iscsi-client 는 본 설명에서 사용하지 않으므로 설치하지 않아도 무방함)


# chkconfig --add iscsid

# chkconfig iscsid on

# vi /etc/iscsid.conf

...

node.startup = automatic

...

node.startup 부분을 찾아서 설정값을 automatic 으로 수정한다.


# service iscsid start

# ps -eaf | grep iscsid

root     19748     1  0 10:51 ?        00:00:00 /sbin/iscsid -c /etc/iscsi/iscsid.conf -n

root     19749     1  0 10:51 ?        00:00:00 /sbin/iscsid -c /etc/iscsi/iscsid.conf -n


# service iscsid status

redirecting to systemctl

iscsid.service - LSB: iSCSI initiator daemon

 Loaded: loaded (/etc/init.d/iscsid)

 Active: active (running) since Mon, 08 Apr 2013 10:51:32 +0900; 38s ago

Process: 900 ExecStop=/etc/init.d/iscsid stop (code=exited, status=0/SUCCESS)

Process: 32368 ExecReload=/etc/init.d/iscsid reload (code=killed, signal=TERM)

Process: 19728 ExecStart=/etc/init.d/iscsid start (code=exited, status=0/SUCCESS)

 CGroup: name=systemd:/system/iscsid.service

 ├ 19748 /sbin/iscsid -c /etc/iscsi/iscsid.conf -n

 └ 19749 /sbin/iscsid -c /etc/iscsi/iscsid.conf -n


# iscsiadm -m discovery -t sendtargets -p 10.10.250.250

10.10.250.250:3260 via sendtargets

iSCSI discovery 기능을 이용하여 network 내의 접속 가능한 대상장비(target device)를 찾는다


# iscsiadm -m node -l -p 10.10.250.250:3260

Logging in to [iface: default, target: iqn.2000-01.com.synology:wtnas.bryanstest, portal: 10.10.250.250, 3260]

Login to .... : successful

대상 장치에 접속을 시도한다.


# iscsiadm -m session

tcp: [1] 10.10.250.250:3260,0 iqn.2000-01.com.synology:wtnas.bryanstest

접속된 세션 정보를 확인한다.


* 대상 장치와의 접속을 끊으려면 다음과 같이 수행한다

# iscsiadm -m node -u -p 10.10.250.250:3260

또는 port 번호를 생략하려면 다음과 같이 수행한다

# iscsiadm -m node -u 10.10.250.250


* discovery 된 target 정보를 삭제하려면 다음과 같이 수행한다

# iscsiadm -m node -o delete 10.10.250.250



  2.1.3 대상 디스크의 파티션 설정


2대의 Machine중 하나에서 다음과 같이 디스크 파티션 수행

# fdisk /dev/sdc

=> 파티션 추가(n, primary), 설정 저장(w)


# fdisk -l

Disk /dev/sdc: 10.7 GB, 10737418240 bytes

64 heads, 32 sectors/track, 10240 cylinders, total 20971520 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x9be02ef9


   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1            2048    20971519    10484736   83  Linux

설정된 파티션 정보를 확인한다. 대상 장치의 정확한 인식 여부의 확인을 위하여 Disk identifier 부분에 주의한다.


2.2 OCFS2 설치 및 Cluster 설정


  iSCSI storage를 연결한 2대(또는 여러 대)의 머신을, OCFS2 cluster 에 참여시켜, 공유된 디스크(Shared storage) 로

 사용하기 위한 Cluster 설정 과정이다.


  2.2.1 Machine 1 설정


Machine 1# zypper in -y ocfs2-tools ocfs2-tools-o2cb ocfs2console

OCFS2를 구동할 패키지를 설치한다. ocfs2console 은 설치하지 않아도 무방하다(본 설명에서는 사용하지 않음)


Machine 1# mkdir /etc/ocfs2

Machine 1# vi /etc/ocfs2/cluster.conf

cluster:

    node_count = 2

    name = ocfscluster1

node:

    ip_port = 7777

    ip_address = 10.10.253.253

    number = 1

    name = ocfsnode1

    cluster = ocfscluster1

node:

    ip_port = 7777

    ip_address = 10.10.253.254

    number = 2

    name = ocfsnode2

    cluster = ocfscluster1

OCFS2 용 cluster 설정 파일을 작성한다.


Machine 1# chkconfig --add o2cb

Machine 1# chkconfig --add ocfs2

부팅시 실행되도록 자동 시작 스크립트를 설정한다.


Machine 1# service o2cb configure

Configuring the O2CB driver


This will configure the on-boot properties of the O2CB driver.

The following questions will determine whether the driver is loaded on

boot. The current values will be shown in brackets ('[]'). Hitting

<ENTER> without typing an answer will keep that current values. Ctrl-C

will abort.


Load O2CB driver on boot (y/n) [n]: y

Cluster stack backing O2CB [o2cb]: 

Cluster to start on boot (Enter "none" to clean) []: ocfscluster1

Specify heartbeat dead threshold (>=7) [31]:

Specify network idle timeout in ms (>=5000) [30000]: 

Specify network keepalive delay in ms (>=1000) [2000]:

Specify network reconnect delay in ms (>=2000) [2000]:

Writing O2CB configuration: OK

Mounting configfs filesystem at /sys/kernel/config: OK

Loading stack plugin "o2cb": OK

Loading filesystem "ocfs2_dlmfs": OK

Creating directory '/dlm': OK

Mounting ocfs2_dlmfs filesystem at /dlm: OK

Setting cluster stack "o2cb": OK

Starting O2CB cluster ocfscluster1: OK


[주의]

mount: configfs already mounted or /sys/kernel/config busy 와 같은 오류 발생시

mount 명령으로 configfs on /sys/kernel/config type configfs (rw, relatime) 라인을 찾아서, 있으면

# service o2cb unload

# umount /sys/kernel/config 로 un-mount 한 후에 service o2cb configure 재 실행


Machine 1# service o2cb status

o2cb service

Loaded: error (Reason: No such file or directory)

Active: inactive (dead)

설정 결과의 확인. 서비스는 정상적으로 Loading 되었으며, ocfs2 디스크를 포맷하기 전까지는 위와 같이 inactive 로 보이는 것이 정상임


Machine 1# mkfs.ocfs2 -b 4K -C 32K -N 2 -L "OCFS2Filesystem" /dev/sdc1

Machine 1# mkdir /mnt/ocfs2

Machine 1# mount -t ocfs2 -o nointr /dev/sdc1 /mnt/ocfs2

대상 디스크를 OCFS2 포맷으로 초기화한다. -N 옵션의 숫자 값은 다중 접속수를 의미하며, 확장시에는 tunefs.ocfs2 로 변경 가능하다. 초기화 후에 정상적으로 사용이 가능한지 mount 를 수행하여 확인한다.


Machine 1# sync

Machine 1# reboot

디스크에 대한 기본 설정이 완료 되었으면 시스템을 재시작하여 전체 설정 결과를 확인한다.


  2.2.2 Machine 2 설정


Machine 2# zypper in -y ocfs2-tools ocfs2-tools-o2cb ocfs2console

OCFS2를 구동할 패키지를 설치한다. ocfs2console 은 설치하지 않아도 무방하다(본 설명에서는 사용하지 않음)


Machine 2# mkdir /etc/ocfs2

Machine 2# scp root@10.10.253.253:/etc/ocfs2/cluster.conf /etc/ocfs2

Machine1의 OCFS2 용 cluster 설정 파일을 복사한다.


Machine 2# chkconfig --add o2cb

Machine 2# chkconfig --add ocfs2

부팅시 실행되도록 자동 시작 스크립트를 설정한다.


Machine 2# service o2cb configure

Configuring the O2CB driver


This will configure the on-boot properties of the O2CB driver.

The following questions will determine whether the driver is loaded on

boot. The current values will be shown in brackets ('[]'). Hitting

<ENTER> without typing an answer will keep that current values. Ctrl-C

will abort.


Load O2CB driver on boot (y/n) [n]: y

Cluster stack backing O2CB [o2cb]: 

Cluster to start on boot (Enter "none" to clean) []: ocfscluster1

Specify heartbeat dead threshold (>=7) [31]:

Specify network idle timeout in ms (>=5000) [30000]: 

Specify network keepalive delay in ms (>=1000) [2000]:

Specify network reconnect delay in ms (>=2000) [2000]:

Writing O2CB configuration: OK

Mounting configfs filesystem at /sys/kernel/config: OK

Loading stack plugin "o2cb": OK

Loading filesystem "ocfs2_dlmfs": OK

Creating directory '/dlm': OK

Mounting ocfs2_dlmfs filesystem at /dlm: OK

Setting cluster stack "o2cb": OK

Starting O2CB cluster ocfscluster1: OK


[주의]

mount: configfs already mounted or /sys/kernel/config busy 와 같은 오류 발생시

mount 명령으로 configfs on /sys/kernel/config type configfs (rw, relatime) 라인을 찾아서, 있으면

# service o2cb unload

# umount /sys/kernel/config 로 un-mount 한 후에 service o2cb configure 재 실행


Machine 2# service o2cb status

o2cb service

Loaded: error (Reason: No such file or directory)

Active: inactive (dead)

설정 결과의 확인. 서비스는 정상적으로 Loading 되었으며, ocfs2 디스크를 포맷하기 전까지는 위와 같이 inactive 로 보이는 것이 정상임


Machine 2# mkdir /mnt/ocfs2

Machine 2# mount -t ocfs2 -o nointr /dev/sdc1 /mnt/ocfs2

정상적으로 디스크의 접속, 사용이 가능한지 mount 를 수행하여 확인한다.


Machine 2# sync

Machine 2# reboot

디스크에 대한 기본 설정이 완료 되었으면 시스템을 재시작하여 전체 설정 결과를 확인한다.



2.3 OCFS2 cluster 설정 로드 및 자동 마운트 설정 & 확인


  2.3.1 정상 Mount 확인 및 자동 마운트 설정


2대의 머신 모두에 대해 2.2의 모든 과정을 거치고 Reboot 후, 다음과 같은 방법으로 마운트 확인 및 설정 수행


# mount -t ocfs2 /dev/sdc1 /mnt/ocfs2

# vi /etc/fstab

/dev/sdc1 /mnt/ocfs2 ocfs2 _netdev,nointr 0 0

자동 마운트를 위해 설정 라인 추가


Machine 1# sync

Machine 1# reboot

Machine 2# sync

Machine 2# reboot

부팅 후 자동 마운트까지의 전체 과정을 최종 확인하기 위하여 2대의 머신 모두 reboot 를 수행한다.


  2.3.2  설정 결과 최종 확인


  * Machine 1 확인


Machine 1# service o2cb status

o2cb.service - LSB: Load O2CB cluster services at system boot.

Loaded: loaded (/etc/init.d/o2cb)

Active: active (exited) since Mon, 08 Apr 2013 13:07:51 +0900; 3h 1min ago

Process: 1912 ExecStart=/etc/init.d/o2cb start (code=exited, status=0/SUCCESS)

CGroup: name=systemd: /system/o2cb.service


Booting 후, dmesg 로 정상 로딩 과정, 결과 확인

[xx.xxxxx] br0: port 1(eth0) entering forwarding state

[xx.xxxxx] Loading iSCSI transport class v2.0-870

[xx.xxxxx] OCFS2 Node Manager 1.5.0

[xx.xxxxx] OCFS2 DLM 1.5.0

[xx.xxxxx] ocfs2: Registered cluster interface o2cb

[xx.xxxxx] iscsi: registered transport (iser)

[xx.xxxxx] OCFS2 CLMFS 1.5.0

[xx.xxxxx] OCFS2 User CLM kernel interface loaded

[xx.xxxxx] scsiX : iSCSI Initiator over TCP/IP

[xx.xxxxx] scsi X:0:0:0: Direct-Access SYNOLOGY iSCSI Storage 3.1 PQ: 0 ANSI: 5

[xx.xxxxx] sd X:0:0:0: Attached scsi generic sg3 type 0

[xx.xxxxx] sd X:0:0:0: [sdc] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)

...

[xx.xxxxx] sdc: sdc1

[xx.xxxxx] sd X:0:0:0: [sdc] Attached SCSI disk

[xx.xxxxx] o2net: accepted connection from node ocfsnode2 (num 2) at 10.10.253.254:7777

[xx.xxxxx] OCFS2 1.5.0

[xx.xxxxx] o2dlm: Nodes in domain 0D44652863FD42B4896FF57249AEE740: 1 2

[xx.xxxxx] ocfs2: Mounting device (8,33) on (node 1, slot 1) with ordered data mode.

...


대상 디스크에 IO 발생 및 결과 확인

Machine 1# echo xxxxxxxxxxxx >> /mnt/ocfs2/test.txt


  * Machine 2 확인


위의 Machine 1 확인 과정과 동일하게 수행후 Disk IO 발생 및 결과 확인

Machine 2# echo yyyyyyyyyyyy >> /mnt/ocfs2/test.txt


Machine 2# cat /mnt/ocfs2/test.txt

xxxxxxxxxxxx

yyyyyyyyyyyy