UNIX/Redhat

12/08/28 3장 iSCSI 저장소에 액세스

99iberty 2012. 8. 28. 10:16


원격에 있는 쪽에 쓰고 싶다 라고 하는거고

대상은 타겟

클라이언트가 연결하고자 하는 원격에 있는 하드디스크다.

대상 포털 : 원격 스토리지(하드디스크)를 제공하는 서버.

IQN : 각각의 대상 식별할 수 있는 이름. 대표적인 게 url. 따로 명명 규칙을 가지고 있다.


[root@server4 ~]# iscsiadm -m discovery -t st -p 192.168.0.254
해당 서버에서 제공하는 iscsi 디스크가 무엇이 이ㅆ는지 확인

이렇게 식별이 돼ㅆ으면

아이스카시 모드 타겟


[root@server4 ~]# iscsiadm -m node -T iqn.2010-09.com.example:rdisks.server4 -p 192.168.0.254 -l
Logging in to [iface: default, target: iqn.2010-09.com.example:rdisks.server4, portal: 192.168.0.254,3260]
Login to [iface: default, target: iqn.2010-09.com.example:rdisks.server4, portal: 192.168.0.254,3260] successful.

[root@server4 ~]# ls -l /dev/disk/by-path/*iscsi*
lrwxrwxrwx. 1 root root 9 Aug 28 10:06 /dev/disk/by-path/ip-192.168.0.254:3260-iscsi-iqn.2010-09.com.example:rdisks.server4-lun-1 -> ../../sda



#fdisk /dev/sda 한다

[root@server4 ~]# fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x21427da5.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1024, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1024, default 1024):
Using default value 1024

Command (m for help): p

Disk /dev/sda: 33 MB, 33554432 bytes
2 heads, 32 sectors/track, 1024 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x21427da5

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        1024       32752   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.




[root@server4 ~]# mkfs -t ext4 /dev/sda1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
8192 inodes, 32752 blocks
1637 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33554432
4 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
    8193, 24577

Writing inode tables: done                            
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@server4 ~]# blkid /dev/sda1
/dev/sda1: UUID="d7778dde-d8b1-409c-96aa-7e0e5f5d3d43" TYPE="ext4"


[root@server4 ~]# vim /etc/fstab
[root@server4 ~]# mount -a
mount: mount point /mnt/iscsi does not exist
[root@server4 ~]# mkdir /mnt/iscsi
[root@server4 mnt]# mount -a
[root@server4 mnt]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vgsrv-root
                      3.3G  2.2G  978M  70% /
tmpfs                 246M  284K  246M   1% /dev/shm
/dev/vda1             248M   30M  206M  13% /boot
/dev/mapper/vgsrv-home
                      248M   11M  226M   5% /home
/dev/sda1              31M  1.4M   28M   5% /mnt/iscsi



iscsi fstab에 등록할 경우  defaults 가 아니라 _netdev 로 해야한다.

defaults로 해 놓으면 부팅될 때부터 찾기 때문에 (네트워크 올라오기 전에) 넘어가게 해야하기 때문에.


#
# /etc/fstab
# Created by anaconda on Sat Aug 25 13:26:47 2012
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vgsrv-root  /                       ext4    defaults        1 1
UUID=2c206f54-3f61-40b7-96b3-86bef62c2ea7 /boot                   ext4    defaults        1 2
/dev/mapper/vgsrv-home  /home                   ext4    defaults        1 2
/dev/mapper/vgsrv-swap  swap                    swap    defaults        0 0
UUID="d7778dde-d8b1-409c-96aa-7e0e5f5d3d43"     /mnt/iscsi      ext4    _netdev 1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0


* iscsi 사용 중단하기

[root@server4 mnt]# umount /mnt/iscsi
[root@server4 mnt]# vim /etc/fstab


// iSCSI 대상에서 로그아웃하여 일시적으로 연결 해제
[root@server4 mnt]# iscsiadm -m node -T iqn.2010-09.com.example:rdisks.server4 -p 192.168.0.254 -u
Logging out of session [sid: 1, target: iqn.2010-09.com.example:rdisks.server4, portal: 192.168.0.254,3260]
Logout of [sid: 1, target: iqn.2010-09.com.example:rdisks.server4, portal: 192.168.0.254,3260] successful.


// 아이스카시 대상의 로컬 레코드를 삭제하여 영구적으로 연결 해제

[root@server4 mnt]# iscsiadm -m node -T iqn.2010-09.com.example:rdisks.server4 -p 192.168.0.254 -o delete




'UNIX > Redhat' 카테고리의 다른 글

12/08/28 5장 계정 관리  (0) 2012.08.28
12/08/28 4장 논리 볼륨 관리  (0) 2012.08.28
12/08/27 3장 저장 장치 관리  (0) 2012.08.27
12/08/27 2장 네트워크 관리  (0) 2012.08.27
12/08/27 1  (0) 2012.08.27