Taking a Backup Using Snapshots

출처 : http://tldp.org/HOWTO/LVM-HOWTO/snapshots_backup.html#snapbackcreate

사용자(작성자) 요청이 있을경우 자삭 합니다.


Taking a Backup Using Snapshots

Following on from the previous example we now want to use the extra space in the "ops" volume group to make a database backup every evening. To ensure that the data that goes onto the tape is consistent we use an LVM snapshot logical volume.

A snapshot volume is a special type of volume that presents all the data that was in the volume at the time the snapshot was created. For a more detailed description, see Section 3.8, Snapshots. This means we can back up that volume without having to worry about data being changed while the backup is going on, and we don't have to take the database volume offline while the backup is taking place.

Note

In LVM1, this type of volume was read-only, but LVM2 creates read/write snapshots by default.

13.4.1. Create the snapshot volume

There is a little over 500 Megabytes of free space in the "ops" volume group, so we will use all of it to allocate space for the snapshot logical volume. A snapshot volume can be as large or a small as you like but it must be large enough to hold all the changes that are likely to happen to the original volume during the lifetime of the snapshot. So here, allowing 500 megabytes of changes to the database volume which should be plenty.

# lvcreate -L592M -s -n dbbackup /dev/ops/databases 
lvcreate -- WARNING: the snapshot must be disabled if it gets full
lvcreate -- INFO: using default snapshot chunk size of 64 KB for "/dev/ops/dbbackup"
lvcreate -- doing automatic backup of "ops"
lvcreate -- logical volume "/dev/ops/dbbackup" successfully created


WarningFull snapshot are automatically disabled
 

If the snapshot logical volume becomes full it will be dropped (become unusable) so it is vitally important to allocate enough space. The amount of space necessary is dependent on the usage of the snapshot, so there is no set recipe to follow for this. If the snapshot size equals the origin size, it will never overflow.

13.4.2. Mount the snapshot volume

We can now create a mount-point and mount the volume

# mkdir /mnt/ops/dbbackup
# mount /dev/ops/dbbackup /mnt/ops/dbbackup

mount: block device /dev/ops/dbbackup is write-protected, mounting read-only

If you are using XFS as the filesystem you will need to add the nouuid option to the mount command:

# mount /dev/ops/dbbackup /mnt/ops/dbbackup -onouuid,ro

13.4.3. Do the backup

I assume you will have a more sophisticated backup strategy than this!

