본문 바로가기

Server

Kt ucloud server 파티션 방법

반응형


- 파티션 하기전 사전 지식:



Linux 계열 서버 Data Disk Mount -LVM 구성

PV(physical volume)생성

하나의 물리적 디스크 이다. 리눅스에서 VG,LV 를 만들기 위해 물리적인 디스크를 PV 형태로 만들어주어야 한다.

VG(volume group) 생성

하나 이상의 물리적 디스크가 모여 이루어진 볼륨이다. 모든 PV 는 VG 에 속해 있어야한다.

리눅스는 모두 속해 있어야 할 필요는 없음

LV(logical volume) 생성

사용자는 LV에 접근을 해서 파일을 읽고 쓴다. VG 는 하나 이상의 LV 에 속한다.

사용자는 파일이 연속된 것처럼 보이지만, 실제로 PV 에는 불연속적인 공간에 write 가 될수 있음.





현재 용량 확인 


# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/xvda3       17G  2.3G   14G  15% /

devtmpfs        1.9G     0  1.9G   0% /dev

tmpfs           1.8G     0  1.8G   0% /dev/shm

tmpfs           1.8G   17M  1.8G   1% /run

tmpfs           1.8G     0  1.8G   0% /sys/fs/cgroup

/dev/xvda1      969M  190M  713M  22% /boot

tmpfs           354M     0  354M   0% /run/user/0



- fdisk 확인 


# fdisk -l


Disk /dev/xvda: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos

Disk identifier: 0x00099475


    Device Boot      Start         End      Blocks   Id  System

/dev/xvda1   *        2048     2050047     1024000   83  Linux

/dev/xvda2         2050048     6244351     2097152   82  Linux swap / Solaris

/dev/xvda3         6244352    41943039    17849344   83  Linux


Disk /dev/xvdb: 85.9 GB, 85899345920 bytes, 167772160 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

xvdb 는 사용자마다 다를 수 있음

  


- 추가된 디스크를 Linux LVM 으로 파티션 생성


# fdisk /dev/xvdb

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 0xb4e3f7ca.


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): 1

First sector (2048-167772159, default 2048): enter

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-167772159, default 167772159): enter

Using default value 167772159

Partition 1 of type Linux and of size 80 GiB is set


Command (m for help): t

Selected partition 1

Hex code (type L to list all codes): 8e

Changed type of partition 'Linux' to 'Linux LVM'


Command (m for help): w

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.




- pvcreate 도구 설치

# yum -y install lvm2


- pcreate 명령어를 이용하여 PV 생성

# pvcreate /dev/xvdb1

  Physical volume "/dev/xvdb1" successfully created. 


- 생성 결과 확인

# pvscan

  PV /dev/xvdb1                      lvm2 [80.00 GiB]

  Total: 1 [80.00 GiB] / in use: 0 [0   ] / in no VG: 1 [80.00 GiB]


- VG 생성

# vgcreate -s 16m DataVG /dev/xvdb1

  Volume group "DataVG" successfully created


- 생성된 VG 결과 확인

# vgdisplay DataVG

  --- Volume group ---

  VG Name               DataVG

  System ID

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  1

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                0

  Open LV               0

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               79.98 GiB

  PE Size               16.00 MiB

  Total PE              5119

  Alloc PE / Size       0 / 0

  Free  PE / Size       5119 / 79.98 GiB

  VG UUID               hqIPnm-yzwG-drBN-GdQK-RQom-GS4O-zbMuyR

     



- LV 생성

- l 옵션을 사용하여 용량을 지정해주고, -n 을 사용하여 이름을 지정해준다.

[root@VM1495156618242 ~]# lvcreate -L 80g -n data00 DataVG

  Volume group "DataVG" has insufficient free space (5119 extents): 5120 required.

  공간 부족 메시지 발생함


안전하게 파티션 할 디스크의 전체 용량을 입력해본다. 

위와 같이 오류가 발생하면서 얼마를 사용할수있다고 알려주면 그 값을 사용하도록 한다.

위에서는 5119 free 라고 한다.아래에 5119 를 사용하도록 한다.


# lvcreate -l 5119 -n data00 DataVG

  Logical volume "data00" created.   


- Logical Volume 생성 내역 확인

# lvdisplay -v

  --- Logical volume ---

  LV Path                /dev/DataVG/data00

  LV Name                data00

  VG Name                DataVG

  LV UUID                PMXwrU-Cp1s-lI8e-VZj3-xwtH-1fRL-RZkrkK

  LV Write Access        read/write

  LV Creation host, time VM1495156618242, 2017-05-19 11:36:17 +0900

  LV Status              available

  # open                 0

  LV Size                79.98 GiB

  Current LE             5119

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     8192

  Block device           253:0



- 파일 시스템 생성

# mkfs.ext3 /dev/DataVG/data00

mke2fs 1.42.9 (28-Dec-2013)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

5242880 inodes, 20967424 blocks

1048371 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

640 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000, 7962624, 11239424, 20480000


Allocating group tables: done

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done



- 폴더 생성후 마운트


# mkdir /mnt/data

# mount /dev/DataVG/data00  /mnt/data/

# mount

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)

tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)

cgroup on /sys/fs/cgroup/systemd type cgroup 

...

...

tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,size=361904k,mode=700)

/dev/mapper/DataVG-data00 on /mnt/data type ext3 (rw,relatime,data=ordered)



- 부팅시 자동 마운트 되도록 fstab 에 추가


# vi /etc/fstab

/dev/mapper/DataVG-data00               /mnt/data               ext3    defaults        0 0



MariaDB 서버구축을 위해 서버 디스크를 100G 가 추가함.

datadir 위치를 마운트된 위치로 변경함

마운트를 /home밑에 디렉터리를 생성하여 mariadb 의 datadir 를 /home/ 으로 변경하였으나 변경 실패함.


my.cnf 설정후 적용하려면 아래와 같은 에러가 발생

Can't create test file /home/ .......

mariadb 에서 데이터 위치는 /home 으로 잡으면 안되는것 같음.

 

datadir 위치를 /home 이 아닌 다른 디렉터리로 변경하여 해결함.



/mnt/ 로 마운트 함.


참고

https://ucloudbiz.olleh.com/manual/ucloud_server_UserManual.pdf





                         

반응형

'Server' 카테고리의 다른 글

mongo db docker-compose  (0) 2020.08.20
파일 비교 하여 다른 부분만 출력  (0) 2017.12.20
find 와 xargs 사용  (0) 2017.09.13
postgresql batch job shell script  (0) 2017.08.10
make 파일  (0) 2013.02.20