LXC: Unterschied zwischen den Versionen

Aus MK Wiki DE
Zur Navigation springen Zur Suche springen
K (6 Versionen importiert: Import von michigreat.a.wiki-site.com)
 
(Übersetzung von Englisch auf Deutsch: lxcbr0 disappears, Moving containers from one host to another)
Zeile 22: Zeile 22:
Lösung: Entweder dnsmasq zum Laufen bringen oder andere virtuelle Schnittstelle verwenden. In der "config"-Datei des Containers lautet die Einstellung dazu "lxc.network.link". Eventuell lässt sich virbr0 verwenden.
Lösung: Entweder dnsmasq zum Laufen bringen oder andere virtuelle Schnittstelle verwenden. In der "config"-Datei des Containers lautet die Einstellung dazu "lxc.network.link". Eventuell lässt sich virbr0 verwenden.


== lxcbr0 disappears ==
== lxcbr0 verschwindet ==


There might be a conflict with an existing DNS server. I use bind9 and this helps:
Möglicherweise gibt es einen Konflikt mit eimem bereits laufenden DNS Server. Ich habe bind9 am Laufen und Folgendes hilft:


  service bind9 stop
  service bind9 stop
Zeile 30: Zeile 30:
  service bind9 start
  service bind9 start


== Moving containers from one host to another ==
== Container von einem Host zu einem anderen verschieben ==


* In /var/lib/lxc, execute <code>tar -czf ''containername''.tar.gz containername</code>
* In /var/lib/lxc folgendes Kommando ausführen: <code>tar -czf ''containername''.tar.gz containername</code>
* Copy ''containername''.tar.gz from one machine to another (for example, using scp or wget)
* ''containername''.tar.gz von einem Host zu anderen kopieren (zum Beispiel mit scp oder wget)
* On the other machine move the file to /var/lib/lxc
* Auf dem Zielhost muss die Datei in /var/lib/lxc landen
* In /var/lib/lxc, execute <code>tar -xzf ''containername''.tar.gz</code>
* In /var/lib/lxc muss <code>tar -xzf ''containername''.tar.gz</code> ausgeführt werden
** Optional: remove the tar file by executing <code>rm ''containername''.tar.gz</code>
** Optional: tar-Datei mittels <code>rm ''containername''.tar.gz</code> entfernen
* Start container using <code>lxc-start -d -n ''containername''</code>
* Container mit <code>lxc-start -d -n ''containername''</code> starten
* Enter container using <code>lxc-attach -n ''containername''</code>
* In den Container mit <code>lxc-attach -n ''containername'' -- bash</code> einsteigen und dort eine Kommandozeile erhalten
* Verify that all services are running (for example, using <code>netstat -tulpn</code> or examing the outout of <code>systemctl status</code> (when using systemd) or <code>ps axf</code>)
* Prüfen, ob alle Dienste laufen (zum Beispiel mit <code>netstat -tulpn</code> oder die Ausgabe von <code>systemctl status</code> (wenn systemd zum Einsatz kommt) oder <code>ps axf</code> inspizieren)


=== Troubleshooting ===
=== Troubleshooting ===


Example: You had mysql installed, but after moving, the service refuses to start.
Beispiel: MySql ist installiert, aber nach dem Verschieben startet das Service nicht mehr.


In the original container, <code>ps axf | grep mysql</code> might print a line like this:
Im Originalcontainer könnte <code>ps axf | grep mysql</code> eine Zeile wie die folgende ausgeben:


   1531 ?        Sl    0:40  \_ /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
   1531 ?        Sl    0:40  \_ /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306


Execute that command on the copied container. It might print something like this:
Wird das selbe Kommando im verschobenen Container ausgeführt, könnte die Ausgabe wie folgt aussehen:


<pre>
<pre>
Zeile 72: Zeile 72:
</pre>
</pre>


If you execute <code>ls -lh ./var/lib/mysql/mysql/plugin.frm</code>, an output similar to that one might appear:
Wenn man <code>ls -lh ./var/lib/mysql/mysql/plugin.frm</code> ausführt könnte etwa folgende Ausgabe erscheinen:


  -rw-rw---- 1 106 110 8,4K Aug 14 09:28 ./var/lib/mysql/mysql/plugin.frm
  -rw-rw---- 1 106 110 8,4K Aug 14 09:28 ./var/lib/mysql/mysql/plugin.frm


* What's the problem? At the position that should show the owning user and owning group you see "106" and "110" instead.
* Was ist das Problem? An der Stelle, an der normalerweise der Besitzer und die besitzende Gruppe der Datei stehen, steht "106" und "110".
* How could that happen? The tar command was unable to correctly resolve the owner information. This is a common pitfall in Linux and other Unix-like systems: the user "mysql" can have another uid on every system (as <code>id -u mysql</code> would show). Furthermore, the system (the LXC host) that ran the tar command, did not have a user "mysql".
* Wie konnte das passieren? Das tar-Kommando konnte die Besitzerinformationen nicht richtig auflösen. Das ist eine bekannte Falle in Linux und anderen Unix-artigen Systemen: der Benutzer "mysql" könnte auf jedem System eine andere UID haben (<code>id -u mysql</code> zeigt die UID dazu an). Desweiteren wurde das tar-Kommando auf dem LXC host ausgeführt, welcher im vorliegenden Fall keinen Benutzer "mysql" hatte.


