离线安装Cloudera Manager 5和CDH5(最新版5.9.3) 完全教程(三)重新分配磁盘空间(可选)

一、查看文件系统

[root@master ~]# df -h
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/vg_master-lv_root   50G  1.2G   46G   3% /
tmpfs                         16G     0   16G   0% /dev/shm
/dev/sda1                    485M   39M  421M   9% /boot
/dev/mapper/vg_master-lv_home  231G  188M  219G   1% /home

由于我的HDFS存储目录实在根目录”/”下,因此实际这个节点上的存储空间只有50G,但是可以看出/dev/mapper/vg_master-lv_home下的空间有231G,大量空间没有被使用,因此我的目标是从中你抽取出223G的空间给根目录

二、卸载目录

[root@master ~]# umount /home

三、重新分配存储容量

[root@master ~]# e2fsck -f /dev/mapper/vg_master-lv_home 
e2fsck 1.41.12 (17-May-2010)
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
Pass 4: Checking reference counts
第5步: 检查簇概要信息
/dev/mapper/vg_master-lv_home: 11/15327232 files (0.0% non-contiguous), 1009843/61280256 blocks
[root@master ~]# resize2fs -p /dev/mapper/vg_master-lv_home 10G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_master-lv_home to 2621440 (4k) blocks.
Begin pass 2 (max = 32768)
正在重定位块            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 1871)
正在扫描inode表          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/vg_master-lv_home is now 2621440 blocks long.

[root@master ~]#

四、重新挂载目录

[root@master ~]# mount /home

五、释放存储空间

将抽出223G空间释放以便重新分配

[root@master ~]# lvreduce -L 10G /dev/mapper/vg_master-lv_home
  WARNING: Reducing active and open logical volume to 10.00 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
  Reducing logical volume lv_home to 10.00 GiB
  Logical volume lv_home successfully resized
[root@master ~]#

查看空闲的存储空间

[root@master ~]# vgdisplay
  --- Volume group ---
  VG Name               vg_master
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               299.51 GiB
  PE Size               4.00 MiB
  Total PE              76674
  Alloc PE / Size       19390 / 75.74 GiB
  Free  PE / Size       57284 / 223.77 GiB
  VG UUID               iF3Sxg-QDyY-2zkm-Tg6C-cuF5-UcRc-f7tCAm
   
[root@master ~]#

六、为目标磁盘增加存储

[root@master ~]# lvextend -L +223G /dev/mapper/vg_master-lv_root
  Extending logical volume lv_root to 273.00 GiB
  Logical volume lv_root successfully resized
[root@master ~]# resize2fs -p /dev/mapper/vg_master-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_master-lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 18
Performing an on-line resize of /dev/mapper/vg_master-lv_root to 71565312 (4k) blocks.
The filesystem on /dev/mapper/vg_master-lv_root is now 71565312 blocks long.

[root@master ~]#

七、查看文件存储大小

[root@master ~]# df -h
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/vg_master-lv_root  269G  1.2G  254G   1% /
tmpfs                         16G     0   16G   0% /dev/shm
/dev/sda1                    485M   39M  421M   9% /boot
/dev/mapper/vg_master-lv_home  9.9G  164M  9.2G   2% /home
[root@master ~]#

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1.  查看文件系统

[root@master ~]# df -h

Filesystem                   Size  Used Avail Use% Mounted on

/dev/mapper/vg_master-lv_root   50G  1.2G   46G   3% /

tmpfs                         16G     0   16G   0% /dev/shm

/dev/sda1                    485M   39M  421M   9% /boot

/dev/mapper/vg_master-lv_home  231G  188M  219G   1% /home

[root@master ~]#

 

由于我的HDFS存储目录实在根目录”/”下,因此实际这个节点上的存储空间只有50G,但是可以看出/dev/mapper/vg_master-lv_home下的空间有231G,大量空间没有被使用,因此我的目标是从中你抽取出223G的空间给根目录

2.  卸载目录

[root@master ~]# umount /home

3.  重新分配存储容量

[root@master ~]# e2fsck -f /dev/mapper/vg_master-lv_home

e2fsck 1.41.12 (17-May-2010)

第一步: 检查inode,,和大小

第二步: 检查目录结构

3: 检查目录连接性

Pass 4: Checking reference counts

5: 检查簇概要信息

/dev/mapper/vg_master-lv_home: 11/15327232 files (0.0% non-contiguous), 1009843/61280256 blocks

[root@master ~]# resize2fs -p /dev/mapper/vg_master-lv_home 10G

resize2fs 1.41.12 (17-May-2010)

Resizing the filesystem on /dev/mapper/vg_master-lv_home to 2621440 (4k) blocks.

Begin pass 2 (max = 32768)

正在重定位块            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Begin pass 3 (max = 1871)

正在扫描inode          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The filesystem on /dev/mapper/vg_master-lv_home is now 2621440 blocks long.

 

[root@master ~]#

4.  重新挂载目录

[root@master ~]# mount /home

5.  释放存储空间

将抽出223G空间释放以便重新分配

[root@master ~]# lvreduce -L 10G /dev/mapper/vg_master-lv_home

  WARNING: Reducing active and open logical volume to 10.00 GiB

  THIS MAY DESTROY YOUR DATA (filesystem etc.)

Do you really want to reduce lv_home? [y/n]: y

  Reducing logical volume lv_home to 10.00 GiB

  Logical volume lv_home successfully resized

[root@master ~]#

 

查看空闲的存储空间

[root@master ~]# vgdisplay

  --- Volume group ---

  VG Name               vg_master

  System ID            

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  5

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                3

  Open LV               3

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               299.51 GiB

  PE Size               4.00 MiB

  Total PE              76674

  Alloc PE / Size       19390 / 75.74 GiB

  Free  PE / Size       57284 / 223.77 GiB

  VG UUID               iF3Sxg-QDyY-2zkm-Tg6C-cuF5-UcRc-f7tCAm

  

[root@master ~]#

6.  为目标磁盘增加存储

[root@master ~]# lvextend -L +223G /dev/mapper/vg_master-lv_root

  Extending logical volume lv_root to 273.00 GiB

  Logical volume lv_root successfully resized

[root@master ~]# resize2fs -p /dev/mapper/vg_master-lv_root

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/mapper/vg_master-lv_root is mounted on /; on-line resizing required

old desc_blocks = 4, new_desc_blocks = 18

Performing an on-line resize of /dev/mapper/vg_master-lv_root to 71565312 (4k) blocks.

The filesystem on /dev/mapper/vg_master-lv_root is now 71565312 blocks long.

 

[root@master ~]#

查看文件存储大小

[root@master ~]# df -h

Filesystem                   Size  Used Avail Use% Mounted on

/dev/mapper/vg_master-lv_root  269G  1.2G  254G   1% /

tmpfs                         16G     0   16G   0% /dev/shm

/dev/sda1                    485M   39M  421M   9% /boot

/dev/mapper/vg_master-lv_home  9.9G  164M  9.2G   2% /home

[root@master ~]#

 

 

posted @ 2018-08-13 08:58  扎心了,老铁  阅读(2528)  评论(0编辑  收藏  举报