文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Linux lvm管理(基于RH AS3.0)

Linux lvm管理(基于RH AS3.0)

时间:2007-06-12  来源:mdiane

1.      创建物理卷

[root@cuug254 /]# pvcreate /dev/sdf

pvcreate -- physical volume "/dev/sdf" successfully created

//显示物理卷的信息:pvdisplay /dev/sdf,参数v显示详细信息

2.      创建卷组

[root@cuug254 /]# vgcreate mysqlvg /dev/sdf

vgcreate -- INFO: using default physical extent size 4 MB

vgcreate -- INFO: maximum logical volume size is 255.99 Gigabyte

vgcreate -- doing automatic backup of volume group "mysqlvg"

vgcreate -- volume group "mysqlvg" successfully created and activated

//显示卷组信息:vgdisplay mysqlvg,参数v显示详细信息

3.      创建逻辑卷

[root@cuug254 /]# lvcreate oravg -n lv01 -L 1000m /dev/sdb /dev/sdc

lvcreate -- doing automatic backup of "oravg"

lvcreate -- logical volume "/dev/oravg/lv01" successfully created

//lvcreate n 指定逻辑卷的名称;-L 指定卷的大小

显示逻辑卷信息

[root@cuug254 /]# lvdisplay /dev/oravg/lv01

--- Logical volume ---

LV Name                /dev/oravg/lv01

VG Name                oravg

LV Write Access        read/write

LV Status              available

LV #                   1

# open                 0

LV Size                1000 MB

Current LE             250

Allocated LE           250

Allocation             next free

Read ahead sectors     1024

Block device           58:4

4.      创建基于卷的文件系统

[root@cuug254 /]# mkfs.ext3 /dev/oravg/lv01

mke2fs 1.32 (09-Nov-2002)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

128000 inodes, 256000 blocks

12800 blocks (5.00%) reserved for the super user

First data block=0

8 block groups

32768 blocks per group, 32768 fragments per group

16000 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376

 

Writing inode tables: done                           

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 33 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@cuug254 /]# mkdir /oracle

[root@cuug254 /]# mount /dev/oravg/lv01 /oracle

[root@cuug254 /]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/rootvg/Vol00     985M  182M  753M  20% /

/dev/sda1             145M  9.4M  128M   7% /boot

none                  149M     0  149M   0% /dev/shm

/dev/rootvg/Vol01     2.9G  1.8G  1.1G  64% /usr

/dev/rootvg/Vol04     985M  140M  796M  15% /var

/dev/oravg/lv01       985M   17M  919M   2% /oracle

5.      扩展逻辑卷的大小

[root@cuug254 /]# lvextend -L +500m /dev/oravg/lv01   //L指定扩展的大小

lvextend -- extending logical volume "/dev/oravg/lv01" to 1.46 GB

lvextend -- doing automatic backup of volume group "oravg"

lvextend -- logical volume "/dev/oravg/lv01" successfully extended

[root@cuug254 /]# df -k

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/rootvg/Vol00      1007896    186268    770428  20% /

/dev/sda1               147766      9559    130578   7% /boot

none                    151708         0    151708   0% /dev/shm

/dev/rootvg/Vol01      3023760   1812988   1057172  64% /usr

/dev/rootvg/Vol04      1007896    142484    814212  15% /var

/dev/oravg/lv01        1007896     16428    940268   2% /oracle

6.      扩展文件系统的大小

[root@cuug254 /]# umount /oracle

[root@cuug254 /]# resize2fs -f /dev/oravg/lv01 //-f 强制

resize2fs 1.32 (09-Nov-2002)

The filesystem on /dev/oravg/lv01 is now 384000 blocks long.

[root@cuug254 /]# mount /dev/oravg/lv01 /oracle

[root@cuug254 /]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/rootvg/Vol00     985M  182M  753M  20% /

/dev/sda1             145M  9.4M  128M   7% /boot

none                  149M     0  149M   0% /dev/shm

