将LXC迁移到LXD [英] migrating lxc to lxd

查看:357
本文介绍了将LXC迁移到LXD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看了很多遍,但是看不到有办法.我有几个在Ubuntu 14.04主机上运行Ubuntu 14.04的LXC容器.它们对我来说已经变得非常重要,因此,如果主机的硬件出现故障,我希望能够轻松地将LXC容器备份/迁移到另一台服务器.

I've looked all over, but can't see if there is a way. I have a couple LXC containers running Ubuntu 14.04 on top of a Ubuntu 14.04 Host. They've become pretty important to me, so I want to be able to easily backup / migrate the LXC containers to another server if the host's hardware should fail.

我现在已经使用LXD构建了新的Ubuntu 15.1服务器,并且已经注销并重新登录,然后看到了新的组.为了进行测试,我用14.04主机上的--numeric-owner开关将我现有的LXC容器之一装满了:

I've built a new Ubuntu 15.1 server now with LXD and have logged out and back in and see the new group. For testing, I tar'd one of my existing LXC containers up with the --numeric-owner switch on my 14.04 Host:

tar --numeric-owner -czvf ContToBeMoved.tgz /var/lib/lxc/my_container

---然后在新服务器上---

---then on new server ---

tar --numeric-owner -xzvf ContToBeMoved.tgz -C /var/lib/lxc/

...并且已成功在新服务器15.1服务器上还原了LXC容器.

...and have successfully restored the LXC container on the new server 15.1 server.

但是当我运行LXD命令时,LXD看不到容器.我尝试将容器移动到/var/lib/lxd/containers目录,但LXD看不到它.有没有一种方法可以编辑/克隆/迁移LXC容器,以便我们可以继续使用LXD?

When I run the LXD commands though, LXD doesn't see the container. I tried moving the container to the /var/lib/lxd/containers directory and still, LXD doesn't see it. Is there a way to edit / clone / migrate the LXC container so that we can use LXD moving forward?

谢谢.

推荐答案

LXD使用sqlite数据库进行容器配置,因此仅将容器的rootfs转储到位是不够的.

LXD uses a sqlite database for container configuration so just dumping the container's rootfs in place won't be quite enough.

最简单的方法是使用LXD创建一个新容器,然后从/var/lib/lxd/containers/NAME/rootfs中删除其rootfs,并从原始主机中替换它.

The easiest way to do what you want is to create a new container with LXD, then remove its rootfs from /var/lib/lxd/containers/NAME/rootfs and substitute the one from your original host.

请注意,默认情况下,LXD运行非特权容器,如果您的源容器具有特权(/var/lib/lxc/NAME/rootfs由root:root拥有,而不是100000:100000),那么您将需要运行也如下:

Note that LXD runs unprivileged containers by default, if your source container was privileged (/var/lib/lxc/NAME/rootfs is owned by root:root instead of 100000:100000), then you'll want to run the following too:

lxc config set NAME security.privileged true

这篇关于将LXC迁移到LXD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