**作者:张华 发表于:2016-08-05
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明
http://blog.csdn.net/quqi99 )**
sudo apt install juju lxd zfsutils-linux bridge-utils squid-deb-proxy python-novaclient python-keystoneclient python-glanceclient python-neutronclient python-openstackclient
sudo systemctl enable lxd
sudo systemctl status lxd
$ 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)? yes
Address to bind LXD to (not including port): 10.0.8.1
Port to bind LXD to (8443 recommended): 8443
Trust password for new clients:
Again:
Do you want to configure the LXD bridge (yes/no)? yes
$ sudo lxc info
apicompat: 0
auth: trusted
environment:
addresses:
- 10.0.8.1:8443
architectures:
- x86_64
- i686
certificate: |
-----BEGIN CERTIFICATE-----
MIIHBjCCBO6gAwIBAgIQfTB6XIM79aFWlO7b9Arp+jANBgkqhkiG9w0BAQsFADA1
MRwwGgYDVQQKExNsaW51eGNvbnRhaW5lcnMub3JnMRUwEwYDVQQDDAxyb290QGRl
c2t0b3AwHhcNMTYwODA1MDYyMzA1WhcNMjYwODAzMDYyMzA1WjA1MRwwGgYDVQQK
ExNsaW51eGNvbnRhaW5lcnMub3JnMRUwEwYDVQQDDAxyb290QGRlc2t0b3AwggIi
MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC7UH/IkE93dRi/Vivbaxmkq+dA
BFKAj9wsbsq4EC7QvlKzII0zqz7Ptqty79QT7TvZvoa0nupf/8wWdNP5PQDiQlkJ
Yd1fyBDovoFq5uDdpJIaobxyVNnAQNlOjiZ9C8gu52St3nKCxG7AjmhU7XfMHjlw
j7NdwoGtOz/18vJXnCmbP8JCaSZrvUaSFYjryJBy2vL1bD9aimxmzA8JJEgfsCqD
BpVKUdWzzcwL6+m3cITC+ULN81L3k4OJ1aam60c+UJ2YOK1myWQbTsEa9d9K1SEO
yxCSwYbXWN6bBB4AM6JHvfZDtYH+WRxZ1EKZPUI6mGXqj4te+AgZgzl2yEqab6Lw
5xs6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y82NIIKZmU4MDo6MS82NDANBgkqhkiG9w0BAQsFAAOCAgEAHupq+OjB
mNKgf8F1c8N62LnkZfJK916uPTv6GLWgvMmJ6RVB49hRzXmCuWsVfn0QbHogDdn5
h2w6Bm+T5UbhQxzR9LesIohqD/w9TXRehGneBoxM2CRaOvS1FCtV9aL+s2q4vVPl
LA98ugKaz12Tiv4+oUzRfDFASjeixKSOcrHmId8LMMr5zV6KCVdiaLqXH61WuQ8u
OHR90mNIHczY8VEnAumT4+RKypKxmmo8p2qj9r+2NdRNV9KzL4scOdCIVQDq5Ct9
QkXwtr1ZMxbOVjK56pkqI9LyJ0rzE/u53hmVgEI/HecqlUOmZarWXAZDZhEeqFDz
p7MHT/PhHJeVsSVD551+Wh6/oPpgwo1HxAwA/5CUiXNXgplsGhOVyId7Zd3Ifr20
jwazGJMfbfBNoQS/kL5LH66aGqIFf2d2DLlF0BEEIFwB8543K8hCWiinU2bT4bzt
e0/17bF7Ld3JesDn0N2GwvlKV/V9J3o2JyI3e7TqG0gi3Hz5YNphFtjTYSkX+Dgc
EJoxLzN4S1yhUd36qBO7xlrufM+ugaNtbSWpVGoBb+sabRa/86EbDgCPrssLN8NY
21R6XZsFkC/HlJRXeXZlCbqk8b7tYySxTg5vKX8nHnkueyWej7vJsqxxAg2+58rG
7AbxWCqhLyTxAx9Gqb50sp9+xbW4e2DjM/A=
-----END CERTIFICATE-----
certificatefingerprint: 592080444e718a5a7e9d53fe36a87d2e220d8f181cad9c69eae872cfee5907c4
driver: lxc
driverversion: 2.0.3
kernel: Linux
kernelarchitecture: x86_64
kernelversion: 4.4.0-31-generic
server: lxd
serverpid: 26909
serverversion: 2.0.3
storage: dir
storageversion: ""
config:
core.https_address: 10.0.8.1:8443
core.trust_password: true
public: false
$ 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
上面的命令会自动调用下列命令配置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}"
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 1500 qdisc noqueue state UP group default qlen 1000
inet 10.0.8.129/24 brd 10.0.8.255 scope global eth0