i.IT运维上分入门篇
a)【】
b)【】
c)【】
d)【】
e)【】
f)【】
g)【】
ii.IT运维上分初级篇
a)【】
b)【】
c)【】
d)【】
【正在更新】
e)【VMware虚拟化架构概述与兼容性查询】
f)【VMware虚拟化esxi安装】
g)【VMware虚拟化vCenter安装】
[root@web-apache site1]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 58.9G 0 part
├─rhel-root 253:0 0 40G 0 lvm /
├─rhel-swap 253:1 0 8.9G 0 lvm [SWAP]
└─rhel-home 253:2 0 10G 0 lvm /home
sdb 8:16 0 10G 0 disk
sdc 8:32 0 5G 0 disk
sr0 11:0 1 9.4G 0 rom /mnt
NAME : 表示磁盘设备名。
MAJ:MIN : 本栏显示主要和次要设备号。 对应 /dev/block 下的号
RM : 本栏显示设备是否可移动设备。注意,在本例中设备sdb和sr0的RM值等于1,这说明他们是可移动设备。
SIZE : 本栏列出设备的容量大小信息。例如60G表明该设备容量为60GB。
RO : 该项表明设备是否为只读。在本案例中,所有设备的RO值为0,表明他们不是只读的。
TYPE : 本栏显示块设备是否是磁盘或磁盘上的分区或lvm卷。
sr0 是光盘是只读设备(rom)。
MOUNTPOINT : 本栏指出设备挂载的挂载点。
[root@web-apache ~]# lsblk --help
Usage:
lsblk [options] [<device> ...]
-a, --all 打印所有设备
-b, --bytes 以字节为单位而非易读的格式来打印 SIZE
-d, --nodeps 不打印从属设备(slave)或占位设备(holder)
-D, --discard 打印时丢弃能力
-e, --exclude <列表> 根据主设备号排除设备(默认:内存盘)
-I, --include <列表> 只显示有指定主设备号的设备
-f, --fs 输出文件系统信息
-h, --help 使用信息(此信息)
-i, --ascii 只使用 ascii 字符
-m, --perms 输出权限信息
-l, --list 使用列表格式的输出
-n, --noheadings 不打印标题
-o, --output <列表> 输出列
-p, --paths 打印完整设备路径
-P, --pairs 使用 key=“value” 输出格式
-r, --raw 使用原生输出格式
-s, --inverse 反向依赖
-t, --topology 输出拓扑信息,并获取设备的IO调度算法
-S, --scsi 输出有关 SCSI 设备的信息
-h, --help 显示此帮助并退出
-V, --version 输出版本信息并退出
[root@web-apache site1]# fdisk -l
Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 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: 0x01b66509
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 2099199 2097152 1G 83 Linux
/dev/sda2 2099200 125634559 123535360 58.9G 8e Linux LVM
Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 sectors
Disk /dev/sda: 设备名
60 GiB 设备容量(以G为单位)
64424509440 bytes 设备容量(以字节为单位)
125829120 sectors 设备扇区
Units: sectors of 1 * 512 = 512 bytes 每个扇区大小是512字节
硬盘分区表:硬盘0磁道第一个扇区 512字节 MBR=446(BootLoader 引导程序信息)+64(分区表信息)+2(结束位校验信息55aa)
dd if=/dev/sda1 of=/tmp/sda1mbr.backup bs=1 count=512 备份分区表
查看磁盘dump文件 hexdump -C /tmp/sdambr.backup
[root@web-apache site1]# fdisk -l /dev/sda
Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 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: 0x01b66509
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 2099199 2097152 1G 83 Linux
/dev/sda2 2099200 125634559 123535360 58.9G 8e Linux LVM
Device 设备名
/dev/sda1 表示第一个分区
/dev/sda2 表示第二个分区
Boot 带*号表示引导
Start 起始容量位(扇区位)
End 结束容量位
Sectors 扇区数量
Size 设备容量大小
Id 设备分区类型ID号
Type 分区类型
硬盘分区表:
MBR:
1) 最大支持4个主分区
2) 硬盘分区:主分区 扩展分区 逻辑分区
3) 最大支持2T的硬盘
4) 扩展分区一块硬盘只能创建一个扩展分区
5) 缺点:最大支持2T的硬盘 最大支持4个主分区.
GPT:
1) 最大支持128个主分区
2) 最大支持18EB硬盘
3) 如果硬盘大于2T,建议使用GPT分区表.
分区工具:
1)fdisk 一般用来分区MGR分区表的磁盘
2)gdisk 一般用来分区GPT分区表的磁盘
3)parted 非交互式分区,一般脚本里面用的多
a)创建一个1G的分区
[root@web-apache ~]# lsblk -i /dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 10G 0 disk
[root@web-apache ~]# free -m
total used free shared buff/cache available
Mem: 7768 1051 5795 13 921 6449
Swap: 9111 0 9111
[root@web-apache ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1). ## fdisk 工具包版本
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x9b45d63b. ## 默认创建MBR格式
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 ## 分区号为1
First sector (2048-20971519, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-20971519, default 20971519): +1G##容量大小
Created a new partition 1 of type 'Linux' and of size 1 GiB.
Command (m for help): p ## 打印分区信息
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 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: 0x9b45d63b
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2099199 2097152 1G 83 Linux ## 分区1信息
Command (m for help): w ## 保存分区表
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
b)创建swap分区
[root@web-apache ~]# mkswap /dev/sdb1
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=51f3521f-73ab-4000-b721-67421c3e658c
[root@web-apache ~]# swapon /dev/sdb1
[root@web-apache ~]# free -m
total used free shared buff/cache available
Mem: 7768 1052 5794 13 921 6448
Swap: 10135 0 10135
c)开机自启动
root@web-apache ~]# lsblk -o UUID /dev/sdb1 UUID 51f3521f-73ab-4000-b721-67421c3e658c [root@web-apache ~]# echo "UUID=51f3521f-73ab-4000-b721-67421c3e658c swap swap defaults 0 0" >>/etc/fstab
[root@web-apache ~]# gdisk /dev/sdc
GPT fdisk (gdisk) version 1.0.3
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries.
Command (? for help): o ##创建磁盘模式GTP
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y
Command (? for help): n ##创建一个分区
Partition number (1-128, default 1): ##分号
First sector (34-10485726, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-10485726, default = 10485726) or {+-}size{KMGTP}: +2G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8300
Changed type of partition to 'Linux filesystem'
Command (? for help): p ##打印分区
Disk /dev/sdc: 10485760 sectors, 5.0 GiB
Model: Virtual disk
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 2C80E8FF-663C-4663-AF75-BFBEF34C16CE
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 10485726
Partitions will be aligned on 2048-sector boundaries
Total free space is 6291389 sectors (3.0 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 4196351 2.0 GiB 8300 Linux filesystem
Command (? for help): w ##保存分区
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.
将分区格式化并挂载
格式化并挂载 [root@web-apache ~]# mkfs -t ext4 /dev/sdc1 mke2fs 1.45.6 (20-Mar-2020) Creating filesystem with 524288 4k blocks and 131072 inodes Filesystem UUID: 99db48a6-bd50-4aaa-bd13-076cb45a1bdf Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Allocating group tables: done Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done [root@web-apache ~]# [root@web-apache ~]# mkdir /newdir [root@web-apache ~]# echo "/dev/sdc1 /newdir ext4 defaults 0 0" >>/etc/fstab [root@web-apache ~]# mount -a [root@web-apache ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev tmpfs tmpfs 3.8G 0 3.8G 0% /dev/shm tmpfs tmpfs 3.8G 9.4M 3.8G 1% /run tmpfs tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup /dev/mapper/rhel-root xfs 40G 4.7G 36G 12% / /dev/mapper/rhel-home xfs 10G 115M 9.9G 2% /home /dev/sda1 xfs 1014M 243M 772M 24% /boot tmpfs tmpfs 777M 3.5M 774M 1% /run/user/0 /dev/sr0 iso9660 9.5G 9.5G 0 100% /mnt /dev/sdc1 ext4 2.0G 6.0M 1.8G 1% /newdir
命令概述
-h, --help 显示此求助信息 -l, --list 列出所有设别的分区信息 -i, --interactive 在必要时,提示用户 -s, --script 从不提示用户 -v, --version 显示版本 操作命令: cp [FROM-DEVICE] FROM-MINOR TO-MINOR #将文件系统复制到另一个分区 help [COMMAND] #打印通用求助信息,或关于 COMMAND 的信息 mklabel 标签类型 #创建新的磁盘标签 (分区表) mkfs MINOR 文件系统类型 #在 MINOR 创建类型为“文件系统类型”的文件系统 mkpart 分区类型 [文件系统类型] 起始点 终止点 #创建一个分区 mkpartfs 分区类型 文件系统类型 起始点 终止点 #创建一个带有文件系统的分区 move MINOR 起始点 终止点 #移动编号为 MINOR 的分区 name MINOR 名称 #将编号为 MINOR 的分区命名为“名称” print [MINOR] #打印分区表,或者分区 quit #退出程序 rescue 起始点 终止点 #挽救临近“起始点”、“终止点”的遗失的分区 resize MINOR 起始点 终止点 #改变位于编号为 MINOR 的分区中文件系统的大小 rm MINOR #删除编号为 MINOR 的分区 select 设备 #选择要编辑的设备 set MINOR 标志 状态 #改变编号为 MINOR 的分区的标志
/dev/sdc的磁盘标签类型为GPT (MBR分区模式命令是 “msdos”)
parted /dev/sdc mklabel gpt
将/dev/sdc整个空间分给同一个分区
parted /dev/sdb mkpart primary 0 100%
设定分区label(非必要)
e2label /dev/sdc1 /nwedir2
也可写成一条命令
parted /dev/sdc mklabel gpt mkpart primary "1 -1"
kpartx -a /dev/sdc 刷新分区表
1.4. 查看设备的UUID与对应的文件系统
[root@web-apache site1]# blkid /dev/sda1: UUID="9a3cc5e8-1cca-4c93-87dc-6bbf77f59e38" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="01b66509-01" /dev/sda2: UUID="siue7I-XM17-DUii-JOKM-qCSU-BRqv-t1zOgg" TYPE="LVM2_member" PARTUUID="01b66509-02" /dev/sr0: BLOCK_SIZE="2048" UUID="2021-05-03-15-21-56-00" LABEL="RHEL-8-4-0-BaseOS-x86_64" TYPE="iso9660" PTUUID="426eea3b" PTTYPE="dos" /dev/mapper/rhel-root: UUID="2d0b32d5-2cc4-4863-b49c-d38635c5510f" BLOCK_SIZE="512" TYPE="xfs" /dev/mapper/rhel-swap: UUID="4004bbbc-be83-4a60-ab32-8133bcf43a8b" TYPE="swap" /dev/mapper/rhel-home: UUID="fc71fd8d-73e7-4e6b-bc8c-b5a407ec31b3" BLOCK_SIZE="512" TYPE="xfs"
1.5. LVM卷管理(Logical Volume Manager)
PV物理卷——> 卷用户组 VG——>物理扩展块PE——-> 逻辑卷LV——->文件系统FS——->挂载点mount
1.5.1. 查看系统当前pv信息
pvs vgdisplay
[root@localhost ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel lvm2 a-- 58.90g 4.00m [root@localhost ~]# pvdisplay --- Physical volume --- PV Name /dev/sda2 ## pv名称 VG Name rhel ## vg名称 PV Size <58.91 GiB / not usable 4.00 MiB ## pv容量/未使用容量 Allocatable yes PE Size 4.00 MiB ## 物理扩展块容量(pyhsical extent) Total PE 15079 ## 物理扩展块数量 Free PE 1 ## 未使用物理扩展块数量 Allocated PE 15078 ## 已经分配物理扩展块数量 PV UUID siue7I-XM17-DUii-JOKM-qCSU-BRqv-t1zOgg
vgs vgdisplay
[root@localhost ~]# vgdisplay --- Volume group --- VG Name rhel ## vg名称 System ID Format lvm2 ## vg版本 Metadata Areas 1 ## 元数据区 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 1 Act PV 1 VG Size 58.90 GiB ## vg容量 PE Size 4.00 MiB ## vg数据块大小 Total PE 15079 ## 物理扩展块 Alloc PE / Size 15078 / <58.90 GiB ## 总的物理扩展块/总容量 Free PE / Size 1 / 4.00 MiB ## 未使用的物理扩展块/未使用容量 VG UUID eQ0G4m-oSrt-ErsI-8g5S-Qxfd-WXrg-9Xt6qy
lvs lvdisplay
[root@localhost ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert home rhel -wi-ao---- 10.00g root rhel -wi-ao---- 40.00g swap rhel -wi-ao---- <8.90g [root@localhost ~]# lvdisplay /dev/rhel/home --- Logical volume --- LV Path /dev/rhel/home ## lv路径 LV Name home ## lv名称 VG Name rhel ## vg名称 LV UUID qRixB5-dQwP-66ac-vmVC-7OWA-h6Ij-K35ktS LV Write Access read/write LV Creation host, time localhost, 2021-08-20 22:54:49 +0800 LV Status available # open 1 LV Size 10.00 GiB ## lv容量 Current LE 2560 ## logical extents 数量 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2
a)新创建一个分区
[root@localhost ~]# fdisk /dev/sdb 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 (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): p Partition number (2-4, default 2): First sector (4196352-20971519, default 4196352): Last sector, +sectors or +size{K,M,G,T,P} (4196352-20971519, default 20971519): +5G Created a new partition 2 of type 'Linux' and of size 5 GiB. Partition #2 contains a ext4 signature. The signature will be removed by a write command. Command (m for help): t Partition number (1,2, default 2): Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM'. Command (m for help): p Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 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: 0xc98599a3 Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 4196351 4194304 2G 83 Linux /dev/sdb2 4196352 14682111 10485760 5G 8e Linux LVM Filesystem/RAID signature on partition 2 will be wiped. Command (m for help): w The partition table has been altered.
b)创建pv磁盘
[root@localhost ~]# pvcreate /dev/sdb2 Physical volume "/dev/sdb2" successfully created. [root@localhost ~]# pvcreate /dev/sdc Physical volume "/dev/sdc" successfully created. [root@localhost ~]#
c)创建vg卷
[root@localhost ~]# vgcreate myvg /dev/sdb2 /dev/sdc Volume group "myvg" successfully created [root@localhost ~]# [root@localhost ~]# vgs VG #PV #LV #SN Attr VSize VFree myvg 2 0 0 wz--n- 9.99g 9.99g rhel 1 3 0 wz--n- 58.90g 4.00m
d)创建条带化lvm卷
查看帮助文档
[root@localhost ~]# lvcreate --help |grep -A 6 striped Create a striped LV (infers --type striped). ## 创建条带化lvm卷 lvcreate -i|--stripes Number -L|--size Size[m|UNIT] VG ## 指定pv数量 [ -l|--extents Number[PERCENT] ] ## 以容量单位指定lv大小 [ -I|--stripesize Size[k|UNIT] ] ##容量单位指定lv大小 [ COMMON_OPTIONS ] [ PV ... ] [root@localhost ~]# lvcreate --help |grep -A 10 raid Create a raid LV (a specific raid level must be used, e.g. raid1). lvcreate --type raid -L|--size Size[m|UNIT] VG ## 创建raid卷 [ -l|--extents Number[PERCENT] ] [ -m|--mirrors Number ] [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ -R|--regionsize Size[m|UNIT] ] [ --minrecoveryrate Size[k|UNIT] ] [ --maxrecoveryrate Size[k|UNIT] ] [ --raidintegrity y|n ] [ --raidintegritymode String ] [ --raidintegrityblocksize Number ] [ COMMON_OPTIONS ] [ PV ... ]
e)创建卷条带化卷
[root@localhost ~]# lvcreate -i 2 -I 1073741824 -L 2G -n mylv myvg Reducing requested stripe size 1.00 TiB to maximum, physical extent size 4.00 MiB. Logical volume "mylv" created. [root@localhost ~]# [root@localhost ~]# [root@localhost ~]# [root@localhost ~]# lvcreate -i 2 -I 1073741824 -L 2G -n mydatalv myvg /dev/sdb2 /dev/sdc Reducing requested stripe size 1.00 TiB to maximum, physical extent size 4.00 MiB. Logical volume "mydatalv" created. [root@localhost ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert mydatalv myvg -wi-a----- 2.00g mylv myvg -wi-a----- 2.00g home rhel -wi-ao---- 10.00g root rhel -wi-ao---- 40.00g swap rhel -wi-ao---- <8.90g
f)lvm卷扩容
[root@localhost ~]# mkdir /mylv_xfs [root@localhost ~]# mount /dev/myvg/mylv /mylv_xfs/ [root@localhost ~]# mkdir /mylv_ext4 [root@localhost ~]# mount /dev/myvg/mydatalv /mylv_xfs/ [root@apache ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/myvg-mylv xfs 2.0G 47M 2.0G 3% /mylv_xfs /dev/mapper/myvg-mydatalv ext4 2.0G 6.0M 2.0G 1% /mylv_ext4 [root@localhost ~]# lvextend -L +200M /dev/myvg/mydatalv Using stripesize of last segment 4.00 MiB Size of logical volume myvg/mydatalv changed from 2.00 GiB (512 extents) to <2.20 GiB (562 extents). Logical volume myvg/mydatalv successfully resized. [root@localhost ~]# lvextend -L +200M /dev/myvg/mylv Using stripesize of last segment 4.00 MiB Size of logical volume myvg/mylv changed from 2.00 GiB (512 extents) to <2.20 GiB (562 extents). Logical volume myvg/mylv successfully resized. [root@localhost ~]# resize2fs /dev/myvg/mydatalv resize2fs 1.45.6 (20-Mar-2020) Filesystem at /dev/myvg/mydatalv is mounted on /mylv_xfs; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 1 The filesystem on /dev/myvg/mydatalv is now 575488 (4k) blocks long. [root@apache ~]# xfs_growfs /dev/mapper/myvg-mylv meta-data=/dev/mapper/myvg-mylv isize=512 agcount=9, agsize=64512 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 data = bsize=4096 blocks=524288, imaxpct=25 = sunit=1024 swidth=2048 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=8 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 524288 to 575488 [root@apache ~]# df -Th /dev/mapper/myvg-mylv xfs 2.2G 49M 2.2G 3% /mylv_xfs /dev/mapper/myvg-mydatalv ext4 2.1G 6.0M 2.0G 1% /mylv_ext4
g)删除lvm卷
[root@apache ~]# umount /mylv_xfs [root@apache ~]# umount /mylv_ext4 [root@apache ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert mydatalv myvg -wi-a----- <2.20g mylv myvg -wi-a----- <2.20g [root@apache ~]# lvremove /dev/myvg/mylv /dev/myvg/mydatalv Do you really want to remove active logical volume myvg/mylv? [y/n]: y Logical volume "mylv" successfully removed Do you really want to remove active logical volume myvg/mydatalv? [y/n]: y Logical volume "mydatalv" successfully removed [root@apache ~]# vgremove myvg Volume group "myvg" successfully removed [root@apache ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert home rhel -wi-ao---- 10.00g root rhel -wi-ao---- 40.00g swap rhel -wi-ao---- <8.90g [root@apache ~]# pvremove /dev/sdb2 /dev/sdc Labels on physical volume "/dev/sdb2" successfully wiped. Labels on physical volume "/dev/sdc" successfully wiped. [root@apache ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel lvm2 a-- 58.90g 4.00m [root@apache ~]# vgs VG #PV #LV #SN Attr VSize VFree rhel 1 3 0 wz--n- 58.90g 4.00m [root@apache ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert home rhel -wi-ao---- 10.00g root rhel -wi-ao---- 40.00g swap rhel -wi-ao---- <8.90g
[root@web-apache site1]# scsi-rescan Scanning SCSI subsystem for new devices Scanning host 0 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning for device 0 0 0 0 ... RedHat 7之前的版本 echo "- - -" > /sys/class/scsi_host/host0/scan 如果外接FC存储设备加载驱动的方式 # modprobe -r lpfc(卸载驱动) # modprobe lpfc(加载驱动)
[root@localhost ~]# yum install stratis* -y [root@apache ~]# man stratis EXAMPLES Example 1. Creating a Stratis pool stratis pool create mypool /dev/sdb /dev/sdc Example 2. Creating an encrypted pool stratis key set --capture-key someKeyDescription stratis pool create --key-desc someKeyDescription mypool /dev/sdb /dev/sdc Example 3. Creating a filesystem from a pool stratis filesystem create mypool data1 Example 4. Binding a pool’s devices to use an NBDE policy for decryption stratis pool bind nbde --trust-url mypool someKeyDescription someTangServerUrl [root@apache ~]# stratis pool create mypool /dev/sdb1 #创建一个mypool池,使用/sdb1块设备 [root@localhost ~]# stratis filesystem create mypool data1 #创建一个data1文件系统,使用mypool池 [root@localhost ~]# stratis filesystem list #查看文件系统 Pool Name Name Used Created Device UUID mypool data1 546 MiB 2021 17:58 /dev/stratis/mypool/data1 f8feabd0940a4ec3b85c846c63459ffe [root@localhost ~]# stratis blockdev list #查看stratis的块设备 Pool Name Device Node Physical Size Tier mypool /dev/sdb1 10.00 GiB Data [root@localhost ~]# stratis pool list #查看stratis的块存储池 Name Total Physical Properties mypool 10.00 GiB / 37.63 MiB / 9.96 GiB ~Ca,~Cr
echo "UUID=XXXXXX /stratis_directory xfs defaults,x-systemd.requires=stratisd.service 0 0" >>/etc/fsttab defaults,x-systemd.requires=stratisd.service ## 该目录依赖于stratisd服务 echo "UUID=XXXXXX /network_share_dir xfs defaults,_netdev 0 0" >>/etc/fsttab defaults,_netdev ## 该目录依赖于网络服务
[root@localhost ~]# yum install kmod-kvdo vdo -y systemctl enable vdo.service --now man vdo # man查看帮助 EXAMPLES Creation of a VDO device named vdo0, with a 10 terabyte thinly-provisioned logical address size: # vdo create --name=vdo0 --device=/dev/sdb1 --vdoLogicalSize=10T Creating VDO vdo0 Starting VDO vdo0 Starting compression on VDO vdo0 VDO instance 1 volume is ready at /dev/mapper/vdo0 [root@localhost ~]# lvcreate --help|grep -A 6 vdo man LVM卷下创建vdo # man查看帮助 lvcreate --type vdo -L|--size Size[m|UNIT] VG [ -l|--extents Number[PERCENT] ] [ -V|--virtualsize Size[m|UNIT] ] [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ --vdo ] [ --vdopool LV_new ] [ --compression y|n ] [ --deduplication y|n ] [ COMMON_OPTIONS ] [ PV ... ]
vdo create --name=vdo0 --device=/dev/sdc --vdoLogicalSize=20G #查看卷状态 [root@servera ~]# vdo status -n vdo0 |egrep "Dedu|Comp|Physical" Compression: enabled ##开启压缩 Deduplication: enabled ##开启重复数据去重 Physical size: 5G ##物理卷容量 #格式化vdo卷 [root@localhost ~]# mkfs.xfs /dev/mapper/vdo0 -K meta-data=/dev/mapper/vdo0 isize=512 agcount=4, agsize=1310720 blks = sectsz=4096 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 data = bsize=4096 blocks=5242880, 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 Discarding blocks...Done.
[root@servera mnt]# vdostats --human-readable Device Size Used Available Use% Space saving% /dev/mapper/vdo0 5.0G 3.0G 2.0G 60% 98% [root@servera mnt]# cat /etc/fstab 增加一条 # /etc/fstab UUID=fcd18147-1e0f-47c6-8ed6-23d49e4c8966 /mnt/file1 xfs defaults,x-systemd.requires=vdo.service 0 0
本篇完
点击加载更多