发表于 2019-4-17 16:21:45

Centos7 system

system-storage-manager 是红帽RHEL7系统自带的一款存储管理工具 可以简化存储管理

本次实验使用一台Centos7的虚拟机,新添加3块8G的scsi硬盘 通过ssm自动完成lvm的创建 文件系统创建 挂载

# yum -y install system-storage-manager
# 查看本机的存储信息
# ssm list
--------------------------------
Device      TotalMount point
--------------------------------
/dev/sda   20.00 GBPARTITIONED
/dev/sda1   1.00 GB/boot      
/dev/sda2   2.00 GBSWAP         
/dev/sda310.00 GB/            
/dev/sdb    8.00 GB               
/dev/sdc    8.00 GB               
/dev/sdd    8.00 GB               
--------------------------------
-------------------------------------------------------------------
Volume   Volume sizeFS    FS size       FreeTypeMount point
-------------------------------------------------------------------
/dev/sda1      1.00 GBext41.00 GB827.75 MBpart/boot      
/dev/sda3   10.00 GBxfs   9.99 GB    8.74 GBpart/            
-------------------------------------------------------------------
# ls /media/
cdromlv1lv2
# 使用 sd{b..d} 创建vg0/lv1 并格式化为 xfs 挂载到 /media/lv1
# ssm create -s 400M -n lv1 -p vg0 --fstype xfs /dev/sd{b..d} /media/lv1
Physical volume "/dev/sdb" successfully created.
Physical volume "/dev/sdc" successfully created.
Physical volume "/dev/sdd" successfully created.
Volume group "vg0" successfully created
Logical volume "lv1" created.
meta-data=/dev/vg0/lv1         isize=512    agcount=4, agsize=25600 blks
=                     sectsz=512   attr=2, projid32bit=1
=                     crc=1      finobt=0, sparse=0
data   =                     bsize=4096   blocks=102400, imaxpct=25
=                     sunit=0      swidth=0 blks
naming   =version 2            bsize=4096   ascii-ci=0 ftype=1
log      =internal log         bsize=4096   blocks=855, version=2
=                     sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
# df -h
Filesystem         SizeUsed Avail Use% Mounted on
/dev/sda3             10G1.3G8.8G13% /
/dev/sda1            976M   97M812M11% /boot
/dev/mapper/vg0-lv1397M   21M377M   6% /media/lv1
# 扩容 /dev/vg0/lv1 增加60M
# ssm resize -s +60M vg0/lv1
Size of logical volume vg0/lv1 changed from 400.00 MiB (100 extents) to 460.00 MiB (115 extents).
Logical volume vg0/lv1 successfully resized.
# df -h
Filesystem         SizeUsed Avail Use% Mounted on
/dev/sda3             10G1.3G8.8G13% /
/dev/sda1            976M   97M812M11% /boot
/dev/mapper/vg0-lv1457M   21M437M   5% /media/lv1
# 创建一个vg0/lv1 的逻辑卷大小200M 使用ext4文件系统 挂载到 /media/lv2
# ssm create -s 200M -n lv2 --fstype ext4 -p vg0 /media/lv2
Logical volume "lv2" created.
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
51200 inodes, 204800 blocks
10240 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33816576
25 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Allocating group tables: done                           
Writing inode tables: done                           
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
# df -h
Filesystem         SizeUsed Avail Use% Mounted on
/dev/sda3             10G1.3G8.8G13% /
/dev/sda1            976M   97M812M11% /boot
/dev/mapper/vg0-lv1457M   21M437M   5% /media/lv1
/dev/mapper/vg0-lv2190M1.6M175M   1% /media/lv2
# vg0/lv2 缩小 40M 如果没有卸载会提示卸载处理完后会自动挂载
# ssm resize -s-40M vg0/lv2
Do you want to unmount "/media/lv2" ? y
fsck from util-linux 2.23.2
/dev/mapper/vg0-lv2: 11/51200 files (0.0% non-contiguous), 12115/204800 blocks
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/mapper/vg0-lv2 to 163840 (1k) blocks.
The filesystem on /dev/mapper/vg0-lv2 is now 163840 blocks long.
Size of logical volume vg0/lv2 changed from 200.00 MiB (50 extents) to 160.00 MiB (40 extents).
Logical volume vg0/lv2 successfully resized.
# lvs
LV   VGAttr       LSize   Pool Origin Data%Meta%Move Log Cpy%Sync Convert
lv1vg0 -wi-ao---- 460.00m                                                
lv2vg0 -wi-ao---- 160.00m         
# df -hT
Filesystem          Type      SizeUsed Avail Use% Mounted on
/dev/sda3         xfs      10G1.3G8.8G13% /
/dev/sda1         ext4      976M   97M812M11% /boot
/dev/mapper/vg0-lv1 xfs       457M   21M437M   5% /media/lv1
/dev/mapper/vg0-lv2 ext4      151M1.6M139M   2% /media/lv2

删除创建的 lvm vg pv

# ssm remove -h
usage: ssm remove [-h] [-a] ]
positional arguments:
items       Items to remove. Item could be device, pool, or volume.
optional arguments:
-h, --helpshow this help message and exit
-a, --all   Remove all pools in the system.
# ssm remove vg0/lv1 vg0/lv2
Do you really want to remove active logical volume vg0/lv1? : y
Logical volume "lv1" successfully removed
Do you really want to remove active logical volume vg0/lv2? : y
Logical volume "lv2" successfully removed
# ssm remove vg0
Volume group "vg0" successfully removed
# ssm remove /dev/sd{b..d}
SSM Info: Unable to remove '/dev/sdb'
SSM Info: Unable to remove '/dev/sdc'
SSM Info: Unable to remove '/dev/sdd'
SSM Error (2001): Nothing was removed!
# pvremove /dev/sd{b..d}
Labels on physical volume "/dev/sdb" successfully wiped.
Labels on physical volume "/dev/sdc" successfully wiped.
Labels on physical volume "/dev/sdd" successfully wiped.



页: [1]
查看完整版本: Centos7 system