/dev/rootvg/Vol01     2.9G  1.8G  1.1G  64% /usr

/dev/rootvg/Vol04     985M  140M  796M  15% /var

/dev/oravg/lv01       1.5G   17M  1.4G   2% /oracle

注意:以上两步操作可用e2fsadm来完成

e2fsadm /dev/Volume/lv –L +5g

 

7.      重建/etc/lvmtab和/etc/lvmtab.d

[root@cuug254 /]# vgscan

vgscan -- reading all physical volumes (this may take a while...)

vgscan -- found active volume group "rootvg"

vgscan -- found active volume group "oravg"

vgscan -- found active volume group "mysqlvg"

vgscan -- "/etc/lvmtab" and "/etc/lvmtab.d" successfully created

vgscan -- WARNING: This program does not do a VGDA backup of your volume groups

8.      缩小文件系统大小

[root@cuug254 /]# lvreduce -L -500 /dev/oravg/lv01

lvreduce -- WARNING: reducing active and open logical volume to 1000 MB

lvreduce -- THIS MAY DESTROY YOUR DATA (filesystem etc.)

lvreduce -- do you really want to reduce "/dev/oravg/lv01"? [y/n]: y

lvreduce -- doing automatic backup of volume group "oravg"

lvreduce -- logical volume "/dev/oravg/lv01" successfully reduced

 

[root@cuug254 /]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/rootvg/Vol00     985M  183M  753M  20% /

/dev/sda1             145M  9.4M  128M   7% /boot

none                  149M     0  149M   0% /dev/shm

/dev/rootvg/Vol01     2.9G  1.8G  1.1G  64% /usr

/dev/rootvg/Vol04     985M  140M  796M  15% /var

/dev/oravg/lv01       1.5G   17M  1.4G   2% /oracle

[root@cuug254 /]# umount /oracle

[root@cuug254 /]# mkfs.ext3 /dev/oravg/lv01

mke2fs 1.32 (09-Nov-2002)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

128000 inodes, 256000 blocks

12800 blocks (5.00%) reserved for the super user

First data block=0

8 block groups

32768 blocks per group, 32768 fragments per group

16000 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376

 

Writing inode tables: done                           

Creating journal (4096 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@cuug254 /]# mount /dev/oravg/lv01 /oracle

[root@cuug254 /]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/rootvg/Vol00     985M  183M  753M  20% /

/dev/sda1             145M  9.4M  128M   7% /boot

none                  149M     0  149M   0% /dev/shm

/dev/rootvg/Vol01     2.9G  1.8G  1.1G  64% /usr

/dev/rootvg/Vol04     985M  140M  796M  15% /var

/dev/oravg/lv01       985M   17M  919M   2% /oracle

9.      缩小卷组的大小

[root@cuug254 /]# vgreduce oravg /dev/sde

vgreduce -- doing automatic backup of volume group "oravg"

vgreduce -- volume group "oravg" successfully reduced by physical volume:

vgreduce -- /dev/sde

[root@cuug254 /]# vgdisplay -v oravg | more

--- Volume group ---

VG Name               oravg

VG Access             read/write

VG Status             available/resizable

VG #                  1

MAX LV                256

Cur LV                1

Open LV               1

MAX LV Size           255.99 GB

Max PV                256

Cur PV                3

。。。。。。。

 

--- Physical volumes ---

