RHEL高级磁盘管理—VDO

VDO简介

  • Virtual Data Optimizer 通过数据去重、压缩的方式来优化存储空间。
  • VDO层放置在现有块存储设备上,例如Raid设备、本地磁盘设备。
  • LVM 或文件系统 放置在VDO层之上,也可以将VDO放在LVM层之上
  • VDO工具需要用户手动安装,安装完成后即可使用vdo命令创建、添加、删除、激活、停止等操作

VDO安装

[root@localhost ~]# yum install -y vdo

vdo常用的选项

  1. vdo语法:vdo command
  2. command常用的参数:
create              创建一个VDO卷及其关联索引使其可用。

remove              删除一个或多个已停止的VDO卷和相关卷索引。

modify              修改一个或所有VDO的配置参数卷。更改将在VDO下次运行时生效设备启动;已经运行的设备则不是受到影响。

list                显示已启动VDO卷的列表。如果,所有指定它同时显示已启动和未启动卷。

start               启动一个或多个已停止、激活的VDO卷相关的服务。

status              以YAML格式报告VDO系统和卷状态。但是,这个命令不需要root特权如果没有,信息将是不完整的。

stop                停止一个或多个正在运行的VDO卷和相关卷服务。

activate            激活一个或多个VDO卷。激活卷可以使用“开始”命令启动。

deactivate          使一个或多个VDO卷失效。停用不能通过“start”命令启动卷。停用当前正在运行的卷不会停止它。

growLogical         增加VDO卷的逻辑大小。卷必须存在并且必须正在运行。

growPhysical        增加VDO卷的物理大小。卷必须存在并且必须正在运行。

使用vdo示例

目标: 使用为分区的磁盘,创建名为vdoname的vdo卷,并挂载到/vdodir目录下,并且能开机自定挂载

  1. 查看已经存在的未分区的磁盘
[root@localhost ~]# lsblk /dev/sda
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 80G 0 disk

使用磁盘分区创建vdo卷(也可以使用整个未分区的磁盘创建分区,在分区上创建vdo卷;如果使用这种方法,首先要清除磁盘上的签名)

  1. 创建一个磁盘分区
[root@localhost ~]# fdisk /dev/sda 

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-167772159, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-167772159, default 167772159): +20G Created a new partition 1 of type 'Linux' and of size 20 GiB. Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
  1. 查看该磁盘分区
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 80G 0 disk
└─sda1 8:1 0 20G 0 part //这是刚刚创建的磁盘分区
sr0 11:0 1 7.3G 0 rom /mnt
nvme0n1 259:0 0 80G 0 disk
├─nvme0n1p1 259:1 0 1G 0 part /boot
└─nvme0n1p2 259:2 0 79G 0 part
├─rhel-root 253:0 0 50G 0 lvm /
├─rhel-swap 253:1 0 2G 0 lvm [SWAP]
└─rhel-home 253:2 0 27G 0 lvm /home
  1. /dev/sda1上创建vdo卷(注意:创建的分区不需要格式化)
[root@localhost ~]# vdo create --name=vdoname --device=/dev/sda1 --vdoLogicalSize=8G
Creating VDO vdoname
Starting VDO vdoname
Starting compression on VDO vdoname
VDO instance 2 volume is ready at /dev/mapper/vdoname
  1. 查看已经创建的vdo
[root@localhost ~]# vdo list
vdoname

或者使用lsblk查看

[root@localhost ~]# lsblk /dev/sda
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 80G 0 disk
└─sda1 8:1 0 20G 0 part
└─vdoname 253:3 0 8G 0 vdo
  1. 格式化vdo卷,格式化类型xfs
[root@localhost ~]# mkfs.xfs /dev/mapper/vdoname
meta-data=/dev/mapper/vdoname isize=512 agcount=4, agsize=524288 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=2097152, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
  1. 查看已经创建的vdo卷的属性
[root@localhost ~]# vdostats --si
Device Size Used Available Use% Space saving%
/dev/mapper/vdoname 21.5G 4.3G 17.2G 20% 99%

或者使用blkid查看

[root@localhost ~]# blkid /dev/mapper/vdoname
/dev/mapper/vdoname: UUID="e7bf09bb-1203-4eef-8837-cd802ef11ded" TYPE="xfs"
  1. 挂载vdo卷,挂载目录/vdodir
