ansible lvg模块详解

news/2024/11/16 15:53:19/

概述

This module creates, removes or resizes volume groups.
创建、删除卷组以及动态改变卷组大小。

常用模块

vg : The name of the volume group
要创建的卷组名称

pvs : List of comma-separated devices to use as physical devices in this volume group.
Required when creating or resizing volume group. The module will take care of running pvcreate if needed.
要加入到卷组中的物理卷列表

pesize : The size of the physical extent. `pesize’ must be a power of 2 of at least 1 sector (where the sector size is the largest sector size of the PVs currently used in the VG), or at least 128KiB. Since Ansible 2.6, pesize can be optionally suffixed by a UNIT (k/K/m/M/g/G), default unit is megabyte. [Default: 4]
指定pe大小,默认值是4M,默认单位是M。

state : Control if the volume group exists. (Choices: absent, present)[Default: present]
模块状态,absent代表删除,present代表新建,默认是present。

示例

案例1:创建卷组(vg.services)并且将物理卷sdb1加入到卷组中,指定pe大小为32M。

- name: Create a volume group on top of /dev/sdb1 with physical extent size = 32MBlvg:vg: vg.servicespvs: /dev/sdb1pesize: 32

指定PE的时候没有单位

[root@control ~]# ansible classroom -m lvg -a 'vg=vg.services pvs=/dev/sdb1 pesize=32'
classroom | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true
}
[root@control ~]# ansible classroom -a 'vgdisplay vg.services'
classroom | CHANGED | rc=0 >>--- Volume group ---VG Name               vg.servicesSystem ID             Format                lvm2Metadata Areas        1Metadata Sequence No  1VG Access             read/writeVG Status             resizableMAX LV                0Cur LV                0Open LV               0Max PV                0Cur PV                1Act PV                1VG Size               992.00 MiBPE Size               32.00 MiBTotal PE              31Alloc PE / Size       0 / 0   Free  PE / Size       31 / 992.00 MiBVG UUID               LTzgWU-a8pz-fk4Z-BR3J-w58j-ib4s-bvuvQq

案例2:创建卷组(vg.services)并且将物理卷sdb2加入到卷组中,指定pe大小为128KiB。

- name: Create a volume group on top of /dev/sdb2 with physical extent size = 128KiBlvg:vg: vg.servicespvs: /dev/sdbpesize: 128K

指定PE的时候有单位

[root@control ~]# ansible classroom -m lvg -a 'vg=vg.services pvs=/dev/sdb1 pesize=128K state=present'
classroom | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true
}[root@control ~]# ansible classroom -a 'pvdisplay'
classroom | CHANGED | rc=0 >>--- Physical volume ---PV Name               /dev/sdb1VG Name               vg.servicesPV Size               1023.00 MiB / not usable 0   Allocatable           yes PE Size               128.00 KiBTotal PE              8176Free PE               8176Allocated PE          0

案例3:在案例1的基础上新增物理卷sdb2

 name: Create or resize a volume group on top of /dev/sdb1 and /dev/sdb2.lvg:vg: vg.servicespvs: /dev/sdb1,/dev/sdb2
[root@control ~]# ansible classroom -m lvg -a 'vg=vg.services pvs=/dev/sdb1'
classroom | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true
}
[root@control ~]# ansible classroom -m lvg -a 'vg=vg.services pvs=/dev/sdb1,/dev/sdb2'
classroom | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true
}而不是ansible classroom -m lvg -a 'vg=vg.services pvs=/dev/sdb2'
不然的话,sdb1就移除vg了[root@control ~]# ansible classroom -a 'pvdisplay'
classroom | CHANGED | rc=0 >>--- Physical volume ---PV Name               /dev/sdb1VG Name               vg.servicesPV Size               1023.00 MiB / not usable 3.00 MiBAllocatable           yes PE Size               4.00 MiBTotal PE              255Free PE               255Allocated PE          0PV UUID               cIqSVO-9TfM-vOqz-A0oj-scoj-6su1-digL1B--- Physical volume ---PV Name               /dev/sdb2VG Name               vg.servicesPV Size               9.00 GiB / not usable 4.00 MiBAllocatable           yes PE Size               4.00 MiBTotal PE              2303Free PE               2303Allocated PE          0PV UUID               DPsWbd-CypK-8zSy-cej2-AbMp-JpBX-etrdEa

案例4:删除卷组

- name: Remove a volume group with name vg.serviceslvg:
vg: vg.services 
state: absent
[root@control ~]# ansible classroom -m lvg -a 'vg=vg.services state=absent'
classroom | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true
}[root@control ~]# ansible classroom -a 'vgscan'
classroom | CHANGED | rc=0 >>Reading all physical volumes.  This may take a while...

NOTES

  * 不能动态修改pe大小,只能删除重建vg的时候指定pe大小。* This module does not modify PE size for already present volume group.

在案例2的基础上尝试修改pe大小为4M

[root@control ~]# ansible classroom -m lvg -a 'vg=vg.services pvs=/dev/sdb1 pesize=4M state=present'
classroom | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": false
}

pe大小没有变化

[root@control ~]# ansible classroom -a 'pvdisplay'
classroom | CHANGED | rc=0 >>--- Physical volume ---PV Name               /dev/sdb1VG Name               vg.servicesPV Size               1023.00 MiB / not usable 0   Allocatable           yes PE Size               128.00 KiBTotal PE              8176Free PE               8176Allocated PE          0PV UUID               fbRiY1-P1CR-Kl3C-6cjp-Jy8m-3ehi-ydKduh

http://www.ppmy.cn/news/572044.html

相关文章

ansible学习笔记【14】lvg模块、lvol模块

一、lvg模块 创建卷组 vg 定义卷组名 state {present 创建,absent 删除} pvs 指定物理卷 pesize 定义pe大小 例如: 1、使用/dev/sdb磁盘创建myvg卷组 [ansiblecontrol ansible]$ ansible node1 -m lvg -a vgmyvg pvs/dev/sdb [ansiblecontrol ans…

ansible的lvg和lvol模块

ansible的lvg和lvol模块 parted分区模块lvg模块的参数lvol模块的参数创建lvm filesystem模块mount模块存储管理综合练习第八题 parted分区模块 实战环境的场景是批量分区和批量扩容 参数解释align配置分区的alignment(对齐)device块设备(磁盘路径)flags分区的flagsnumber分区编…

这篇文章让你彻底了解什么是安全测试?

目录 前言 安全测试的验证点: 主要归结为以下几点:(后期可以优化成一个安全测试的框架结构) 总结: 前言 web应用无处不在,存在于每个行业,现在的发展速度非常快速,且web应用在软…

模拟电路系列分享-运放的关键参数4

目录 概要 整体架构流程 技术名词解释 1.定义 2.优劣范围 3.理解 技术细节 1.压摆率 1.定义∶ 2.优劣范围 3.理解︰ 2.单位增益带宽 1.定义∶ 2.优劣范围︰ 3.理解∶ 小结 概要 提示:这里可以添加技术概要 例如: 实际运放与理想运放具有很多差别。理想…

采样中断服务程序原理

采样中断服务程序框图如图2-6所示。采样中断服务程序主要包括采样计算,TV、TA断线自检和保护起动元件三个部分。同时还可以根据不同的保护特点,增加一些检测被保护系统状态的程序。 一、采样计算概述 进入采样中断服务程序,首先进…

CorelDraw2019-pojie版下载

作为SCI顶刊画图神器 下载链接如下 https://pan.baidu.com/s/1oAVcZoRxcbkywn6jE6JRSQ 提取码 n2a8 安装和pojie教程请自行百度

ACDSee v8.0最完美汉化破解补丁发布,永不过期,还有绿色版

最完美汉化破解补丁发布,完全断绝和官方服务器的联系,不用再怕序列号会被封!(此版本基于烈火汉化第5版上进行破解)使用方法:1,安装软件,选择“FULL"2,输入序列号&am…

acdsee 5.0简体中文免费下载【非常流行的看图工具】

acdsee 5.0 简体中文版 acdsee看图软件免费下载 软件大小:96.93MB 软件语言:简体中文 软件性质:免费软件 软件授权:免费软件 软件等级:2 更新时间:2013-03-08 15:35:08 应用平台:win9x winnt …