http://docs.openstack.org/user-guide/cli_nova_launch_instance_from_volume.html

http://docs.openstack.org/admin-guide-cloud/blockstorage-manage-volumes.html

Manage volumes

Volume-backed image

从image创建volume,当dirvier的volume clone快的话,性能要比其他store如file/swift好。

1 设置cinder为glance的存储后端:

glance_store section of the glance-api.conf file:

stores = file, http, swift, cinder

2显示 locations information

DEFAULT section of theglance-api.conf file:

show_multiple_locations = True

3 To enable the Block Storage services to create a new volume by cloning Image- Volume

DEFAULT section of the cinder.conf file. For example:

glance_api_version = 2

allowed_direct_url_schemes = cinder

4,让cinder upload-to-image来从image-Volume创建一个volume

back-end section of the cinder.conf file:

image_upload_use_cinder_backend = True

Creating a Volume-backed image

注册volume为 new Volume-backed image

$ glance image-create --disk-format raw --container-format bare --name <name>

$ glance location-add <image-uuid> --url cinder://<volume-uuid>

必须是raw和bare否则就存早glance的默认store中。

Note

Currently, the cinder store of the Image services does not support uploading and downloading of image data. By this limitation, Volume-backed images can only be used to create a new volume.

以cinder作为store的glance不支持image的upload/download,仅仅支持创建一个新volume。

Configure and use volume number weigher

http://docs.openstack.org/admin-guide-cloud/blockstorage_volume_number_weigher.html

cinder scheduler是根据free_capacity and allocated_capacity

但也可以volume 数量:

set the scheduler_default_weighers toVolumeNumberWeigher flag in the cinder.conf file

实例:

创建2个lvm backend,

在创建一个lvm type:

Define a volume type in Block Storage:

$ cinder type-create lvm

Create an extra specification that links the volume type to a back-end name:

$ cinder type-key lvm set volume_backend_name=LVM

创建6个1g的volume

$ cinder create --volume-type lvm 1

6个volume各自3个分布在2个backend上。

Migrate volumes

http://docs.openstack.org/admin-guide-cloud/blockstorage_volume_migration.html

cinder可以多个back-ends之前迁移volumes

流程如下:

  1. 如果storage可以自己migrate the volume,那它自己做,否则
  2. 2.       如果not attached, the Block Storage service创建一个volume并copy数据

 Note

While most back-ends support this function, not all do. See the driver documentation in the OpenStack Configuration Reference for more details.

  1. 如果 volume is attached, the Block Storage创建一个volume并calls Compute copy数据. 目前仅仅支持Compute libvirt driver.

以下例子中,2个back end,采用方案3.

# cinder get-pools

Note

Only Block Storage V2 API supports get-pools.

或者

# cinder-manage host list
server1@lvmstorage-1    zone1
server2@lvmstorage-2    zone1
$ cinder show 6088f80a-f116-4331-ad48-9afb0dfb196c
$ cinder migrate 6088f80a-f116-4331-ad48-9afb0dfb196c \
  server2@lvmstorage-2#lvmstorage-2

cinder show来查看迁移状态

 Note

Migrating volumes that have snapshots are currently not allowed.

Back up Block Storage service disks

使用LVM snapshot来创建 snapshots时,也可以用它来back up 你的volumes。使用LVM snapshot,你可以减少backup的size,它仅仅backup存在的数据而不是整个的volume。

Backup时volume不能被使用,必须数据都flush到guest文件系统,通常要求文件系统被unmounted,snapshot完成之后在mounted。

下面例子中,100 GB volume named volume-00000001只有4 GB 数据。se commands to back up only those 4 GB:

  • lvm2 command. Directly manipulates the volumes.
  • kpartx command. Discovers the partition table created inside the instance.
  • tar command. Creates a minimum-sized backup.
  • sha1sum command. Calculates the backup checksum to check its consistency.

You can apply this process to volumes of any size.

To back up Block Storage service disks

  1. Create a snapshot of a used volume
  • Use this command to list all volumes
