FlexCloud Linux Server 원격접속및볼륨확장매뉴얼 Date: 2011.01.24 Hostway IDC Corporation 1
목차 1. Linux VM 원격접속... 3 가 ) WEB Console 사용... 3 나 ) SSH 접속프로그램사용... 3 2. Linux VM 볼륨확장... 5 가 ) Disk 확장방법 1 ( 새로운파티션에마운트 )... 5 나 ) Disk 확장방법 2 ( / 파티션용량확장 )... 9 다 ) VM 사용중볼륨추가... 14 2
1. Linux VM 원격접속 가 ) WEB Console 사용 A. http://manage.hostwaycloud.co.kr/ 로그인 B. [ 서버현황 ( 서버사용현황 )] 에서생성한 VM 을클릭 C. [ 요약 ] 탭의 [ 콘솔 ] 을클릭 D. VM 생성초기패스워드는임의생성되며, [ 서버관리 ] 탭에서 [ 초기비밀번호받기 ] 를클릭하면 패스워드확인가능 E. VM 의공인 DNS 및 IP 정보확인 - [ 서버현황 ( 서버사용현황 )] -> [ 요약 ] 탭의최하단에서확인가능 - 공인 DNS 를통한접속가능, 공인 IP 는공인 DNS 중숫자부분에해당함, 64.23.65.31 나 ) SSH 접속프로그램사용 A. http://manage.hostwaycloud.co.kr/ 로그인 B. [ 서버현황 ( 서버사용현황 )] 에서생성한 VM 을클릭 C. VM 의공인 DNS 및 IP 정보확인 - [ 서버현황 ( 서버사용현황 )] -> [ 요약 ] 탭의최하단에서확인가능 - 공인 DNS 를통한접속가능, 공인 IP 는공인 DNS 중숫자부분에해당함, 64.23.65.31 D. SSH 접속프로그램을이용하여접속 (Putty, SecureCRT 등 ) E. SSH 프로그램호스트이름부분에확인된공인 DNS 정보를입력하여접속 - 접속예 (Putty 프로그램사용 ) 3
F. VM 생성초기패스워드는임의생성되며, [ 서버관리 ] 탭에서 [ 초기비밀번호받기 ] 를클릭하면 패스워드확인가능 4
2. Linux VM 볼륨확장 FlexCloud Servers 에서서버생성시클라우드의특성상 Disk 를 60GB 이상설정하면초기에는 60GB 만확인됩니다. 아래매뉴얼은 60GB 이상디스크를설정한경우 60GB 외의나머지용량을모두사용할수있도록하는방법에대한매뉴얼입니다. 아래작업은처음 VM 생성후바로작업하시는것을추천하며, 서비스중용량을늘리고자하는경우에는하단의 다 ) VM 사용중볼륨추가 매뉴얼을참고하시어 FlexCloud 콘솔의볼륨추가기능을이용해용량을늘리시기바랍니다. Linux 명령어사용법을잘모르실경우 man 명령어를통해기본사용법을보실수있습니다. 예 ) man df 가 ) Disk 확장방법 1 ( 새로운파티션에마운트 ) VM 생성초기에남아있는용량에대해 Volume Group 의공간을확장하여새로운파티션에 마운트시키는방법입니다. 현재 /dev/hda1( / 파티션 ) 이 40G 로되어있는데여유용량 20G 를 /data 파티션에마운트하는 방법 A. fdisk 를이용하여파티션을확인후나머지공간을나누고 ID 를 8e (Linux LVM) 으로설정 예 ) 디스크 (/dev/hda) 의나머지공간을 LVM 으로파티션하는과정 [root@localhost ~]# fdisk -l Disk /dev/hda: 64.4 GB, 64424509440 bytes [root@localhost ~]# fdisk /dev/hda The number of cylinders for this disk is set to 7832. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) 5
Command (m for help): p Disk /dev/hda: 64.4 GB, 64424509440 bytes Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (5222-7832, default 5222): Using default value 5222 Last cylinder or +size or +sizem or +sizek (5222-7832, default 7832): Using default value 7832 Command (m for help): p Disk /dev/hda: 64.4 GB, 64424509440 bytes /dev/hda3 5222 7832 20972857+ 83 Linux Command (m for help): t <- 파티션타입 Partition number (1-4): 3 <- 파티션선택 Hex code (type L to list codes): 8e <- 8e 선택 (LVM) Changed system type of partition 3 to 8e (Linux LVM) Command (m for help): p Disk /dev/hda: 64.4 GB, 64424509440 bytes 6
/dev/hda3 5222 7832 20972857+ 8e Linux LVM Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. [root@localhost ~]# reboot 리부팅후파티션확인 [root@localhost ~]# fdisk -l Disk /dev/hda: 64.4 GB, 64424509440 bytes /dev/hda3 5222 7832 20972857+ 8e Linux LVM B. pvcreate 명령을이용 Physical Volume 을생성 [root@localhost ~]# pvcreate /dev/hda3 C. Physical Volume 을 data 라는이름의 Volume Group 으로 vgcreate 명령을이용하여생성 [root@localhost ~]# vgcreate VolGroup00 /dev/hda3 D. vgdisplay 명령으로 Volume Group 정보확인가능. [root@localhost ~]# vgdisplay F. lvcreate 명령을이용하여 test 라는 ( 임의생성 ) 이름의 Logical Volume 을생성 (lvcreate 명령은 Volume Group 이름 (data) 을 -L, -n 옵션과함께주어실행하는데, -L 옵션뒤에는 Logical Volume 의크기를 -n 옵션뒤에는 Logical Volume 의이름이주어집니다. [root@localhost ~]# lvcreate -L 20G -n test VolGroup00 G. 마운트대상디렉토리 (/data) 생성후파일시스템에서액세스가능하도록 Logical Volume 을포맷하고마운트 [root@localhost ~]# mkfs.ext3 /dev/volgroup00/test [root@localhost ~]# mkdir /data [root@localhost ~]# mount -t ext3 /dev/volgroup00/test /data/ 7
[root@localhost ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/volgroup00-logvol00 38471112 3066536 33418836 9% / /dev/hda1 101086 31551 64316 33% /boot tmpfs 257652 0 257652 0% /dev/shm /dev/mapper/volgroup00-test 20642428 176200 19417652 1% /data H. 부팅시자동으로마운트되도록 /etc/fstab 에등록 /dev/volgroup00/logvol00 / ext3 defaults 1 1 /dev/volgroup00/test /data ext3 defaults 1 1 LABEL=/boot /boot ext3 defaults 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 /dev/volgroup00/logvol01 swap swap defaults 0 0 8
나 ) Disk 확장방법 2 ( / 파티션용량확장 ) VM 생성초기에남아있는용량에대해 Volume Group 을이용해 / 파티션용량을확장하는방법입니다. 이방법은작업시 / 파티션에대하여 umount 를하지않고작업해야하는문제 ( 위험부담 ) 가있으며작업도중파티션에손상이있을경우 VM 을새로생성해야합니다. VM 생성초기에꼭필요한경우에만작업하시기바라며, 이미서비스중인 VM 에서이방법을사용해용량을늘리는것은권장하지않습니다. 이미서비스중인 VM 의용량을늘리고자하는경우에는하단의 다 ) VM 사용중볼륨추가 매뉴얼을참고하시어 FlexCloud 콘솔의볼륨추가기능을이용해용량을늘리시기바랍니다. 현재 /dev/hda1( / 파티션 ) 이 40G 로되어있는데여유용량 20G 를추가하여 / 파티션을총 60G 로늘리는방법예시 ( 현재파티션용량확인 ) [root@localhost ~]# df ( 현재하드디스크의사용량과남은용량을표시해주는명령어 ) Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/volgroup00-logvol00 38471112 3057880 33427492 9% / ( / 파티션용량확인 ) /dev/hda1 101086 31551 64316 33% /boot ( 현재디스크파티션리스트확인 ) [root@localhost ~]# fdisk -l Disk /dev/hda: 64.4 GB, 64424509440 bytes ( 현재디스크파티션용량 64.4 GB) fdisk /dev/had 명령으로남은파티션을 /dev/hda3 로추가생성후타입을 8e (LVM) 으로변경후 저장합니다. ( 아래순서예제참조 ) A. fdisk 명령으로디스크파티션작업 [root@localhost ~]# fdisk /dev/had B. p 명령현재상태확인 ( 현재디스크에는 /dev/hda1, /dev/hda2 의두개파티션이존재함 ) Command (m for help): p ( 파티션현황보기 ) Disk /dev/hda: 64.4 GB, 64424509440 bytes 9
C. 나머지용량에새파티션할당작업 (n) Command (m for help): n => 신규파티션추가 Command action e extended p primary partition (1-4) p => primary 파티션을만들기 Partition number (1-4): 3 => 3 번째파티션으로추가 First cylinder (5222-7832, default 5222): ( 엔터 / 두번째파티션이후부터사용 ) Using default value 5222 Last cylinder or +size or +sizem or +sizek (5222-7832, default 7832): ( 엔터 / 나머지를모두사용 ) Using default value 7832 Command (m for help): p ( 파티션현황보기 ) Disk /dev/hda: 64.4 GB, 64424509440 bytes /dev/hda3 5222 7832 20972857+ 83 Linux ( 추가파티션확인 ) Command (m for help): t ( 파티션타입을변경 ) Partition number (1-4): 3 (3 번째파티션을선택 ) Hex code (type L to list codes): 8e ( 파티션타입을 8e(LVM) 으로변경 ) Changed system type of partition 3 to 8e (Linux LVM) Command (m for help): p ( 파티션현황보기 ) Disk /dev/hda: 64.4 GB, 64424509440 bytes /dev/hda3 5222 7832 20972857+ 8e Linux LVM ( 변경내용확인 ) 10
Command (m for help): w ( 위에서작업한내용을저장합니다 ) The partition table has been altered! Calling ioctl() to re-read partition table. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. D. reboot 명령으로서버를리부팅합니다. [root@localhost ~]# reboot E. 새로생성한 /dev/hda3 파티션을 ext3 파일시스템으로포맷합니다. (mkfs.ext3 : linux 파일시스템을 ext3 타입으로포맷하는명령 ) [root@manage ~]# mkfs.ext3 /dev/hda3 Filesystem label= OS type: Linux Block size=4096 (log=2) : : This filesystem will be automatically checked every 32 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. 서버리부팅이완료된후아래와같이볼륨추가작업을진행합니다. A. pvscan 현재상태확인 [root@localhost ~]# pvscan (pvscan 는 Physical Volume 을확인하는명령 ) PV /dev/hda2 VG VolGroup00 lvm2 [39.88 GB / 0 free] Total: 1 [39.88 GB] / in use: 1 [39.88 GB] / in no VG: 0 [0 ] B. pvcreate : Physical Volume 을생성하는명령 ( 생략시아래 vgextend 작업시생성됨 ) [root@localhost ~]# pvcreate /dev/hda3 Physical volume "/dev/hda3" successfully created [root@localhost ~]# C. VolGroup00 이활성화가되어있지않기때문에활성화 [root@localhost ~]# vgchange -a y VolGroup00 (vgchange 볼륨그룹을활성화 ) 2 logical volume(s) in volume group "VolGroup00" now active D. 활성화후 vgextend 를사용해 VolGroup00 에 /dev/hda3 을다음과같이추가 ( 생성된 physical volume 을 Volume group 에추가 ) [root@localhost ~]# vgextend VolGroup00 /dev/hda3 Volume group "VolGroup00" successfully extended 11
[root@localhost ~]# E. VolGroup00 의볼륨그룹확인 [root@localhost ~]# vgdisplay VolGroup00 ( 볼륨그룹의속성과정보를보여줍니다 ) --- Volume group --- VG Name VolGroup00 System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 59.88 GB PE Size 32.00 MB Total PE 1916 Alloc PE / Size 1276 / 39.88 GB Free PE / Size 640 / 20.00 GB VG UUID y1kt1c-m0yu-9slz-n0lh-q0ts-q31v-svnkb2 F. lvextend 명령을이용하여위파티션작업에서추가한 20G 용량을추가함 (lvextend : LV 를확장시키는명령 ) [root@localhost ~]# lvextend -L +20G /dev/volgroup00/logvol00 Extending logical volume LogVol00 to 57.88 GB Logical volume LogVol00 successfully resized G. 파일시스템체크및리사이징 (e2fsck 명령 : Linux 파일시스템을 check 시사용되는명령어 ) [root@localhost ~]# e2fsck -f /dev/volgroup00/logvol00 e2fsck 1.39 (29-May-2006) /dev/volgroup00/logvol00 is mounted. WARNING!!! Running e2fsck on a mounted filesystem may cause SEVERE filesystem damage. Do you really want to continue (y/n)? yes /dev/volgroup00/logvol00: recovering journal Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure 12
Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/volgroup00/logvol00: ***** FILE SYSTEM WAS MODIFIED ***** /dev/volgroup00/logvol00: ***** REBOOT LINUX ***** /dev/volgroup00/logvol00: 132954/9928704 files (2.3% non-contiguous), 1075408/9928704 blocks (resize2fs 명령 : 디바이스 ext2(ext3) 파티션의크기를조절하는명령어 ) [root@localhost ~]# resize2fs -p /dev/volgroup00/logvol00 resize2fs 1.39 (29-May-2006) Filesystem at /dev/volgroup00/logvol00 is mounted on /; on-line resizing required Performing an on-line resize of /dev/volgroup00/logvol00 to 15171584 (4k) blocks. The filesystem on /dev/volgroup00/logvol00 is now 15171584 blocks long. [root@localhost ~]# H. lvscan 과 pvscan 으로볼륨및사이즈확인 [root@localhost ~]# lvscan (Logical Volume 확인 ) ACTIVE '/dev/volgroup00/logvol00' [57.88 GB] inherit ACTIVE '/dev/volgroup00/logvol01' [2.00 GB] inherit [root@localhost ~]# pvscan (Physical Volume 확인 ) PV /dev/hda2 VG VolGroup00 lvm2 [39.88 GB / 0 free] PV /dev/hda3 VG VolGroup00 lvm2 [20.00 GB / 0 free] Total: 2 [59.88 GB] / in use: 2 [59.88 GB] / in no VG: 0 [0 ] F. 위내용까지마친후서버리부팅리부팅이완료후아래와같이 df 명령을이용하여추가된루트파티션용량을확인가능 [root@localhost ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/volgroup00-logvol00 58785924 3062008 52689856 6% / ( 늘어난용량확인 ) /dev/hda1 101086 31551 64316 33% /boot tmpfs 257652 0 257652 0% /dev/shm 13
다 ) VM 사용중볼륨추가 OS 사용중디스크공간부족으로새로운 Volume 을확장하여폴더에마운트시키는방법 A. [ 서버현황 ( 서버사용방법 )] -> 볼륨추가를원하는서버명클릭 B. [ 서버관리 ] 탭클릭 C. TASK 의 [ 볼륨관리 ] 클릭 D. 추가를원하는볼륨사이즈및정보입력후를클릭 E. 정상추가요청시 [ 서버현황 ( 서버사용방법 )] 을클릭하면서버의상태가 Processing 으로 변경되었으면정상 ( 처리완료시까지약 2 분소요, 볼륨추가시서버정상사용가능 ) F. [ 서버현황 ( 서버사용방법 )] 의요약에서서버의상태가 Running 으로변경되면볼륨추가작업 완료 G. 추가된볼륨은서버에서바로확인은불가하며리부팅후확인가능 서버 Reboot [root@localhost ~]# fdisk -l Disk /dev/hda: 279.1 GB, 279172874240 bytes 255 heads, 63 sectors/track, 33940 cylinders 14
Disk /dev/sda: 107.3 GB, 107374182400 bytes 16 heads, 255 sectors/track, 51400 cylinders Units = cylinders of 4080 * 512 = 2088960 bytes Disk /dev/sda doesn't contain a valid partition table H. 파티션생성및포맷 [root@localhost ~]# fdisk /dev/sda The number of cylinders for this disk is set to 51400. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-51400, default 1): Using default value 1 Last cylinder or +size or +sizem or +sizek (1-51400, default 51400): Using default value 51400 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@localhost ~]# mkfs.ext3 /dev/sda1 I. 마운트디렉토리 (/data) 생성후마운트 [root@localhost ~]# mkdir /data [root@localhost ~]# mount -t ext3 /dev/sda1 /data/ [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/volgroup00-logvol00 37G 3.0G 32G 9% / /dev/hda1 99M 31M 63M 33% /boot tmpfs 1014M 0 1014M 0% /dev/shm /dev/sda1 99G 188M 94G 1% /data 15
J. 부팅시자동으로마운트되도록 /etc/fstab 에등록 /dev/volgroup00/logvol00 / ext3 defaults 1 1 /dev/sda1 /data ext3 defaults 1 2 LABEL=/boot /boot ext3 defaults 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 /dev/volgroup00/logvol01 swap swap defaults 0 0 16