Play with LXD (by quqi99)

标签: lxd
1313人阅读 评论(0) 收藏 举报
分类:

**作者:张华 发表于:2016-08-05
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明
http://blog.csdn.net/quqi99 )**

安装LXD

sudo apt install juju lxd zfsutils-linux bridge-utils squid-deb-proxy python-novaclient python-keystoneclient python-glanceclient python-neutronclient python-openstackclient
sudo ln -s /images/lxd /var/lib/lxd/containers

sudo systemctl enable lxd
sudo systemctl start lxd
sudo systemctl status lxd
sudo systemctl --failed
sudo lxc profile device set default eth0 mtu 9000

$ sudo lxc info
$ sudo lxd init
Name of the storage backend to use (dir or zfs): dir
Would you like LXD to be available over the network (yes/no)? no
Do you want to configure the LXD bridge (yes/no)? yes
$ sudo lxc profile show default
name: default
config:
  environment.http_proxy: http://[fe80::1%eth0]:13128
  user.network_mode: link-local
description: Default LXD profile
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: lxdbr0
    type: nic

$ ps -ef|grep dnsmasq
lxd      28917     1  0 17:43 ?        00:00:00 dnsmasq -s lxd -S /lxd/ -u lxd --strict-order --bind-interfaces --pid-file=/run/lxd-bridge//dnsmasq.pid --dhcp-no-override --except-interface=lo --interface=lxdbr0 --dhcp-leasefile=/var/lib/lxd-bridge//dnsmasq.lxdbr0.leases --dhcp-authoritative --listen-address 10.0.8.1 --dhcp-range 10.0.8.2,10.0.8.200 --dhcp-lease-max=252

安装LXD中可能遇到的问题

上面的命令会自动调用下列命令配置lxdbr0,但是有时候出错时可以使用下列命令分步调试。

sudo dpkg-reconfigure lxd
cat /etc/default/lxd-bridge  #/usr/lib/lxd/lxd-bridge
sudo service lxd-bridge restart
sudo systemctl status lxd-bridge

配置lxd-bridge时出错比较多,首先会遇到这么一个错误“Unable to connect to Upstart”,那是因为ubuntu 16.04里同时安装了upstart与systemd,使用下列命令禁用upstart的启动方式,今后启动程序采用init.d或systemd的方式。

sudo dpkg-divert --local --rename --add /sbin/initctl
sudo ln -s /bin/true /sbin/initctl
#sudo apt-get --reinstall install upstart
#sudo dpkg-diver --local --remove /sbin/initctl
#sudo rm /sbin/initctl

另外一个是/var/log/syslog中报这种错误“Aug 5 17:02:54 localhost lxd-bridge.start[23556]: Error: ??? prefix is expected rather than “10.0.8.1/24/24”.”,这是采用sudo dpkg-reconfigure lxd命令生成的/etc/default/lxd-bridge文件中配置的下列LXD_IPV4_ADDR参数多出了/24。

## IPv4 address (e.g. 10.0.8.1)
LXD_IPV4_ADDR="10.0.8.1/24"

从而导致/usr/lib/lxd/lxd-bridge中的下列命令就会报上述错误。

ifup "${LXD_BRIDGE}" "${LXD_IPV4_ADDR}" "${LXD_IPV4_NETMASK}"

测试lxd

sudo lxc launch ubuntu:xenial test1
sudo lxc info --show-log test1
sudo lxc list
#sudo lxc delete test1 --force

sudo lxc exec test1 bash
root@test1:~# ip addr show eth0           
root@test1:~# cat /etc/resolv.conf 
nameserver 10.0.8.1
root@test1:~# ip addr show eth0 |grep eth0
265: eth0@if266: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc noqueue state UP group default qlen 1000
    inet 10.0.8.129/24 brd 10.0.8.255 scope global eth0

参考


  1. https://bayton.org/2016/05/lxd-zfs-and-bridged-networking-on-ubuntu-16-04-lts/
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1398618次
    • 积分:15862
    • 等级:
    • 排名:第662名
    • 原创:295篇
    • 转载:10篇
    • 译文:0篇
    • 评论:298条