LXC로 테스트 시스템을 설정하고, 웹서버를 설치하는 등 문제가 없었습니다. 하지만 이제 다른 호스트 시스템으로 전환하고 싶고 /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
받은 오류에 따르면 두 번째 호스트에 브리지가 누락된 것으로 보입니다 lxcbr0
.
고려해야 할 기타 사항:
- 또한 컨테이너를 "이동"하기 위해 어떤 단계를 수행했나요?
- 컨테이너의 파일과 .conf 파일을 복사하셨나요?
다음과 같은 명령을 사용하여 두 번째 호스트에서 해당 호스트의 컨테이너를 다시 생성하셨나요?
$ lxc-create -t TEMPLATE -f lxc.conf -n CONTAINER
또한 두 호스트 간의 다음 사항을 비교하고 두 시스템 간의 모든 설정이 일관되는지 확인합니다. 두 호스트 모두에서 다음 명령을 사용합니다.
$ ifconfig -a $ brctl show $ ls -l /var/log/upstart/lxc* $ cat /etc/default/lxc $ cat /etc/init/lxc-net.conf