# tar -cf /dev/rmt0 /mnt/ops/dbbackup
tar: Removing leading `/' from member names

13.4.4. Remove the snapshot

When the backup has finished you can now unmount the volume and remove it from the system. You should remove snapshot volume when you have finished with them because they take a copy of all data written to the original volume and this can hurt performance.

# umount /mnt/ops/dbbackup
# lvremove /dev/ops/dbbackup

lvremove -- do you really want to remove "/dev/ops/dbbackup"? [y/n]: y
lvremove -- doing automatic backup of volume group "ops"
lvremove -- logical volume "/dev/ops/dbbackup" successfully removed

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 삐꾸강아쥐

2008/11/20 09:43 2008/11/20 09:43
, , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://blog.blog.n-nuri.com/rss/response/579

Trackback URL : http://blog.blog.n-nuri.com/trackback/579

Leave a comment
[로그인][오픈아이디란?]

[Linux] LVM mirror 만들기

출처 : http://www.redhat.com/docs/manuals/csgfs/browse/4.5/SAC_Cluster_Logical_Volume_Manager/mirror_create.html
작성자의 요청시 자삭 합니다.

Creating Mirrored Volumes

When you create a mirrored volume, you specify the number of copies of the data to make with the -m argument of the lvcreate command. Specifying -m1 creates one mirror, which yields two copies of the file system: a linear logical volume plus one copy. Similarly, specifying -m2 creates two mirrors, yielding three copies of the file system.

The following command creates a mirrored logical volume with a single mirror. The volume is 50 gigabytes in size, is named mirrorlv, and is carved out of volume group vg0:

lvcreate -L 50G -m1 -n gfslv vg0

An LVM mirror divides the device being copied into regions that, by default, are 512KB in size. You can use the -R argument to specify the region size in MB. LVM maintains a small log which it uses to keep track of which regions are in sync with the mirror or mirrors. By default, this log is kept on disk, which keeps it persistent across reboots. You can specify instead that this log be kept in memory with the --corelog argument; this eliminates the need for an extra log device, but it requires that the entire mirror be resynchronized at every reboot.

The following command creates a mirrored logical volume from the volume group bigvg. The logical is named ondiskmirvol and has a single mirror. The volume is 12MB in size and keeps the mirror log in memory.

# lvcreate -L 12MB -m1 --corelog -n ondiskmirvol bigvg
Logical volume "ondiskmirvol" created

When a mirror is created, the mirror regions are synchronized. For large mirror components, the sync process may take a long time. When you are creating a new mirror that does not need to be revived, you can specify the nosync argument to indicate that an initial synchronization from the first device is not required.

You can specify which devices to use for the mirror logs and log, and which extents of the devices to use. To force the log onto a particular disk, specify exactly one extent on the disk on which it will be placed. LVM does not necessary respect the order in which devices are listed in the command line. If any physical volumes are listed that is the only space on which allocation will take place. Any physical extents included in the list that are already allocated will get ignored.

The following command creates a mirrored logical volume with a single mirror. The volume is 500 megabytes in size, it is named mirrorlv, and it is carved out of volume group vg0. The first leg of the mirror is on device /dev/sda1, the second leg of the mirror is on device /dev/sdb1, and the mirror log is on /dev/sdc1.

lvcreate -L 500M -m1 -n mirrorlv vg0 /dev/sda1 /dev/sdb1 /dev/sdc1

The following command creates a mirrored logical volume with a single mirror. The volume is 500 megabytes in size, it is named mirrorlv, and it is carved out of volume group vg0. The first leg of the mirror is on extents 0 through 499 of device /dev/sda1, the second leg of the mirror is on extents 0 through 499 of device /dev/sdb1, and the mirror log starts on extent 0 of device /dev/sdc1. These are 1MB extents. If any of the specified extents have already been allocated, they will be ignored.

lvcreate -L 500M -m1 -n mirrorlv vg0 /dev/sda1:0-499 /dev/sdb1:0-499 /dev/sdc1:0

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 삐꾸강아쥐

2008/06/09 15:31 2008/06/09 15:31
,
Response
0 Trackbacks , 0 Comments
RSS :
http://blog.blog.n-nuri.com/rss/response/536

Trackback URL : http://blog.blog.n-nuri.com/trackback/536

Leave a comment
[로그인][오픈아이디란?]

LVM 간략 메뉴얼

Logical Volume Manager

장점으론 약간의 성능 향상이 있다고 하더군요...
그리고 용량을 늘리고, 줄이고가 자유롭죠

단점은... 갑작스런 하드 fail 의 대처가... 좀 힘들다는 점...

- LVM 생성 -

pvcreate 물리 디스크 추가
ex) pvcreate /dev/sdb /dev/sdc /dev/sdd

pvdisplay 추가한 물리 디스크 확인

vgcreate 볼륨 그룹 생성
ex) vgcreate vg0 /dev/sdb /dev/sdc /dev/sdd

vgdisplay 볼륨그룹 상태 확인

lvcreate 볼륨 그룹에 할당된 용량을 실질적인 파티셔닝
ex) lvcreate -L 6G -n data vg0
-L size LogicalVolumeSize
-n name LogicalVolumeName ( 파티션 레이블 )

lvdisplay 로지컬 볼륨의 상태 확인

format 하고
mount 시키면 끝.

- LVM 확장 -

vgextend 볼륨 그룹을 확장함
ex) vgextend vg0 /dev/sde

lvextend 로지컬 볼륨 확장
ex) lvextend -L +1G /dev/vg0/data

on line volume resize
resize2fs /dev/vg0/data

- LVM 축소 -

pvmove pv 교체등의 작업을 할경우 기존 pv 들어있던 정보를 다른 pv로 재 분배하는 유틸리티

lvreduce 로지컬 볼륨 축소
ex) lvreduce -L -1G /dev/vg0/data -A y
-L 사이즈 -1G
device
-A autobackup [y/n]


pvmove /dev/sde
해당 pv에 있던 데이터를 다른 pv로 재 분배
ex) /dev/sde 에 딜어있던 데이터를 라느곳으로 이동...

vgreduce 볼륨 그룹에서 해당 pv 제거
ex)
vgreduce vg0 /dev/sde
  Removed "/dev/sde" from volume group "vg0"

pvremove 해당 pv에서 완전 제거
pvremove vg0 /dev/sde
  Labels on physical volume "/dev/sde" successfully wiped


크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 삐꾸강아쥐

2007/08/10 18:14 2007/08/10 18:14
,
Response
0 Trackbacks , 0 Comments
RSS :
http://blog.blog.n-nuri.com/rss/response/453

Trackback URL : http://blog.blog.n-nuri.com/trackback/453

Leave a comment
[로그인][오픈아이디란?]

LVM의 간략 사용법

LVM을 사용할 경우 간략 사용법 이다.

먼저 사용할 파티션과 파티셥 타입을 지정해 준다.

파티션 타입은 8e 이며


vgscan ## LVM DB 초기화
pvcrate ## 물리적 볼륨그룹 지정 ex) pvcreate /dev/sda1 /dev/sdb1
vgcreate ## 볼륨그룹 생성 ex) vgcreate vg0 /dev/sda1 /dev/sdb1
lvcreate ## 로지컬 볼륨 생성 ex) lvcreate -L 4000 -n lv0 vg0

pvdisplay , vgdisplay , lvdisplay 정보 보여주기


e2fasdm 으로 LVM 영역 확장

vgextend vg0 /dev/sdc1 ## 물리적 볼륨그룹 지정한 영역을 볼륨그룹 vg0 에 할당
pvmove /dev/

로지컬 볼륨 용량 늘리기 ex) lvextend -L +4000 /dev/vg0/lv0 ## "+" 추가 한다는 것 임.

lvreduce ## 용량 줄이기
vgreduce ## pv 줄이기

더 자세한 내용은 인터넷이나 man 페이지를 참고 하면 된다.

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 삐꾸강아쥐

2007/05/02 21:43 2007/05/02 21:43
,
Response
0 Trackbacks , 0 Comments
RSS :
http://blog.blog.n-nuri.com/rss/response/342

Trackback URL : http://blog.blog.n-nuri.com/trackback/342

Leave a comment
[로그인][오픈아이디란?]

블로그 이미지

http://blog.n-nuri.com 이 접속이 안 될경우 http://x2x.dnip.net 으로 접속해 주세요 공유하지 않는 지식은 썩은 물과 같다~~~!!!

- 삐꾸강아쥐

Archives

Recent Trackbacks

Calendar

«   2009/01   »
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Site Stats

Total hits:
228254
Today:
33
Yesterday:
247
free counters