系统存储管理器的使用
SSM:系统存储管理器,是RHEL7/CentOS7 新增的功能,是一种统一的命令界面, 最新版本的CentOS/RHEL 7现在随带系统存储管理器(又叫ssm),这是一种统一的命令行界面,由红帽公司开发,用于管理各种各样的存储设备。目前,有三种可供ssm使用的卷管理后端:LVM、Btrfs和Crypt。
[iyunv@RHEL7 ~]# date
Mon Aug 22 23:11:31 CST 2016
[iyunv@system1 ~]# yum install system-storage-manager
查看系统存储信息
[iyunv@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 /
------------------------------------------------------------------------------
[iyunv@system1 ~]#
直接扩容VG,先创建一个分区,不要格式化
[iyunv@RHEL7 ~]# fdisk /dev/sdd
[iyunv@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
--------------------------------------------------------------------
[iyunv@RHEL7 ~]# ssm add -p vgtest /dev/sdd2
Physical volume "/dev/sdd2" successfully created
Volume group "vgtest" successfully extended
[iyunv@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
--------------------------------------------------------------------
[iyunv@RHEL7 ~]#
实例2
[iyunv@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
[iyunv@RHEL7 ~]# fdisk /dev/sdd 创建SDD3分区
[iyunv@RHEL7 ~]# ssm add -p vgtest /dev/sdd3
Physical volume "/dev/sdd3" successfully created
Volume group "vgtest" successfully extended
[iyunv@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中
[iyunv@RHEL7 ~]# fdisk /dev/sdd
[iyunv@RHEL7 ~]# ls /dev/sdd5
/dev/sdd5
[iyunv@RHEL7 ~]# ssm add -p rhel /dev/sdd5
Physical volume "/dev/sdd5" successfully created
Volume group "rhel" successfully extended
[iyunv@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
查看原来磁盘容量情况
[iyunv@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
[iyunv@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
[iyunv@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快照
[iyunv@RHEL7 ~]# ls /dev/sde
/dev/sde
创建挂载点
[iyunv@RHEL7 ~]# mkdir /ssm_disk
SSM命令格式
ssm create -s lv 大小 -nlv名称 --fstype lv文件系统类型 -p 卷组名 设备 挂载点
[iyunv@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
[iyunv@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 #自动挂载上了
[iyunv@RHEL7 ~]# mount | tail -1
/dev/mapper/ssm-ssm_disk on /ssm_disk type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
[iyunv@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 名称 创建快照的设备
[iyunv@RHEL7 ~]# ssm snapshot -s 1G -n ssm_disk_sp /dev/ssm/ssm_disk
Logical volume "ssm_disk_sp" created
[iyunv@RHEL7 ~]#
使用快照
[iyunv@RHEL7 ~]# umount /ssm_disk
[iyunv@RHEL7 ~]# mount /dev/ssm/ssm_disk_sp /ssm_disk_sp/
mount: special device /dev/ssm/ssm_disk_sp does not exist
[iyunv@RHEL7 ~]# ssm snapshot -s 1G -n ssm_disk_sp /dev/ssm/ssm_disk
Logical volume "ssm_disk_sp" created
[iyunv@RHEL7 ~]# mount /dev/ssm/ssm_disk_sp /ssm_disk_sp/
[iyunv@RHEL7 ~]# df | tail -1
/dev/mapper/ssm-ssm_disk_sp 2086912 32928 2053984 2% /ssm_disk_sp
[iyunv@RHEL7 ~]#
删除快照
[iyunv@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
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com