o    # lvdisplay
o    # lvcreate --size 10G --snapshot --name volume-00000001-snapshot \
o      /dev/cinder-volumes/volume-00000001

The --sizeparameter defines the space that LVM reserves for the snapshot volume.

  • Run the lvdisplay command again to verify the snapshot:
o    --- Logical volume ---
o    LV Name                /dev/cinder-volumes/volume-00000001
o    VG Name                cinder-volumes
o    LV UUID                gI8hta-p21U-IW2q-hRN1-nTzN-UC2G-dKbdKr
o    LV Write Access        read/write
o    LV snapshot status     source of
o                     /dev/cinder-volumes/volume-00000026-snap [active]
o    LV Status              available
o    # open                 1
o    LV Size                15,00 GiB
o    Current LE             3840
o    Segments               1
o    Allocation             inherit
o    Read ahead sectors     auto
o    - currently set to     256
o    Block device           251:13
o     
o    --- Logical volume ---
o    LV Name                /dev/cinder-volumes/volume-00000001-snap
o    VG Name                cinder-volumes
o    LV UUID                HlW3Ep-g5I8-KGQb-IRvi-IRYU-lIKe-wE9zYr
o    LV Write Access        read/write
o    LV snapshot status     active destination for /dev/cinder-volumes/volume-00000026
o    LV Status              available
o    # open                 0
o    LV Size                15,00 GiB
o    Current LE             3840
o    COW-table size         10,00 GiB
o    COW-table LE           2560
o    Allocated to snapshot  0,00%
o    Snapshot chunk size    4,00 KiB
o    Segments               1
o    Allocation             inherit
o    Read ahead sectors     auto
o    - currently set to     256
o    Block device           251:14
  1. Partition table discovery

为了tar 打包snapshot,使用kpartx 发现分区

o    $ ls /dev/mapper/nova*

可以看见 cinder--volumes-volume--00000001--snapshot1 partition.,如果volume上有多个分区还可以看见: cinder--volumes-volume--00000001--snapshot2, cinder--volumes-volume--00000001--snapshot3, and so on.

  • Mount your partition
o    # mount /dev/mapper/cinder--volumes-volume--volume--00000001--snapshot1 /mnt
  1. Use the tar command to create archives

Create a backup of the volume:

$ tar --exclude="lost+found" --exclude="some/data/to/exclude" -czf \
  volume-00000001.tar.gz -C /mnt/ /backup/destination

只会打包已有的数据

  1. Checksum calculation I
  2. After work cleaning
$ sha1sum volume-00000001.tar.gz > volume-00000001.checksum
  • Unmount the volume:
  • Delete the partition table:
  • Remove the snapshot:
o    $ umount /mnt
o    $ kpartx -dv /dev/cinder-volumes/volume-00000001-snapshot
o    $ lvremove -f /dev/cinder-volumes/volume-00000001-snapshot

Repeat these steps for all your volumes.

  1. Automate your backups
    可以用这个script来自动backup

https://github.com/Razique/BashStuff/blob/master/SYSTEMS/OpenStack/SCR_5005_V01_NUAC-OPENSTACK-EBS-volumes-backup.sh

和cinder backup的关系:

这里是backup cinder 服务的disks

下面backup volumes:

Back up and restore volumes

$
cinder backup-create [--incremental] [--force] VOLUME

Volume在使用中需要force flag

The incremental and force flags are only available for block storage
API v2.

The force flag is new in OpenStack Liberty.

The incremental backup is based on a parent backup。

第一次backup必须是full backup。

$
cinder backup-restore BACKUP_ID

Because volume backups are dependent on the Block Storage
database, you must also back up your Block Storage database regularly to ensure
data recovery.

DB也需要定期backup来保存backup metadata

如果只想backup 特定的一些可以you can export
and save the metadata of selected volume backups

Backup 后端默认的是swift ,可以配置NFS:

backup_driver = cinder.backup.drivers.nfs