[root@localhost ~]# mkdir /vdodir
[root@localhost ~]# mount /dev/mapper/vdoname /vdodir/
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 886M 0 886M 0% /dev
tmpfs 903M 0 903M 0% /dev/shm
tmpfs 903M 8.6M 894M 1% /run
tmpfs 903M 0 903M 0% /sys/fs/cgroup
/dev/mapper/rhel-root 50G 2.2G 48G 5% /
/dev/mapper/rhel-home 27G 225M 27G 1% /home
/dev/nvme0n1p1 1014M 171M 844M 17% /boot
tmpfs 181M 0 181M 0% /run/user/0
/dev/sr0 7.4G 7.4G 0 100% /mnt
/dev/mapper/vdoname 8.0G 90M 8.0G 2% /vdodir //已经挂载成功
  1. 查看挂载后的vdo卷的信息
[root@localhost ~]# vdostats --si
Device Size Used Available Use% Space saving%
/dev/mapper/vdoname 21.5G 4.3G 17.2G 20% 98%
[root@localhost ~]# lsblk /dev/mapper/vdoname
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vdoname 253:3 0 8G 0 vdo /vdodir
  1. 开机自动挂载vdo
[root@localhost ~]# echo "/dev/mapper/vdoname    /vdodir      xfs     defaults  0 0" >> /etc/fstab
[root@localhost ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Wed Aug 26 03:25:38 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=234365dc-2262-452e-9cbb-a6acfde04385 /boot xfs defaults 0 0
/dev/mapper/rhel-home /home xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
/dev/mapper/vdoname /vdodir xfs defaults 0 0
  1. 删除一个vdo
[root@localhost ~]# umount /vdodir/        //如果已经挂载,需要先卸载
[root@localhost ~]# vdo remove --name=vdoname
Removing VDO vdoname
Stopping VDO vdoname
[root@localhost ~]# vdo list

或者使用lsblk查看

[root@localhost ~]# lsblk /dev/sda
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 80G 0 disk
└─sda1 8:1 0 20G 0 part

RHEL高级磁盘管理—Stratis

Stratis简介

  • RHEL8.0本地存储管理工具
  • 通过Stratis可以便捷的使用精简配置(Thin Provisioning)、快照(Snapshots)、基于池(Pool-based)的管理和监控等高级存储功能
  • Stratis 基于xfs文件系统格式,创建filesystem后不需要格式化;例如:在pool池中创建file文件系统,则file文件系统的类型已经是xfs格式,不需要在去格式化
  • 守护进程:stratisd

安装Stratisd服务

[root@localhost ~]# yum install -y stratisd stratis-cli
[root@localhost ~]# systemctl enable --now stratisd

使用Stratis的整体操作流程

  1. 选择完好的块设备(磁盘或者分区)
  2. 创建pool
  3. pool中创建文件系统(filesystem

使用Stratis创建pool示例

  1. 创建完好的磁盘分区
[root@localhost ~]# lsblk /dev/sda
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 80G 0 disk
└─sda1 8:1 0 20G 0 part
  1. 创建pool前查看块设备是否存在签名认证,如果有则必须先清除块设备上的签名认证,才能继续使用
[root@localhost ~]# fdisk -l /dev/sda
Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4b000bc8

Disklabel部分就是块设备的签名认证,需要清除该签名认证

[root@localhost ~]# wipefs -a /dev/sda
/dev/sda: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
/dev/sda: calling ioctl to re-read partition table: Success

清除后,再次查看块设备的签名信息

[root@localhost ~]# fdisk -l /dev/sda
Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
  1. 创建pool池,一般是要求1G以上大小的块设备,才能创建pool
[root@localhost ~]# stratis pool create pool-one /dev/sda1       //pool-one是pool的名称;/dev/sda1是拿来使用的块设备
[root@localhost ~]# stratis pool list
Name Total Physical Size Total Physical Used
pool-one 20 GiB 52 MiB
  1. 向已经存在的pool池中添加块设备
[root@localhost ~]# lsblk /dev/sda2
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda2 8:2 0 20G 0 part
[root@localhost ~]# stratis pool add-data pool-one /dev/sda2
[root@localhost ~]# stratis pool list
Name Total Physical Size Total Physical Used
pool-one 40 GiB 72 MiB //容量比原来扩大了
  1. 同时将两块块设备添加到同一个pool池中
[root@localhost ~]# lsblk /dev/sda3 /dev/sda4
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda3 8:3 0 10G 0 part
sda4 8:4 0 20G 0 part
[root@localhost ~]# stratis pool create pool-two /dev/sda3 /dev/sda4
[root@localhost ~]# stratis pool list
Name Total Physical Size Total Physical Used
pool-one 40 GiB 72 MiB
pool-two 30 GiB 56 MiB
  1. 查看pool-one池和pool-two池中所使用的块设备
[root@localhost ~]# stratis blockdev list pool-one
Pool Name Device Node Physical Size State Tier
pool-one /dev/sda1 20 GiB InUse Data
pool-one /dev/sda2 20 GiB InUse Data
[root@localhost ~]# stratis blockdev list pool-two
Pool Name Device Node Physical Size State Tier
pool-two /dev/sda3 10 GiB InUse Data
pool-two /dev/sda4 20 GiB InUse Data
  1. 查看pool-one池和pool-two池中块设备的信息
[root@localhost ~]# lsblk /dev/sda
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 80G 0 disk
├─sda1 8:1 0 20G 0 part
│ └─stratis-1-private-2a5d0ca4266540b889057f37816c7423-physical-originsub 253:3 0 40G 0 stratis
│ ├─stratis-1-private-2a5d0ca4266540b889057f37816c7423-flex-thinmeta 253:4 0 32M 0 stratis
│ │ └─stratis-1-private-2a5d0ca4266540b889057f37816c7423-thinpool-pool 253:7 0 40G 0 stratis
│ ├─stratis-1-private-2a5d0ca4266540b889057f37816c7423-flex-thindata 253:5 0 40G 0 stratis
│ │ └─stratis-1-private-2a5d0ca4266540b889057f37816c7423-thinpool-pool 253:7 0 40G 0 stratis
│ └─stratis-1-private-2a5d0ca4266540b889057f37816c7423-flex-mdv 253:6 0 16M 0 stratis
├─sda2 8:2 0 20G 0 part
│ └─stratis-1-private-2a5d0ca4266540b889057f37816c7423-physical-originsub 253:3 0 40G 0 stratis
│ ├─stratis-1-private-2a5d0ca4266540b889057f37816c7423-flex-thinmeta 253:4 0 32M 0 stratis
│ │ └─stratis-1-private-2a5d0ca4266540b889057f37816c7423-thinpool-pool 253:7 0 40G 0 stratis
│ ├─stratis-1-private-2a5d0ca4266540b889057f37816c7423-flex-thindata 253:5 0 40G 0 stratis
│ │ └─stratis-1-private-2a5d0ca4266540b889057f37816c7423-thinpool-pool 253:7 0 40G 0 stratis
│ └─stratis-1-private-2a5d0ca4266540b889057f37816c7423-flex-mdv 253:6 0 16M 0 stratis
├─sda3 8:3 0 10G 0 part
│ └─stratis-1-private-31db6de0edb64a3f8721a33f55922b69-physical-originsub 253:8 0 30G 0 stratis
│ ├─stratis-1-private-31db6de0edb64a3f8721a33f55922b69-flex-thinmeta 253:9 0 16M 0 stratis
│ │ └─stratis-1-private-31db6de0edb64a3f8721a33f55922b69-thinpool-pool 253:12 0 30G 0 stratis
│ ├─stratis-1-private-31db6de0edb64a3f8721a33f55922b69-flex-thindata 253:10 0 30G 0 stratis
│ │ └─stratis-1-private-31db6de0edb64a3f8721a33f55922b69-thinpool-pool 253:12 0 30G 0 stratis
│ └─stratis-1-private-31db6de0edb64a3f8721a33f55922b69-flex-mdv 253:11 0 16M 0 stratis
└─sda4 8:4 0 20G 0 part
└─stratis-1-private-31db6de0edb64a3f8721a33f55922b69-physical-originsub 253:8 0 30G 0 stratis
├─stratis-1-private-31db6de0edb64a3f8721a33f55922b69-flex-thinmeta 253:9 0 16M 0 stratis
│ └─stratis-1-private-31db6de0edb64a3f8721a33f55922b69-thinpool-pool 253:12 0 30G 0 stratis
├─stratis-1-private-31db6de0edb64a3f8721a33f55922b69-flex-thindata 253:10 0 30G 0 stratis
│ └─stratis-1-private-31db6de0edb64a3f8721a33f55922b69-thinpool-pool 253:12 0 30G 0 stratis
└─stratis-1-private-31db6de0edb64a3f8721a33f55922b69-flex-mdv 253:11 0 16M 0 stratis

使用Stratis创建filesystem示例

  1. pool-one池中创建filesystem(一次只能创建一个filesystem
[root@localhost ~]# stratis filesystem create pool-one file-one      //pool-one是pool的名称;file-one是filesystem的名称
[root@localhost ~]# stratis filesystem list //列出已经拥有的filesystem
Pool Name Name Used Created Device UUID
pool-one file-one 546 MiB Sep 20 2020 20:33 /stratis/pool-one/file-one deeb42ce571542cab33afcbfece6dd0a
  1. 查看指定pool池中拥有的filesystem
[root@localhost ~]# stratis filesystem list pool-one
Pool Name Name Used Created Device UUID
pool-one file-one 546 MiB Sep 20 2020 20:33 /stratis/pool-one/file-one deeb42ce571542cab33afcbfece6dd0a
  1. 挂载filesystem,挂载点:/fsdir
[root@localhost ~]# mkdir /fsdir
[root@localhost ~]# mount /stratis/pool-one/file-one /fsdir/
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 886M 0 886M 0% /dev
tmpfs 903M 0 903M 0% /dev/shm
tmpfs 903M 8.7M 894M 1% /run
tmpfs 903M 0 903M 0% /sys/fs/cgroup
/dev/mapper/rhel-root 50G 1.7G 49G 4% /
/dev/nvme0n1p1 1014M 173M 842M 17% /boot
/dev/mapper/rhel-home 27G 225M 27G 1% /home
tmpfs 181M 0 181M 0% /run/user/0
/dev/sr0 7.4G 7.4G 0 100% /mnt
/dev/mapper/stratis-1-2a5d0ca4266540b889057f37816c7423-thin-fs-deeb42ce571542cab33afcbfece6dd0a 1.0T 7.2G 1017G 1% /fsdir
  1. 写入到/etc/fstab配置文件中,建议使用UUID,因为使用name的话,每次更新name,都要对配置文件进行刷新
[root@localhost ~]# blkid /stratis/pool-one/file-one
/stratis/pool-one/file-one: UUID="deeb42ce-5715-42ca-b33a-fcbfece6dd0a" TYPE="xfs"
[root@localhost ~]# echo "UUID=deeb42ce-5715-42ca-b33a-fcbfece6dd0a /fsdir xfs defaults 0 0" >> /etc/fstab
[root@localhost ~]# tail -3 /etc/fstab
/dev/mapper/rhel-home /home xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
UUID=deeb42ce-5715-42ca-b33a-fcbfece6dd0a /fsdir xfs defaults 0 0

RHEL_高级磁盘管理(vdo、stratis)的更多相关文章

  1. RHEL高级磁盘管理—Stratis

    2. Stratis 本地存储管理工具,通过Stratis可以便捷的使用Thin Provisioning.Snapshots.Pool-based的管理和监控等高级存储功能. Stratis 基于x ...

  2. linux磁盘管理系列-LVM的使用

    LVM是什么 LVM是Linux操作系统的逻辑卷管理器. 现在有两个Linux版本的LVM,分别是 LVM1,LVM2.LVM1是一种已经被认为稳定了几年的成熟产品,LVM2 是最新最好的LVM版本. ...

  3. linux 磁盘管理三部曲——(2)管理分区,文件系统类型格式化

    上篇小编给大家讲解了磁盘结构和分区的介绍,这篇小编就给大家演示如何管理分区和文件系统类型格式化. 小编上篇已经提到如何使用磁盘,今天这两步,就是其中很重要的两步.(前几天写的有点急,有点乱,今天又整理 ...

  4. linux磁盘管理系列三:LVM的使用

    磁盘管理系列 linux磁盘管理系列一:磁盘配额管理   http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_040_quota.html l ...

  5. 有关 Azure IaaS VM 磁盘以及托管和非托管高级磁盘的常见问题解答

    本文将对有关 Azure 托管磁盘和 Azure 高级存储的一些常见问题进行解答. 托管磁盘 什么是 Azure 托管磁盘? 托管磁盘是一种通过处理存储帐户管理来简化 Azure IaaS VM 的磁 ...

  6. centos Linux下磁盘管理 parted,df ,du,fdisk,partprobe,mkfs.ext4,mount,/etc/fstab,fsck,e2fsck,mk2efs,tmpfs ,nr_inodes, LVM,传统方式扩容文件系统 第七节课

    centos Linux下磁盘管理   parted,df ,du,fdisk,partprobe,mkfs.ext4,mount,/etc/fstab,fsck,e2fsck,mk2efs,tmpf ...

  7. linux 系统磁盘管理体系

    目录 linux 系统磁盘管理体系 一.磁盘的基本概念 二.磁盘的内部结构 三.磁盘的外部结构 四.磁盘的接口及类型 五.fdisk磁盘分区实践 六.gdisk 分区 七.parted 高级分区工具. ...

  8. Linux上天之路(十)之Linux磁盘管理

    主要内容 磁盘介绍 磁盘管理 磁盘限额 逻辑卷管理 磁盘阵列 1. 磁盘介绍 硬盘最基本的组成部分是由坚硬金属材料制成的涂以磁性介质的盘片,不同容量硬盘的盘片数不等.每个盘片有两面,都可记录信息.盘片 ...

  9. linux下玩转磁盘管理与挂载硬盘

    前言 本文将带来linux下的磁盘管理中的硬盘挂载,Linux操作系统挂载硬盘需要了解的一些知识.这可能是迄今为止介绍的最最最实用的linux硬盘挂载的文章了,比较详细.由于工作原因,平时使用的比较多 ...

随机推荐

  1. 别人 echo 、你也 echo ,是问 echo 知多少?-- Shell十三问<第三问>

    别人 echo .你也 echo ,是问 echo 知多少?-- Shell十三问<第三问> 承接上一章所介绍的 command line ,这里我们用 echo 这个命令加以进一步说明. ...

  2. ON DUPLICATE KEY UPDATE作用

    ON DUPLICATE KEY UPDATE作用 先声明一点,ON DUPLICATE KEY UPDATE为Mysql特有语法,这是个坑 语句的作用,当insert已经存在的记录时,执行Updat ...

  3. Kubernetes网络概念初探

    ------------恢复内容开始------------ Kubernetes网络是Kubernetes中一个核心概念.简而言之,Kubernetes网络模型可以确保集群上所有Kubernetes ...

  4. java面试一日一题:讲对mysql的MVCC的理解

    问题:请讲下对mysql中MVCC的理解 分析:这个问题要回答的是对MVCC的理解,以及MVCC解决了什么问题这几个方面入手. 回答要点: 主要从以下几点去考虑, 1.什么是MVCC? 2.MVCC用 ...

  5. Spring Security OAuth 2.0 发放令牌接口地址自定义

    OAuth 2.0 如何获取令牌 以密码模式为例,获取 Token curl --location --request POST 'http://oauth-server/oauth/token' \ ...

  6. 【macOS】Homebrew & Homebrew cask macOS软件包管理神器

    Homebrew Homebrew 与 Homebrew Cask Homebrew 是基于 OS X 的套件管理工具,是一个开源的 Ruby 脚本,专门用于快速下载软件.更通俗地讲,Homebrew ...

  7. Selenium 3 常用 API

    元素定位 获取页面元素属性 元素判断 元素操作 操作输入框/单击 双击 下拉框操作 键盘操作 鼠标操作 单选框操作 多选框操作 拖动窗口 操作 JS 框 切换 frame 使用 JS 操作页面对象 操 ...

  8. k8s endpoints k8s未配置选择器的service

    service 其实是一个TCP/UDP 代理 不仅可以代理Pod也可以代理其他的非Pod资源,例如外网的数据库,或者其他的资源 创建未配置选择器的service, service 的对外端口是500 ...

  9. spring data jpa之Auditing 表的创建时间,更新时间自动生成策略

    java实际编程中,几乎每一张表都会有createTime和updateTime字段,spring的优秀之处在于只要用几个注解,就帮我们解决该类问题,具体实现: 1,实体类添加注解: @EntityL ...

  10. 5403. Find the Kth Smallest Sum of a Matrix With Sorted Rows

    You are given an m * n matrix, mat, and an integer k, which has its rows sorted in non-decreasing or ...