LXCでテストシステムを設定し、Webサーバーをインストールするなど問題はありませんでした。しかし、今私は別のホストシステムに切り替えたいと思い、/var/lib/lxc/webserverを圧縮して別のホストにコピーしました。しかし、いくつかのエラーが発生します。
lxc-start: failed to attach 'vethO5HJ2b' to the bridge 'lxcbr0' : No such device
lxc-start: failed to create netdev
lxc-start: failed to create the network
lxc-start: failed to spawn 'webserver'
構成でネットワーク設定が見つかりました。ネットワークの問題を解決したり、ホスト間の移行を終了したりするより良い方法についてのアイデアはありますか?
ifconfig-a
Host1(仮想マシンはここで動作しています)
eth0 Link encap:Ethernet Hardware Adresse 00:25:90:d2:c2:d6
inet Adresse:85.xxx.xxx.43 Bcast:85.xxx.xxx.43 Maske:255.255.255.255
inet6-Adresse: fe80::225:90ff:fed2:c2d6/64 Gültigkeitsbereich:Verbindung
UP BROADCAST RUNNING MULTICAST MTU:1500 Metrik:1
RX packets:186831047 errors:0 dropped:0 overruns:0 frame:0
TX packets:170397357 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:1000
RX-Bytes:14641876568 (14.6 GB) TX-Bytes:32363758586 (32.3 GB)
Speicher:f7100000-f7180000
eth0:1 Link encap:Ethernet Hardware Adresse 00:25:90:d2:c2:d6
inet Adresse:81.xxx.xxx.247 Bcast:81.xxx.xxx.255 Maske:255.255.255.255
UP BROADCAST RUNNING MULTICAST MTU:1500 Metrik:1
Speicher:f7100000-f7180000
eth1 Link encap:Ethernet Hardware Adresse 00:25:90:d2:c2:d7
BROADCAST MULTICAST MTU:1500 Metrik:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:1000
RX-Bytes:0 (0.0 B) TX-Bytes:0 (0.0 B)
Interrupt:20 Speicher:f7200000-f7220000
lo Link encap:Lokale Schleife
inet Adresse:127.0.0.1 Maske:255.0.0.0
inet6-Adresse: ::1/128 Gültigkeitsbereich:Maschine
UP LOOPBACK RUNNING MTU:65536 Metrik:1
RX packets:22574 errors:0 dropped:0 overruns:0 frame:0
TX packets:22574 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:0
RX-Bytes:4393152 (4.3 MB) TX-Bytes:4393152 (4.3 MB)
lxcbr0 Link encap:Ethernet Hardware Adresse ee:2c:00:bf:f0:a9
inet Adresse:10.0.3.1 Bcast:10.0.3.255 Maske:255.255.255.0
inet6-Adresse: fe80::ec2c:ff:febf:f0a9/64 Gültigkeitsbereich:Verbindung
UP BROADCAST RUNNING MULTICAST MTU:1500 Metrik:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:0
RX-Bytes:0 (0.0 B) TX-Bytes:468 (468.0 B)
bridge name bridge id STP enabled interfaces
lxcbr0 8000.000000000000 no
ls: Zugriff auf /var/log/upstart/lxc* nicht möglich: Datei oder Verzeichnis nicht gefunden (in English, not found)
$ brctl show
bridge name bridge id STP enabled interfaces
lxcbr0 8000.000000000000 no
minecraft@h2210663:~$ ls -l /var/log/upstart/lxc*
ls: Zugriff auf /var/log/upstart/lxc* nicht möglich: Datei oder Verzeichnis nicht gefunden
minecraft@h2210663:~$ cat /etc/default/lxc
# MIRROR to be used by ubuntu template at container creation:
# Leaving it undefined is fine
#MIRROR="http://archive.ubuntu.com/ubuntu"
# or
#MIRROR="http://<host-ip-addr>:3142/archive.ubuntu.com/ubuntu"
# LXC_AUTO - whether or not to start containers symlinked under
# /etc/lxc/auto
LXC_AUTO="true"
# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your
# containers. Set to "false" if you'll use virbr0 or another existing
# bridge, or mavlan to your host's NIC.
USE_LXC_BRIDGE="true"
# If you change the LXC_BRIDGE to something other than lxcbr0, then
# you will also need to update your /etc/lxc/default.conf as well as the
# configuration (/var/lib/lxc/<container>/config) for any containers
# already created using the default config to reflect the new bridge
# name.
# If you have the dnsmasq daemon installed, you'll also have to update
# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon.
LXC_BRIDGE="lxcbr0"
LXC_ADDR="10.0.3.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="10.0.3.0/24"
LXC_DHCP_RANGE="10.0.3.2,10.0.3.254"
LXC_DHCP_MAX="253"
LXC_SHUTDOWN_TIMEOUT=120
$ cat /etc/init/lxc-net.conf
description "lxc network"
author "Serge Hallyn <[email protected]>"
start on starting lxc
stop on stopped lxc
env USE_LXC_BRIDGE="false"
env LXC_BRIDGE="lxcbr0"
env LXC_ADDR="10.0.3.1"
env LXC_NETMASK="255.255.255.0"
env LXC_NETWORK="10.0.3.0/24"
env LXC_DHCP_RANGE="10.0.3.2,10.0.3.254"
env LXC_DHCP_MAX="253"
env varrun="/var/run/lxc"
pre-start script
[ -f /etc/default/lxc ] && . /etc/default/lxc
[ "x$USE_LXC_BRIDGE" = "xtrue" ] || { stop; exit 0; }
cleanup() {
# dnsmasq failed to start, clean up the bridge
iptables -t nat -D POSTROUTING -s ${LXC_NETWORK} ! -d ${LXC_NETWORK} -j MASQUERADE || true
ifconfig ${LXC_BRIDGE} down || true
brctl delbr ${LXC_BRIDGE} || true
}
if [ -d /sys/class/net/${LXC_BRIDGE} ]; then
if [ ! -f ${varrun}/network_up ]; then
# bridge exists, but we didn't start it
stop;
fi
exit 0;
fi
# set up the lxc network
echo 1 > /proc/sys/net/ipv4/ip_forward
mkdir -p ${varrun}
brctl addbr ${LXC_BRIDGE}
ifconfig ${LXC_BRIDGE} ${LXC_ADDR} netmask ${LXC_NETMASK} up
iptables -t nat -A POSTROUTING -s ${LXC_NETWORK} ! -d ${LXC_NETWORK} -j MASQUERADE
dnsmasq -u lxc-dnsmasq --strict-order --bind-interfaces --pid-file=${varrun}/dnsmasq.pid --conf-file= --listen-address ${LXC_ADDR} --dhcp-range ${LXC_DHCP_RANGE} --dhcp-lease-max=${LXC_DHCP_MAX} --dhcp-no-override --except-interface=lo --interface=${LXC_BRIDGE} --dhcp-leasefile=/var/lib/misc/dnsmasq.${LXC_BRIDGE}.leases --dhcp-authoritative || cleanup
touch ${varrun}/network_up
end script
post-stop script
[ -f /etc/default/lxc ] && . /etc/default/lxc
[ -f "${varrun}/network_up" ] || exit 0;
# if $LXC_BRIDGE has attached interfaces, don't shut it down
ls /sys/class/net/${LXC_BRIDGE}/brif/* > /dev/null 2>&1 && exit 0;
if [ -d /sys/class/net/${LXC_BRIDGE} ]; then
ifconfig ${LXC_BRIDGE} down
iptables -t nat -D POSTROUTING -s ${LXC_NETWORK} ! -d ${LXC_NETWORK} -j MASQUERADE || true
pid=`cat ${varrun}/dnsmasq.pid 2>/dev/null` && kill -9 $pid || true
rm -f ${varrun}/dnsmasq.pid
brctl delbr ${LXC_BRIDGE}
fi
rm -f ${varrun}/network_up
end script
ホスト2(対象)
eth0 Link encap:Ethernet Hardware Adresse 00:25:90:ae:09:6a
inet Adresse:2xx.xx4.xxx.217 Bcast:2xx.xx4.xxx.255 Maske:255.255.255.192
inet6-Adresse: fe80::225:90ff:feae:96a/64 Gültigkeitsbereich:Verbindung
UP BROADCAST RUNNING MULTICAST MTU:1500 Metrik:1
RX packets:2876153658 errors:0 dropped:48779 overruns:0 frame:0
TX packets:2680725017 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:1000
RX bytes:234344379020 (218.2 GiB) TX bytes:710758489234 (661.9 GiB)
Interrupt:16 Speicher:df900000-df920000
eth0:1 Link encap:Ethernet Hardware Adresse 00:25:90:ae:09:6a
inet Adresse:2xx.xx4.xxx.252 Bcast:2xx.xx4.xxx.255 Maske:255.255.255.192
UP BROADCAST RUNNING MULTICAST MTU:1500 Metrik:1
Interrupt:16 Speicher:df900000-df920000
eth1 Link encap:Ethernet Hardware Adresse 00:25:90:ae:09:6b
BROADCAST MULTICAST MTU:1500 Metrik:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:20 Speicher:dfa00000-dfa20000
lo Link encap:Lokale Schleife
inet Adresse:127.0.0.1 Maske:255.0.0.0
inet6-Adresse: ::1/128 Gültigkeitsbereich:Maschine
UP LOOPBACK RUNNING MTU:16436 Metrik:1
RX packets:738956166 errors:0 dropped:0 overruns:0 frame:0
TX packets:738956166 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:0
RX bytes:65605834297 (61.1 GiB) TX bytes:65605834297 (61.1 GiB)
$ brctl show
bridge name bridge id STP enabled interfaces
$ ls: Zugriff auf /var/log/upstart/lxc* nicht möglich: Datei oder Verzeichnis nicht gefunden (in English, not found)
$ cat /etc/default/lxc
# /etc/default/lxc
LXC_AUTO="true"
LXC_DIRECTORY="/ssd/lib/lxc"
$ cat /etc/init/lxc-net.conf
cat: /etc/init/lxc-net.conf: Datei oder Verzeichnis nicht gefunden (in English, not found)
答え1
受信したエラーによれば、2番目のホストにブリッジがありませんlxcbr0
。
考慮すべきその他の事項:
- また、コンテナを「移動」するためにどのような手順を実行しましたか?
- コンテナのファイルと.confファイルをコピーしましたか?
次のコマンドを使用して、2番目のホストでそのホストのコンテナを再作成しましたか?
$ lxc-create -t TEMPLATE -f lxc.conf -n CONTAINER
また、2 つのホスト間の次の点を比較し、2 つのシステム間のすべての設定が一貫していることを確認します。両方のホストで次のコマンドを使用します。
$ ifconfig -a $ brctl show $ ls -l /var/log/upstart/lxc* $ cat /etc/default/lxc $ cat /etc/init/lxc-net.conf