backup_share = HOST:EXPORT_PATH

backup_compression_algorithm = zlib

backup_sha_block_size_bytes = 32768

backup_file_size = 1999994880

Export and import backup metadata

http://docs.openstack.org/admin-guide-cloud/blockstorage_volume_backups_export_import.html

$
cinder backup-export BACKUP_ID

$
cinder backup-import METADATA

Use LIO iSCSI support

The
default mode for the iscsi_helper tool is tgtadm. To use LIO iSCSI, install the python-rtslib package, and set iscsi_helper=lioadm in the cinder.conf file.

Once
configured, you can use the cinder-rtstool command to manage the
volumes. This command enables you to create, delete, and verify volumes and
determine targets and add iSCSI initiators to the system.

Consistency groups

http://docs.openstack.org/admin-guide-cloud/blockstorage-consistency-groups.html

用来支持group snapshot

A consistency group can only contain volumes hosted by the
same back end.

Create a
consistency group
:

cinder
consisgroup-create

[--name
name]

[--description
description]

[--availability-zone
availability-zone]

volume-types

Create a volume and add it to a consistency group:

Create a
snapshot for a consistency group
:

$
cinder cgsnapshot-create 1de80c27-3b2f-47a6-91a7-e867cbe36462

当一个volume在一个sg中,不支持一下操作:

  • Volume
    migration.
  • Volume
    retype.
  • Volume
    deletion.

Oversubscription in thin provisioning

http://docs.openstack.org/admin-guide-cloud/blockstorage_over_subscription.html

Configure an NFS storage back end

http://docs.openstack.org/admin-guide-cloud/blockstorage_nfs_backend.html

NFS如何提供block volume:

cinder.volume.drivers.nfs.NfsDriver

def _create_sparsed_file(self,
path, size):

"""Creates file with 0 disk usage."""

self._execute('truncate', '-s', '%sG' % size,

path, run_as_root=True)

def _create_regular_file(self,
path, size):

"""Creates regular file of given size. Takes a lot of time
for large

        files.

        """

block_size_mb = 1

block_count = size * units.GiB /
(block_size_mb * units.MiB)

self._execute('dd', 'if=/dev/zero',
'of=%s'
% path,

'bs=%dM'
% block_size_mb,

'count=%d' % block_count,

run_as_root=True)

volume image的更多相关文章

  1. Java中实现SAX解析xml文件到MySQL数据库

    大致步骤: 1.Java bean 2.DBHelper.java 3.重写DefaultHandler中的方法:MyHander.java 4.循环写数据库:SAXParserDemo.java ① ...

  2. CSharpGL(8)使用3D纹理渲染体数据 (Volume Rendering) 初探

    CSharpGL(8)使用3D纹理渲染体数据 (Volume Rendering) 初探 2016-08-13 由于CSharpGL一直在更新,现在这个教程已经不适用最新的代码了.CSharpGL源码 ...

  3. 理解Docker(8):Docker 存储之卷(Volume)

    (1)Docker 安装及基本用法 (2)Docker 镜像 (3)Docker 容器的隔离性 - 使用 Linux namespace 隔离容器的运行环境 (4)Docker 容器的隔离性 - 使用 ...

  4. Docker Volume 之权限管理(转)

    Volume数据卷是Docker的一个重要概念.数据卷是可供一个或多个容器使用的特殊目录,可以为容器应用存储提供有价值的特性: 持久化数据与容器的生命周期解耦:在容器删除之后数据卷中的内容可以保持.D ...

  5. NFS Volume Provider(Part III) - 每天5分钟玩转 OpenStack(64)

    今天我们将前一小节创建的 NFS volume “nfs-vol-1” attach 到 instance “c2”上. 这里我们重点关注 nova-compute 如何将“nfs-vol-1” at ...

  6. NFS Volume Provider(Part II) - 每天5分钟玩转 OpenStack(63)

    上一节我们将 NFS volume provider 配置就绪,本节将创建 volume. 创建 volume 创建 NFS volume 操作方法与 LVM volume 一样,唯一区别是在 vol ...

  7. NFS Volume Provider(Part I) - 每天5分钟玩转 OpenStack(62)

    cinder-volume 支持多种 volume provider,前面我们一直使用的是默认的 LVM,本节我们将增加 NFS volume provider. 虽然 NFS 更多地应用在实验或小规 ...

  8. Boot from Volume - 每天5分钟玩转 OpenStack(61)

    Volume 除了可以用作 instance 的数据盘,也可以作为启动盘(Bootable Volume),那么如何使 volume 成为 bootable 呢? 现在我们打开 instance 的 ...

  9. Restore Volume 操作 - 每天5分钟玩转 OpenStack(60)

    前面我们 backup 了 voluem,今天我们将讨论如何 restore volume. restore 的过程其实很简单,两步走: 在存储节点上创建一个空白 volume. 将 backup 的 ...

  10. Backup Volume 操作 - 每天5分钟玩转 OpenStack(59)

    本节我们讨论 volume 的 Backup 操作. Backup 是将 volume 备份到别的地方(备份设备),将来可以通过 restore 操作恢复. Backup VS Snapshot 初看 ...