PV Name (#)           /dev/sdb (1)

PV Status             available / allocatable

Total PE / Free PE    5118 / 4868

 

PV Name (#)           /dev/sdc (2)

PV Status             available / allocatable

Total PE / Free PE    5118 / 5118

 

PV Name (#)           /dev/sdd (3)

PV Status             available / allocatable

Total PE / Free PE    5118 / 5118

10. 移出逻辑卷

[root@cuug254 /]# umount /oracle

[root@cuug254 /]# lvremove /dev/oravg/lv01

lvremove -- do you really want to remove "/dev/oravg/lv01"? [y/n]: y

lvremove -- doing automatic backup of volume group "oravg"

lvremove -- logical volume "/dev/oravg/lv01" successfully removed

[root@cuug254 /]# vgdisplay -v oravg

--- Volume group ---

VG Name               oravg

VG Access             read/write

VG Status             available/resizable

VG #                  1

MAX LV                256

Cur LV                0

Open LV               0

MAX LV Size           255.99 GB

Max PV                256

Cur PV                3

Act PV                3

VG Size               59.98 GB

PE Size               4 MB

Total PE              15354

Alloc PE / Size       0 / 0

Free  PE / Size       15354 / 59.98 GB

VG UUID               Gci3AB-vkjA-x3Zv-0FFU-uvOj-wUfp-nImNPP

--- No logical volumes defined in "oravg" ---

--- Physical volumes ---

PV Name (#)           /dev/sdb (1)

PV Status             available / allocatable

Total PE / Free PE    5118 / 5118

PV Name (#)           /dev/sdc (2)

PV Status             available / allocatable

Total PE / Free PE    5118 / 5118

PV Name (#)           /dev/sdd (3)

PV Status             available / allocatable

Total PE / Free PE    5118 / 5118

11. 删除卷组

[root@cuug254 /]# vgchange -an oravg

vgchange -- volume group "oravg" successfully deactivated

[root@cuug254 /]# vgremove oravg

vgremove -- volume group "oravg" successfully removed

显示卷组信息

[root@cuug254 /]# vgdisplay

--- Volume group ---

VG Name               mysqlvg

VG Access             read/write

VG Status             available/resizable

VG #                  2

MAX LV                256

Cur LV                0

Open LV               0

MAX LV Size           255.99 GB

Max PV                256

Cur PV                1

Act PV                1

VG Size               19.99 GB

PE Size               4 MB

Total PE              5118

Alloc PE / Size       0 / 0

Free  PE / Size       5118 / 19.99 GB

VG UUID               fQ1T64-UnjQ-hzZT-z1pR-U0NP-Alzr-tEWmhw

 

--- Volume group ---

VG Name               rootvg

VG Access             read/write

VG Status             available/resizable

VG #                  0

MAX LV                256

Cur LV                4

Open LV               4

MAX LV Size           255.99 GB

Max PV                256

Cur PV                1

Act PV                1

VG Size               19.84 GB

PE Size               4 MB

Total PE              5080

Alloc PE / Size       1375 / 5.37 GB

Free  PE / Size       3705 / 14.47 GB

VG UUID               T1sRpo-rOQc-duuz-URuo-fXcK-K5ou-Q03jTh

[root@cuug254 /]# pvdisplay /dev/sdb

pvdisplay -- "/dev/sdb" is a new physical volume of 20 GB

重新生成配置文件

[root@cuug254 /]# vgscan

vgscan -- reading all physical volumes (this may take a while...)

vgscan -- found active volume group "rootvg"

vgscan -- found active volume group "mysqlvg"

vgscan -- "/etc/lvmtab" and "/etc/lvmtab.d" successfully created

vgscan -- WARNING: This program does not do a VGDA backup of your volume groups

备份卷组的信息

vgcfgbackup/vgcfgrestor

默认情况下,会把卷组的配置信息备份在/etc/lvmconf/VGNAME.conf.n.old

创建镜像卷

lvcreate –i 2 –I 64 –n mirrlv mysqlvg –L 50m

lvcreate -- rounding 20480 KB to stripe boundary size 24576 KB / 6 PE

lvcreate -- doing automatic backup of "mygroup"

lvcreate -- logical volume "/dev/mygroup/stripedlv" successfully created

相关阅读 更多 +
排行榜 更多 +
爱是小事最新版

爱是小事最新版

休闲益智 下载
几何飞行内购修改版

几何飞行内购修改版

飞行射击 下载
别踩白块内购修改版

别踩白块内购修改版

休闲益智 下载