分享

PVE虚拟机增加硬盘

 doctor_刘 2019-03-15

 3. 在iSCSI磁盘 /dev/sdb上创建LVM分区、创建物理卷、创建卷组(只在某一个节点进行如下操作即可。)

a.执行磁盘分区命令:

root@pve-01:/#fdisk /dev/sdb

Welcome to fdisk(util-linux 2.25.2).

Changes will remainin memory only, until you decide to write them.

Be careful beforeusing the write command.

Command (m forhelp):g      (建立GPT分区表)

…………

Command (m forhelp):n      (建立一个新的分区,输入分区号、起始结束扇区等)

…………

Command (m forhelp):t      (改变分区类型31)

Selected partition1

Partition type(type L to list all types):31  (分区1的类型改变为Linux LVM)

Command(m for help): w      (写入磁盘并退出fdisk)

b.在分区/dev/sdb1上创建物理卷physical volume (PV):

pvcreate /dev/sdb1

  c.创建卷组volume group (VG),VG名为“vg-pve”

vgcreate vg-pve /dev/sdb1

至此,iSCSI共享存储已准备就绪。可供proxmoxVE使用了,在“数据中心”下存储栏,添加新的存储LVM,选择之前添加的vg-pve卷组,左侧下方会出现新增存储名称,即可在虚拟机添加硬件

以上为PVE虚拟机添加硬盘实际操作,在节点的Shell栏命令里写,不用winscp或putty

引自:http://blog.51cto.com/6222666/2161860

------------------------------------------------------------------------------------------------------------------
https://pve./wiki/LVM2
1、查看硬盘
#fdisk -l
例如有/dev/sdb

2 新建一个分区
# sgdisk -N 1 /dev/sdb


3 创建pv
#pvcreate --metadatasize 250k -y -ff /dev/sdb1

4 创建vg
#vgcreate pve1 /dev/sdb1

5 创建lv 薄模式 这里100g根据自己硬盘大小填写
#lvcreate -L 100g -T -n data pve1


6 警告:

在某些情况下,LVM不会正确计算元数据池/块大小。请检查metadatapool是否足够大。必须满足的公式是:

PoolSize / ChunkSize * 64b = MetadataPoolSize

你可以通过命令获取这些信息
#lvs -a -o name,size,chunk_size

8 增加到存储 可以在数据中心 存储 直接添加lvm-thin  id:lvm1, 卷组:pve1, thin pool:data 
或者编辑/etc/pve/storage.cfg
lvmthin: lvm1
         thinpool data
         vgname pve1
         content rootdir,images


Creating a Volume Group
Let’s assume we have an empty disk /dev/sdb, onto which we want to create a volume group named “vmdata”.

Caution Please note that the following commands will destroy all existing data on /dev/sdb.
First create a partition.

# sgdisk -N 1 /dev/sdb
Create a Physical Volume (PV) without confirmation and 250K metadatasize.

# pvcreate --metadatasize 250k -y -ff /dev/sdb1
Create a volume group named “vmdata” on /dev/sdb1

# vgcreate vmdata /dev/sdb1
Creating an extra LV for /var/lib/vz
This can be easily done by creating a new thin LV.

# lvcreate -n -V /
A real world example:

# lvcreate -n vz -V 10G pve/data
Now a filesystem must be created on the LV.

# mkfs.ext4 /dev/pve/vz
At last this has to be mounted.

Warning be sure that /var/lib/vz is empty. On a default installation it’s not.
To make it always accessible add the following line in /etc/fstab.

# echo '/dev/pve/vz /var/lib/vz ext4 defaults 0 2' >> /etc/fstab
Resizing the thin pool
Resize the LV and the metadata pool can be achieved with the following command.

# lvresize --size + --poolmetadatasize + /
Note When extending the data pool, the metadata pool must also be extended.
Create a LVM-thin pool
A thin pool has to be created on top of a volume group. How to create a volume group see Section LVM.

# lvcreate -L 80G -T -n vmstore vmdata



二、增加为zfs格式:
1 创建存储池(type  raidz 两块硬盘是raid1,三块硬盘是raid5,还可以用raidz1,2,3等高级用法)
性能对比
Stripe > Mirror
Stripe > RAIDZ1 > RAIDZ2 > RAIDZ3

数据可靠性
Mirror > Stripe
RAIDZ3 > RAIDZ2 > RAIDZ1 > Stripe

zpool create -f -o ashift=12 log cache
对已有pool增加缓存
zpool add -f log cache

更换失败的硬盘
zpool replace -f


pool存储池丢失处理.no pools avaliable
查看存储池状态
#zpool status -v
删除缓存
#rm -f /etc/zfs/zpool.cache
导入存储池
#zpool import zfs-v 
如果提示 -f 
#zpool import -f zfs-v
如果有设置过缓存或者log,可能会提示 -m 
#zpool import -f zfs-v -m



LVM使用缓存
#sda为HDD   sdb为SSD

1、创建物理卷
pvcreate /dev/sda
pvcreate /dev/sdb

2、创建卷组vg
vgcreate vg /dev/sda
vgextend vg /dev/sdb

3、创建逻辑卷(data为存储卷,cache为缓存卷,meta为缓冲卷索引,其中cache:meta不能大于1000:1,meta最小为8M)
lvcreate -L 500G -n data /dev/sda
lvcreate -L 220G -n cache /dev/sdb
lvcreate -L 220M -n meta  /dev/sdb

4、创建缓存池(注意cache和meta的顺序不能颠倒)
lvconvert --type cache-pool --poolmetadata vg/meta vg/cache

5、将存储卷加入到缓存池中(cachemode有writeback和writethrough两种模式,默认为writethrough)
lvconvert --type cache --cachepool vg/cache --cachemode writeback vg/data
注:writeback会在写入cache完成后,再写入date中
    writethrough会在写入cache的同时,写入date(写入date慢于cache)
    两种模式比较下writeback在使用过程中写入加速,但如果数据在缓存层中服务器掉电数据会丢失(现在已解决丢失问题,未研究)
    writethrough写入较慢,但数据不易丢失


 创建完成。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多