随机推荐

  1. iframe脸面的页面和父页面之间的交互方法

    1.iframe父页面修改iframe中的页面的信息 var obj = document.getElementById("iframeId").contentWindow;   ...

  2. 【转】在服务器上排除问题的头五分钟&常用命令

    转自:https://blog.csdn.net/l821133235/article/details/80103106(在服务器上排除问题的头五分钟) 遇到服务器故障,问题出现的原因很少可以一下就想 ...

  3. GBK和UTF-8文字编码的区别

    UTF-8是一种国际化标准的文字编码,我们已知Windows系统程序已经将最初的UTF-8转向Unicode,而GBK的存在是为了中国国情而创造的,不过GBK也将伴随着中文字符的一直流传下去. GBK ...

  4. Java中volatile关键字实现原理

    原文地址http://www.cnblogs.com/xrq730/p/7048693.html,转载请注明出处,谢谢 前言 我们知道volatile关键字的作用是保证变量在多线程之间的可见性,它是j ...

  5. 前端框架之jQuery

    一 iQuery是什么 jQuery由美国人John Resig创建,至今已吸引了来自世界各地的众多 javascript高手加入其team jQuery是继prototype之后又一个优秀的Java ...

  6. 笔画宽度变化(C++和matlab算法)

    最近一直在看工作方面的书籍,把论文的事情搁置了,之前承诺的贴代码的事一直拖.现在把代码整理发上来,只有核心部分的,都不是我写的,我是网上整理下载的,matlab代码的效果比较差. 全部文件网盘下载地址 ...

  7. cn_office_professional_plus_2010_x86_515 安装激活方法解决方案64bit

    一:首先选择 Office 2010 Toolkit.exe 右键 选择属性 –兼容性 然后 选择以管理员身份运行此程序  然后 双击 Office 2010 Toolkit.exe 需要安装的工具及 ...

  8. 和openjdk在一起的第一天-第一次接触有些生疏,就先熟悉一下吧

    暂时搞到了openjdk7,就将就着看吧,(为什么csdn全部都是收费啊,llllj),但是还是决定先读这个openjdk7 还有,不知道怎么的就想试试markdown,也不知道好用不 hello w ...

  9. python之路 正则表达式,模块导入的方法,hashlib加密

    一.正则表达式re python中re模块提供了正则表达式相关操作 字符: . 匹配除换行符以外的任意字符 \w 匹配字母或数字或下划线或汉字 \s 匹配任意的空白符 \d 匹配数字 \b 匹配单词的 ...

  10. b和strong,i与em的区别

    html语义化标签: 1)title与h1的区别 title与H1是不能划等号的 1.H1是大标题的意思.一般出现网页文章页面,作用如同一张报纸的大标题,使用读者在没看内容之前就 大概了解本文的旨意, ...