手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux fdisk LVM soft RAID 配置管理

[日期:2010-11-06] 来源:Linux社区  作者:wfliving [字体:大 中 小]
4. 查看结果
[root@localhost ~]# df -lh
文件系统             容量  已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
                       18G  2.1G   15G  13% /
/dev/sda1              99M   12M   82M  13% /boot
tmpfs                 252M     0  252M   0% /dev/shm
/dev/mapper/vg1-lvol0
                      775M   11M  725M   2% /tmp/test1    (观察发现,该分区已经增加了300M,现有775M)

解决方案3:减少分区容量200M
1.创建PV,VG,LV(略)  
查看现有磁盘容量:
[root@localhost ~]# df -lh
文件系统             容量  已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
                       18G  2.1G   15G  13% /
/dev/sda1              99M   12M   82M  13% /boot
tmpfs                 252M     0  252M   0% /dev/shm
/dev/mapper/vg2-lvol0
                      194M  5.6M  179M   4% /tmp/test2
/dev/mapper/vg1-lvol0
                      591M   17M  545M   3% /tmp/test1

2.取消挂载
(对ext2/ext3文件系统来说,resize2fs工具并不能在线缩小文件系统。什么是在线?在增大分区里边说的那样,对一个正常使用的文件系统进行增大操作,就叫在线操作。因此,需要先卸载了这个分区的文件系统才行)

[root@localhost ~]# umount /tmp/test1

3.检查文件系统正确性 (关键步骤):
[root@localhost ~]# e2fsck -f /dev/mapper/vg1-lvol0   (-f 强制检查  -p 打印输入)
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg1-lvol0: 11/76800 files (9.1% non-contiguous), 6635/153600 blocks

如果不检查文件系统,接下来减少分区会有如下提示,可能对后续操作有影响!!
[root@localhost ~]# resize2fs /dev/mapper/vg1-lvol0 50M
resize2fs 1.39 (29-May-2006)
Please run 'e2fsck -f /dev/mapper/vg1-lvol0 ' first.

4.修改文件系统大小 (关键步骤):
[root@localhost ~]# resize2fs /dev/mapper/vg1-lvol0 200M  (可以加 -p 参数)
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/mapper/vg1-lvol0 to 51200 (4k) blocks.
The filesystem on /dev/mapper/vg1-lvol0 is now 51200 blocks long.

5.减少逻辑卷大小(关键步骤):
[root@localhost ~]# lvreduce -L 200M /dev/mapper/vg1-lvol0
  WARNING: Reducing active logical volume to 200.00 MB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lvol0? [y/n]: y
  Reducing logical volume lvol0 to 200.00 MB
  Logical volume lvol0 successfully resized

6.查看结果:
[root@localhost ~]# vgdisplay vg1
  --- Volume group ---
  VG Name               vg1
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               952.00 MB
  PE Size               4.00 MB
  Total PE              238
  Alloc PE / Size       50 / 200.00 MB
  Free  PE / Size       188 / 752.00 MB
  VG UUID               erhVbI-5Ckz-befx-QpFZ-RbhV-Hl9K-qZ0x9Z

[root@localhost ~]# df -lh
文件系统             容量  已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
                       18G  2.1G   15G  13% /
/dev/sda1              99M   12M   82M  13% /boot
tmpfs                 252M     0  252M   0% /dev/shm
/dev/mapper/vg2-lvol0
                      194M  5.6M  179M   4% /tmp/test2  (观察发现,该分区已经从原来的591M变成了200M)

参考网址:
1.LVM详细说明 http://tech.foolpig.com/2010/04/01/lvm/
2.E2fsck用法  http://wiki.chinaunix.net/index.php/E2fsck
3.新手学LVM扩容  http://world77.blog.51cto.com/414605/382230
4.VMWARE终于扩容成功  http://blog.csdn.net/junglyfine/archive/2009/12/09/4974269.aspx
5.管理LVM逻辑分区         http://blog.chinaunix.net/u1/33254/showart_371203.html
6.LVM(逻辑管理器)     http://blog.csdn.net/xjtuse_mal/archive/2010/05/09/5572335.aspx
7. RHEL5下LVM扩容       http://blog.sina.com.cn/s/blog_3f7e47f20100iy53.html
8.LINUX查看的一些命令  http://www.360doc.com/content/07/0808/00/9144_659342.shtml
9. umount device busy 解决方法 http://blog.csdn.net/yunshine/archive/2009/04/07/4055509.aspx
10. umount 解决   http://www.linuxforum.net/forum/showflat.php?Board=linuxK &Number=598759
11 软RAID            http://www.chinaeda.cn/show.aspx?id=18290&cid=46

三.LINUX 创建软RAID
1.增加硬盘分区格式化,参照之前的步骤(略)


2.创建RAID5 (共四个硬盘 hd6 hd7 hd8 hd9)
[root@localhost ~]# mdadm --create /dev/md0 -l 5 -n 3 -x 1 /dev/hdb7 /dev/hdb6 /dev/hdb8 /dev/hdb9
mdadm: /dev/hdb7 appears to be part of a raid array:
    level=raid5 devices=3 ctime=Wed Nov  3 03:41:34 2010
mdadm: /dev/hdb6 appears to be part of a raid array:
    level=raid5 devices=3 ctime=Wed Nov  3 03:41:34 2010
mdadm: /dev/hdb8 appears to be part of a raid array:
    level=raid5 devices=3 ctime=Wed Nov  3 03:41:34 2010
mdadm: /dev/hdb9 appears to be part of a raid array:
    level=raid5 devices=3 ctime=Wed Nov  3 03:41:34 2010
Continue creating array? Y
mdadm: array /dev/md0 started.

3.查看RAID信息
[root@localhost ~]# mdadm --detail /dev/md0
/dev/md0:
        Version : 0.90
  Creation Time : Wed Nov  3 06:54:15 2010
     Raid Level : raid5
     Array Size : 1954304 (1908.82 MiB 2001.21 MB)
  Used Dev Size : 977152 (954.41 MiB 1000.60 MB)
   Raid Devices : 3
  Total Devices : 4
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Wed Nov  3 06:54:15 2010
          State : clean, degraded, recovering
 Active Devices : 2
Working Devices : 4
 Failed Devices : 0
  Spare Devices : 2

         Layout : left-symmetric
     Chunk Size : 64K

 Rebuild Status : 21% complete

           UUID : a4ec0ae2:2a155628:7f52fc73:b72a2dad
         Events : 0.1

    Number   Major   Minor   RaidDevice State
       0       3       71        0      active sync   /dev/hdb7
       1       3       70        1      active sync   /dev/hdb6
       4       3       72        2      spare rebuilding   /dev/hdb8

       3       3       73        -      spare   /dev/hdb9

4.删除RAID
[root@localhost ~]# mdadm -S /dev/md0
mdadm: stopped /dev/md0
[root@localhost ~]# mdadm -D /dev/md0

创建RAID1 : mdadm --create /dev/md0 -l 1 -n 2 /dev/hdb8 /dev/hdb9linux
相关资讯       Linux服务器 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款