RHCE contact notes on Soft RAID and LVM

Source: Internet
Author: User
Article Title: RHCE's contact notes on Soft RAID and LVM. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Environment VM + rhel5.1

Add a 1 GB Virtual Disk (sdb) for testing.

Create 4 partitions (sdb1-4) for sdb each partition is 100 M

Fdisk/dev/sdb

Partprobe

RAID

Create two RAID 1 partitions

Mdadm-C/dev/md0-l 1-n 2/dev/sdb {1, 2}-a yes

Mdadm-C/dev/md1-l 1-n 2/dev/sdb {3, 4}-a yes

-C: Create a raid

-L specify the raid type

-N: number of devices used

View Current RAID Information

Cat/proc/mdstat

Or

Mdadm -- detail/dev/md0

Mdadm -- detail/dev/md1

Format RAID

Mke2fs-j/dev/md0

Mke2fs-j/dev/md1

Test and repair soft RAID

Simulate a drive failure using the mdadm-f parameter

Note: This command is useful in testing RAID1 and RAID5, and RAID0 is unavailable.

Mdadm-f/dev/md0/dev/sdb1

Now let's look at the differences in RADI information.

Cat/proc/mdstat

Delete A broken partition from RAID

Mdadm-r/dev/md0/dev/sdb1

Add the repaired partition or new partition

Mdadm-a/dev/md0/dev/sdb1

LVM

Concept

Pv physical volume

Vg volume group

Lv logical volume

Convert the above md0 md1 to a physical volume

Create a physical volume pvcreate

Pvcreate/dev/md0

Pvcreate/dev/md1

View physical volume information

Pvdisplay/dev/md0

 Create a volume group

Vgcreate vgname/dev/md0

 Create multiple physical volumes into a volume group

Vgcreate vaname/dev/md0/dev/md1 ............

View volume group information

View All

Vgdisplay vgname

Create logical volume

Lvcreate-L 100 M-n lvname vgname

-L specify the logical volume size

-N indicates the logical volume name.

Format logical volume

Mke2fs-j/dev/vgname/lvname

View logical volume information

Lvdisplay

Create an lv directory and mount the logical volume to this directory

Mkdir/lv

Mount/dev/vgname/lvname/lv

Modify/etc/fstab so that it can be automatically mounted during boot.

Add downstream

/Dev/vgname/lvname/lv ext3 defaults 0 0

Mount-a check whether the mounting is correct

Clear the device cache for the system to detect new volumes during startup

Rm/etc/lvm/. cache

Adjust logical volume size

Add physical volume/dev/md1 to the volume group

Vgextend vgname/dev/md1

Increase logical volume capacity

Lvextend-L + 50 M/dev/vgname/lvname

Resize2fs/dev/vgname/lvname

You can dynamically increase the capacity of a logical volume. When you increase the capacity, you do not need to unmount the mounted directory.

Reduces the logical volume capacity and reduces the logical volume capacity to 100 MB.

In this step, you must first uninstall the mounted directory

Umount/lv

The logical volume must be checked forcibly before adjustment

Fsck-f/dev/vgname/lvname

The subsequent steps are in reverse order with the added steps.

Execute resize2fs first to reduce the File System

Resize2fs/dev/vgname/lvname 100 M

Reduce logical volume

Lvreduce/dev/vgname/lvname-L 100 M

Reducing logical volumes is rarely used.

Create logical volume Snapshot

Write some content in/lv first

Create Snapshot

Lvcreate-L 16 M-p r-s-n lv-backup/dev/vgname/lvname

-P: The read/write attribute parameters of the specified snapshot are (r, rw)

-S

-L specify the snapshot size

-N specifies the snapshot name.

Test whether the snapshot is created successfully.

Create directory

Mkdir/tmp/lv

Attach a snapshot

Mount/dev/vgname/lv-backup/tmp/lv

Ls/tmp/lv

Check whether/tmp/lv and/lv have the same content.

The following error may be reported frequently during snapshot creation:

Snapshot: Required device-mapper target (s) net detected in your kernel

Cause: the dm-snapshot module is missing.

Solution: Enter modprobe dm-snapshot.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.