标签:linux
系统存储管理器的使用
SSM:系统存储管理器,是RHEL7/CentOS7 新增的功能,是一种统一的命令界面, 最新版本的CentOS/RHEL 7现在随带系统存储管理器(又叫ssm),这是一种统一的命令行界面,由红帽公司开发,用于管理各种各样的存储设备。目前,有三种可供ssm使用的卷管理后端:LVM、Btrfs和Crypt。
[root@RHEL7 ~]# date
Mon Aug 22 23:11:31 CST 2016
[root@system1 ~]# yum install system-storage-manager
查看系统存储信息
[root@system1 ~]# ssm list
-----------------------------------------------------------
Device Free Used Total Pool Mount point
-----------------------------------------------------------
/dev/vda 8.00 GB PARTITIONED
/dev/vda1 3.91 GB /
/dev/vda2 512.00 MB SWAP
/dev/vda3 0.00 KB 192.00 MB 196.00 MB vg0
-----------------------------------------------------------
--------------------------------------------------
Pool Type Devices Free Used Total
--------------------------------------------------
vg0 lvm 1 0.00 KB 192.00 MB 192.00 MB
--------------------------------------------------
------------------------------------------------------------------------------
Volume Pool Volume size FS FS size Free Type Mount point
------------------------------------------------------------------------------
/dev/vg0/vo vg0 192.00 MB xfs 188.67 MB 188.52 MB linear /home
/dev/vda1 3.91 GB xfs 3.90 GB 2.78 GB part /
------------------------------------------------------------------------------
[root@system1 ~]#
直接扩容VG,先创建一个分区,不要格式化
[root@RHEL7 ~]# fdisk /dev/sdd
[root@RHEL7 ~]# ssm list
---------------------------------------------------------------
Device Free Used Total Pool Mount point
---------------------------------------------------------------
/dev/sda 20.00 GB PARTITIONED
/dev/sda1 200.00 MB /boot
/dev/sda2 4.00 MB 10.74 GB 10.75 GB rhel
/dev/sdb 10.00 GB
/dev/sdb1 9.94 GB 56.00 MB 100.00 MB vgtest
/dev/sdb2 100.00 MB
/dev/sdc 10.00 GB
/dev/sdc1 40.00 MB 52.00 MB 95.00 MB vgtest
/dev/sdc2 191.00 MB
/dev/sdc3 95.00 MB
/dev/sdd 8.00 GB
/dev/sdd1 996.00 MB 0.00 KB 1000.00 MB rhel
/dev/sdd2 1000.00 MB
---------------------------------------------------------------
------------------------------------------------------
Pool Type Devices Free Used Total
------------------------------------------------------
rhel lvm 2 1000.00 MB 10.74 GB 11.72 GB
vgtest lvm 2 9.98 GB 108.00 MB 10.09 GB
------------------------------------------------------
---------------------------------------------------------------------------------------
Volume Pool Volume size FS FS size Free Type Mount point
---------------------------------------------------------------------------------------
/dev/rhel/root rhel 9.77 GB xfs 9.76 GB 6.48 GB linear /
/dev/rhel/swap rhel 1000.00 MB linear
/dev/vgtest/lvtest vgtest 52.00 MB xfs 48.67 MB 48.58 MB linear
/dev/sda1 200.00 MB xfs 196.67 MB 115.91 MB part /boot
---------------------------------------------------------------------------------------
--------------------------------------------------------------------
Snapshot Origin Pool Volume size Size Type
--------------------------------------------------------------------
/dev/vgtest/lvdisk_sp lvtest vgtest 56.00 MB 17.20 KB linear
--------------------------------------------------------------------
[root@RHEL7 ~]# ssm add -p vgtest /dev/sdd2
Physical volume "/dev/sdd2" successfully created
Volume group "vgtest" successfully extended
[root@RHEL7 ~]# ssm list
---------------------------------------------------------------
Device Free Used Total Pool Mount point
---------------------------------------------------------------
/dev/sda 20.00 GB PARTITIONED
/dev/sda1 200.00 MB /boot
/dev/sda2 4.00 MB 10.74 GB 10.75 GB rhel
/dev/sdb 10.00 GB
/dev/sdb1 9.94 GB 56.00 MB 100.00 MB vgtest
/dev/sdb2 100.00 MB
/dev/sdc 10.00 GB
/dev/sdc1 40.00 MB 52.00 MB 95.00 MB vgtest
/dev/sdc2 191.00 MB
/dev/sdc3 95.00 MB
/dev/sdd 8.00 GB
/dev/sdd1 996.00 MB 0.00 KB 1000.00 MB rhel
/dev/sdd2 996.00 MB 0.00 KB 1000.00 MB vgtest
---------------------------------------------------------------
------------------------------------------------------
Pool Type Devices Free Used Total
------------------------------------------------------
rhel lvm 2 1000.00 MB 10.74 GB 11.72 GB
vgtest lvm 3 10.95 GB 108.00 MB 11.06 GB
------------------------------------------------------
---------------------------------------------------------------------------------------
Volume Pool Volume size FS FS size Free Type Mount point
---------------------------------------------------------------------------------------
/dev/rhel/root rhel 9.77 GB xfs 9.76 GB 6.48 GB linear /
/dev/rhel/swap rhel 1000.00 MB linear
/dev/vgtest/lvtest vgtest 52.00 MB xfs 48.67 MB 48.58 MB linear
/dev/sda1 200.00 MB xfs 196.67 MB 115.91 MB part /boot
---------------------------------------------------------------------------------------
--------------------------------------------------------------------
Snapshot Origin Pool Volume size Size Type
--------------------------------------------------------------------
/dev/vgtest/lvdisk_sp lvtest vgtest 56.00 MB 17.20 KB linear
--------------------------------------------------------------------
[root@RHEL7 ~]#
实例2
[root@RHEL7 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
rhel 2 2 0 wz--n- 11.72g 1000.00m
vgtest 3 2 1 wz--n- 11.06g 10.95g
[root@RHEL7 ~]# fdisk /dev/sdd 创建SDD3分区
[root@RHEL7 ~]# ssm add -p vgtest /dev/sdd3
Physical volume "/dev/sdd3" successfully created
Volume group "vgtest" successfully extended
[root@RHEL7 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
rhel 2 2 0 wz--n- 11.72g 1000.00m
vgtest 4 2 1 wz--n- 12.05g 11.95g
LV扩容
需要VG有足够空间,我们先添加2GB容量到rhel中
[root@RHEL7 ~]# fdisk /dev/sdd
[root@RHEL7 ~]# ls /dev/sdd5
/dev/sdd5
[root@RHEL7 ~]# ssm add -p rhel /dev/sdd5
Physical volume "/dev/sdd5" successfully created
Volume group "rhel" successfully extended
[root@RHEL7 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
rhel 3 2 0 wz--n- 13.71g 2.97g
vgtest 4 2 1 wz--n- 12.05g 11.95g
查看原来磁盘容量情况
[root@RHEL7 ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs 9.8G 3.4G 6.5G 34% /
devtmpfs devtmpfs 908M 0 908M 0% /dev
tmpfs tmpfs 914M 80K 914M 1% /dev/shm
tmpfs tmpfs 914M 8.9M 905M 1% /run
tmpfs tmpfs 914M 0 914M 0% /sys/fs/cgroup
/dev/sda1 xfs 197M 91M 106M 47% /boot
进行扩容LV
[root@RHEL7 ~]# ssm resize -s +2G /dev/rhel/root
Extending logical volume root to 11.77 GiB
Logical volume root successfully resized
meta-data=/dev/mapper/rhel-root isize=256 agcount=4, agsize=640000 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=2560000, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2560000 to 3084288
扩容后的磁盘容量情况,/目录变成了12G
[root@RHEL7 ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs 12G 3.4G 8.5G 29% /
devtmpfs devtmpfs 908M 0 908M 0% /dev
tmpfs tmpfs 914M 80K 914M 1% /dev/shm
tmpfs tmpfs 914M 8.9M 905M 1% /run
tmpfs tmpfs 914M 0 914M 0% /sys/fs/cgroup
/dev/sda1 xfs 197M 91M 106M 47% /boot
创建LVM快照
[root@RHEL7 ~]# ls /dev/sde
/dev/sde
创建挂载点
[root@RHEL7 ~]# mkdir /ssm_disk
SSM命令格式
ssm create -s lv大小 -nlv名称 --fstype lv文件系统类型 -p 卷组名 设备 挂载点
[root@RHEL7 ~]# ssm create -s 2G -n ssm_disk --fstype xfs -p ssm /dev/sde //ssm_disk/
Physical volume "/dev/sde" successfully created
Volume group "ssm" successfully created
Logical volume "ssm_disk" created
meta-data=/dev/ssm/ssm_disk isize=256 agcount=4, agsize=131072 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=524288, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@RHEL7 ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs 12G 3.4G 8.5G 29% /
...
/dev/mapper/ssm-ssm_disk xfs 2.0G 33M 2.0G 2% /ssm_disk #自动挂载上了
[root@RHEL7 ~]# mount | tail -1
/dev/mapper/ssm-ssm_disk on /ssm_disk type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
[root@RHEL7 ~]# ssm list
----------------------------------------------------------------
Device Free Used Total Pool Mount point
----------------------------------------------------------------
....
/dev/sde 3.00 GB 2.00 GB 5.00 GB ssm #/dev/sde使用了2GB挂载了 ssm
创建快照
ssm snapshot快照 -s 大小 -n 名称 创建快照的设备
[root@RHEL7 ~]# ssm snapshot -s 1G -n ssm_disk_sp /dev/ssm/ssm_disk
Logical volume "ssm_disk_sp" created
[root@RHEL7 ~]#
使用快照
[root@RHEL7 ~]# umount /ssm_disk
[root@RHEL7 ~]# mount /dev/ssm/ssm_disk_sp /ssm_disk_sp/
mount: special device /dev/ssm/ssm_disk_sp does not exist
[root@RHEL7 ~]# ssm snapshot -s 1G -n ssm_disk_sp /dev/ssm/ssm_disk
Logical volume "ssm_disk_sp" created
[root@RHEL7 ~]# mount /dev/ssm/ssm_disk_sp /ssm_disk_sp/
[root@RHEL7 ~]# df | tail -1
/dev/mapper/ssm-ssm_disk_sp 2086912 32928 2053984 2% /ssm_disk_sp
[root@RHEL7 ~]#
删除快照
[root@RHEL7 ~]# ssm remove /dev/ssm/ssm_disk_sp
Do you really want to remove active logical volume ssm_disk_sp? [y/n]: y
Logical volume "ssm_disk_sp" successfully removed
本文出自 “技术成就梦想” 博客,请务必保留此出处http://andyliu.blog.51cto.com/518879/1841280
标签:linux
原文地址:http://andyliu.blog.51cto.com/518879/1841280