mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-23 21:20:42 +08:00
translated
This commit is contained in:
parent
b2d168dd1a
commit
43dc75d166
@ -1,85 +0,0 @@
|
||||
translating---geekpi
|
||||
|
||||
Storage management in LXD 2.15
|
||||
============================================================
|
||||
|
||||
|
||||
### Share or save
|
||||
|
||||
![containers](https://cbrauner.files.wordpress.com/2017/07/containers.png?w=1008)
|
||||
|
||||
For a long time LXD has supported multiple storage drivers. Users could choose between zfs, btrfs, lvm, or plain directory storage pools but they could only ever use a single storage pool. A frequent feature request was to support not just a single storage pool but multiple storage pools. This way users would for example be able to maintain a zfs storage pool backed by an SSD to be used by very I/O intensive containers and another simple directory based storage pool for other containers. Luckily, this is now possible since LXD gained its own storage management API a few versions back.
|
||||
|
||||
### Creating storage pools
|
||||
|
||||
A new LXD installation comes without any storage pool defined. If you run `lxd init`LXD will offer to create a storage pool for you. The storage pool created by `lxd init`will be the default storage pool on which containers are created.
|
||||
|
||||
[![asciicast](https://asciinema.org/a/126892.png)][2]
|
||||
|
||||
### Creating further storage pools
|
||||
|
||||
Our client tool makes it really simple to create additional storage pools. In order to create and administer new storage pools you can use the `lxc storage` command. So if you wanted to create an additional btrfs storage pool on a block device `/dev/sdb`you would simply use `lxc storage create my-btrfs btrfs source=/dev/sdb`. But let’s take a look:
|
||||
|
||||
[![asciicast](https://asciinema.org/a/128580.png)][3]
|
||||
|
||||
### Creating containers on the default storage pool
|
||||
|
||||
If you started from a fresh install of LXD and created a storage pool via `lxd init` LXD will use this pool as the default storage pool. That means if you’re doing a `lxc launch images:ubuntu/xenial xen1` LXD will create a storage volume for the container’s root filesystem on this storage pool. In our examples we’ve been using `my-first-zfs-pool`as our default storage pool:
|
||||
|
||||
[![asciicast](https://asciinema.org/a/128582.png)][4]
|
||||
|
||||
### Creating containers on a specific storage pool
|
||||
|
||||
But you can also tell `lxc launch` and `lxc init` to create a container on a specific storage pool by simply passing the `-s` argument. For example, if you wanted to create a new container on the `my-btrfs` storage pool you would do `lxc launch images:ubuntu/xenial xen-on-my-btrfs -s my-btrfs`:
|
||||
|
||||
[![asciicast](https://asciinema.org/a/128583.png)][5]
|
||||
|
||||
### Creating custom storage volumes
|
||||
|
||||
If you need additional space for one of your containers to for example store additional data the new storage API will let you create storage volumes that can be attached to a container. This is as simple as doing `lxc storage volume create my-btrfs my-custom-volume`:
|
||||
|
||||
[![asciicast](https://asciinema.org/a/128584.png)][6]
|
||||
|
||||
### Attaching custom storage volumes to containers
|
||||
|
||||
Of course this feature is only helpful because the storage API let’s you attach those storage volume to containers. To attach a storage volume to a container you can use `lxc storage volume attach my-btrfs my-custom-volume xen1 data /opt/my/data`:
|
||||
|
||||
[![asciicast](https://asciinema.org/a/128585.png)][7]
|
||||
|
||||
### Sharing custom storage volumes between containers
|
||||
|
||||
By default LXD will make an attached storage volume writable by the container it is attached to. This means it will change the ownership of the storage volume to the container’s id mapping. But Storage volumes can also be attached to multiple containers at the same time. This is great for sharing data among multiple containers. However, this comes with a few restrictions. In order for a storage volume to be attached to multiple containers they must all share the same id mapping. Let’s create an additional container `xen-isolated` that has an isolated id mapping. This means its id mapping will be unique in this LXD instance such that no other container does have the same id mapping. Attaching the same storage volume `my-custom-volume` to this container will now fail:
|
||||
|
||||
[![asciicast](https://asciinema.org/a/128588.png)][8]
|
||||
|
||||
But let’s make `xen-isolated` have the same mapping as `xen1` and let’s also rename it to `xen2` to reflect that change. Now we can attach `my-custom-volume` to both `xen1` and `xen2` without a problem:
|
||||
|
||||
[![asciicast](https://asciinema.org/a/128593.png)][9]
|
||||
|
||||
### Summary
|
||||
|
||||
The storage API is a very powerful addition to LXD. It provides a set of essential features that are helpful in dealing with a variety of problems when using containers at scale. This short introducion hopefully gave you an impression on what you can do with it. There will be more to come in the future.
|
||||
|
||||
This blog was originally featured at [Brauner's Blog][10]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://insights.ubuntu.com/2017/07/12/storage-management-in-lxd-2-15/
|
||||
|
||||
作者:[Christian Brauner ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://cbrauner.wordpress.com/
|
||||
[1]:https://insights.ubuntu.com/author/christian-brauner/
|
||||
[2]:https://asciinema.org/a/126892
|
||||
[3]:https://asciinema.org/a/128580
|
||||
[4]:https://asciinema.org/a/128582
|
||||
[5]:https://asciinema.org/a/128583
|
||||
[6]:https://asciinema.org/a/128584
|
||||
[7]:https://asciinema.org/a/128585
|
||||
[8]:https://asciinema.org/a/128588
|
||||
[9]:https://asciinema.org/a/128593
|
||||
[10]:https://cbrauner.wordpress.com/
|
85
translated/tech/20170712 Storage management in LXD 2.15.md
Normal file
85
translated/tech/20170712 Storage management in LXD 2.15.md
Normal file
@ -0,0 +1,85 @@
|
||||
LXD 2.15 中的存储管理
|
||||
============================================================
|
||||
|
||||
|
||||
### 分享或保存
|
||||
|
||||
![containers](https://cbrauner.files.wordpress.com/2017/07/containers.png?w=1008)
|
||||
|
||||
长久以来 LXD 已经支持多种存储驱动。用户可以在 zfs、btrfs、lvm 或纯目录存储池之间进行选择,但它们只能使用单个存储池。一个被频繁被提到的需求是不仅支持单个存储池,还支持多个存储池。这样,用户可以维护一个由 SSD 支持的 zfs 存储池用于 I/O 密集型容器,另一个简单的基于目录的存储池用于其他容器。幸运的是,现在这是可能的,因为 LXD 在几个版本后有了自己的存储管理 API。
|
||||
|
||||
### 创建存储池
|
||||
|
||||
新安装 LXD 没有定义任何存储池。如果你运行 `lxd init` ,LXD 将提供为你创建一个存储池。由 `lxd init` 创建的存储池将是创建容器的默认存储池。
|
||||
|
||||
|
||||
[![asciicast](https://asciinema.org/a/126892.png)][2]
|
||||
|
||||
### 创建更多的存储池
|
||||
|
||||
我们的客户端工具使得创建额外的存储池变得非常简单。为了创建和管理新的存储池,你可以使用 `lxc storage` 命令。所以如果你想在块设备 `/dev/sdb` 上创建一个额外的 btrfs 存储池,你只需使用 `lxc storage create my-btrfs btrfs source=/dev/sdb`。让我们来看看:
|
||||
|
||||
[![asciicast](https://asciinema.org/a/128580.png)][3]
|
||||
|
||||
### 在默认存储池上创建容器
|
||||
|
||||
如果你从全新安装的 LXD 开始,并通过 `lxd init` 创建了一个存储池,LXD 将使用此池作为默认存储池。这意味着如果你执行 `lxc launch images:ubuntu/xenial xen1`,LXD 将为此存储池上的容器的根文件系统创建一个存储卷。在示例中,我们使用 `my-first-zfs-pool` 作为默认存储池
|
||||
|
||||
[![asciicast](https://asciinema.org/a/128582.png)][4]
|
||||
|
||||
### 在特定存储池上创建容器
|
||||
|
||||
但是你也可以通过传递 `-s` 参数来告诉 `lxc launch` 和 `lxc init` 在特定存储池上创建一个容器。例如,如果要在 `my-btrfs` 存储池上创建一个新的容器,你可以执行 `lxc launch images:ubuntu/xenial xen-on-my-btrfs -s my-btrfs`:
|
||||
|
||||
[![asciicast](https://asciinema.org/a/128583.png)][5]
|
||||
|
||||
### 创建自定义存储卷
|
||||
|
||||
如果你其中一个容器需要额外的空间存储额外的数据,那么新的存储 API 将允许你创建可以连接到容器的存储卷。只需要 `lxc storage volume create my-btrfs my-custom-volume`:
|
||||
|
||||
[![asciicast](https://asciinema.org/a/128584.png)][6]
|
||||
|
||||
### 连接自定义卷到容器中
|
||||
|
||||
Of course this feature is only helpful because the storage API let’s you attach those storage volume to containers. To attach a storage volume to a container you can use `lxc storage volume attach my-btrfs my-custom-volume xen1 data /opt/my/data`:
|
||||
当然,这个功能是有用的,因为存储 API 让你把这些存储卷连接到容器。要将存储卷连接到容器,可以使用 `lxc storage volume attach my-btrfs my-custom-volume xen1 data /opt/my/data`:
|
||||
|
||||
[![asciicast](https://asciinema.org/a/128585.png)][7]
|
||||
|
||||
### 在容器之间共享自定义存储卷
|
||||
|
||||
默认情况下,LXD 将使连接的存储卷由其所连接的容器写入。这意味着它会将存储卷的所有权更改为容器的 id 映射。但存储卷也可以同时连接到多个容器。这对于在多个容器之间共享数据是非常好的。但是,这有一些限制。为了将存储卷连接到多个容器,它们必须共享相同的 id 映射。让我们创建一个额外的具有一个隔离的 id 映射的容器 `xen-isolated`。这意味着它的 id 映射在这个 LXD 实例中将是唯一的,因此没有其他容器具有相同的id映射。将相同的存储卷 `my-custom-volume` 连接到此容器现在将会失败:
|
||||
|
||||
[![asciicast](https://asciinema.org/a/128588.png)][8]
|
||||
|
||||
但是我们让 `xen-isolated` 与 `xen1` 有相同的映射,并把它重命名为 `xen2` 来反映这个变化。现在我们可以将 `my-custom-volume` 连接到 `xen1` 和 `xen2` 而不会有问题:
|
||||
|
||||
[![asciicast](https://asciinema.org/a/128593.png)][9]
|
||||
|
||||
### 总结
|
||||
|
||||
存储 API 是 LXD 非常强大的补充。它提供了一组基本功能,有助于在大规模使用容器时处理各种问题。这个简短的介绍希望给你一个印象,你可以做什么。将来会有更多介绍。
|
||||
|
||||
本篇文章最初在[ Brauner 的博客][10]中发布。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://insights.ubuntu.com/2017/07/12/storage-management-in-lxd-2-15/
|
||||
|
||||
作者:[Christian Brauner ][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://cbrauner.wordpress.com/
|
||||
[1]:https://insights.ubuntu.com/author/christian-brauner/
|
||||
[2]:https://asciinema.org/a/126892
|
||||
[3]:https://asciinema.org/a/128580
|
||||
[4]:https://asciinema.org/a/128582
|
||||
[5]:https://asciinema.org/a/128583
|
||||
[6]:https://asciinema.org/a/128584
|
||||
[7]:https://asciinema.org/a/128585
|
||||
[8]:https://asciinema.org/a/128588
|
||||
[9]:https://asciinema.org/a/128593
|
||||
[10]:https://cbrauner.wordpress.com/
|
Loading…
Reference in New Issue
Block a user