By "cd /", go to the file system's root directory and execute these commands:
Mit "cd /" wechselt man ins Root-Verzeichnis des Dateisystems und führt folgende Befehle aus:


  find -uid 106 -exec chown mysql {} \;
  find -uid 106 -exec chown mysql {} \;
  find -gid 110 -exec chgrp mysql {} \;
  find -gid 110 -exec chgrp mysql {} \;


If the above "ls" command printed other uid/gid values, replace as needed.
Wenn das obere ls-Kommando andere Werte als 106 und 110 ausgegeben hat müssen die Werte entsprechend ersetzt werden.


== Links ==
== Links ==

Version vom 28. Juni 2018, 18:04 Uhr

Verzeichnisse

  • Container: /var/lib/lxc
  • Cache für Systeminstallationen: /var/cache/lxc

Debian Container unter Ubuntu bis 14.10

Direkt nach dem Erstellen lässt sich der Container nicht starten. Es erscheint folgende Fehlermeldung:

Failed to mount cgroup at /sys/fs/cgroup/systemd: Permission denied

Fehlerbehebung: In der "config"-Datei des Containers (normalerweise /var/lib/lxc/CONTAINER/config) folgende Zeile eintragen:

lxc.aa_profile = unconfined

Credits

Container startet ohne IP-Adresse

Womöglich läuft dnsmasq auf der virtuellen Schnittstelle (Standard: lxcbr0) nicht.

Lösung: Entweder dnsmasq zum Laufen bringen oder andere virtuelle Schnittstelle verwenden. In der "config"-Datei des Containers lautet die Einstellung dazu "lxc.network.link". Eventuell lässt sich virbr0 verwenden.

lxcbr0 verschwindet

Möglicherweise gibt es einen Konflikt mit eimem bereits laufenden DNS Server. Ich habe bind9 am Laufen und Folgendes hilft:

service bind9 stop
service lxc-net restart
service bind9 start

Container von einem Host zu einem anderen verschieben

  • In /var/lib/lxc folgendes Kommando ausführen: tar -czf containername.tar.gz containername
  • containername.tar.gz von einem Host zu anderen kopieren (zum Beispiel mit scp oder wget)
  • Auf dem Zielhost muss die Datei in /var/lib/lxc landen
  • In /var/lib/lxc muss tar -xzf containername.tar.gz ausgeführt werden
    • Optional: tar-Datei mittels rm containername.tar.gz entfernen
  • Container mit lxc-start -d -n containername starten
  • In den Container mit lxc-attach -n containername -- bash einsteigen und dort eine Kommandozeile erhalten
  • Prüfen, ob alle Dienste laufen (zum Beispiel mit netstat -tulpn oder die Ausgabe von systemctl status (wenn systemd zum Einsatz kommt) oder ps axf inspizieren)

Troubleshooting

Beispiel: MySql ist installiert, aber nach dem Verschieben startet das Service nicht mehr.

Im Originalcontainer könnte ps axf | grep mysql eine Zeile wie die folgende ausgeben:

 1531 ?        Sl     0:40  \_ /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306

Wird das selbe Kommando im verschobenen Container ausgeführt, könnte die Ausgabe wie folgt aussehen:

171112 17:50:01 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
171112 17:50:01 [Note] /usr/sbin/mysqld (mysqld 5.5.57-0+deb7u1) starting as process 2140 ...
171112 17:50:01 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
171112 17:50:01 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
171112 17:50:01 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
171112 17:50:01 InnoDB: The InnoDB memory heap is disabled
171112 17:50:01 InnoDB: Mutexes and rw_locks use GCC atomic builtins
171112 17:50:01 InnoDB: Compressed tables use zlib 1.2.7
171112 17:50:01 InnoDB: Using Linux native AIO
171112 17:50:01 InnoDB: Initializing buffer pool, size = 128.0M
171112 17:50:01 InnoDB: Completed initialization of buffer pool
171112 17:50:01  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.

Wenn man ls -lh ./var/lib/mysql/mysql/plugin.frm ausführt könnte etwa folgende Ausgabe erscheinen:

-rw-rw---- 1 106 110 8,4K Aug 14 09:28 ./var/lib/mysql/mysql/plugin.frm
  • Was ist das Problem? An der Stelle, an der normalerweise der Besitzer und die besitzende Gruppe der Datei stehen, steht "106" und "110".
  • Wie konnte das passieren? Das tar-Kommando konnte die Besitzerinformationen nicht richtig auflösen. Das ist eine bekannte Falle in Linux und anderen Unix-artigen Systemen: der Benutzer "mysql" könnte auf jedem System eine andere UID haben (id -u mysql zeigt die UID dazu an). Desweiteren wurde das tar-Kommando auf dem LXC host ausgeführt, welcher im vorliegenden Fall keinen Benutzer "mysql" hatte.

Mit "cd /" wechselt man ins Root-Verzeichnis des Dateisystems und führt folgende Befehle aus:

find -uid 106 -exec chown mysql {} \;
find -gid 110 -exec chgrp mysql {} \;

Wenn das obere ls-Kommando andere Werte als 106 und 110 ausgegeben hat müssen die Werte entsprechend ersetzt werden.

Links