ubuntu https://blog.werk21.de/de de Subnetz, Zusatz-IPs oder Failover-IPs mit netplan / systemd bei Hetzner konfigurieren (Ubuntu 18.04 / Xen) https://blog.werk21.de/de/2018/07/06/subnetz-zusatz-ips-oder-failover-ips-netplan-systemd-hetzner-konfigurieren-ubuntu-1804 <span>Subnetz, Zusatz-IPs oder Failover-IPs mit netplan / systemd bei Hetzner konfigurieren (Ubuntu 18.04 / Xen)</span> <span><span lang="" about="/de/user/15" typeof="schema:Person" property="schema:name" datatype="">kelly</span></span> <span><time datetime="2018-07-06T08:31:14+02:00" title="Freitag, 6. Juli 2018 - 08:31 Uhr">Fr., 06.07.2018 - 08:31 Uhr</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h2>Host-Konfiguration</h2> <p>Der Server unter Ubuntu 18.04 wird vom Hetzner-Script installimage mit netplan installiert (vorher mit systemd-network).</p> <h3>Netzwerk-Konfiguration</h3> <p>Für Zusatz-IPs, Subnetze oder Fail-Over-IP-Adressen ist keine Konfiguration des Hosts-System nötig, wenn diese Adressen von den Xen-Gästen verwendet werden sollen.</p> <h3>Routed Network</h3> <p>Bei Hetzner muss xen als routed network betrieben werden. Die entsprechenden Konfigurations-Dateien <strong>/etc/xen/xl.conf </strong>sind dahingehend anzupassen:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">vif<span style="color: #339933;">.</span><span style="color: #b1b100;">default</span><span style="color: #339933;">.</span>script<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;vif-route&quot;</span> vif<span style="color: #339933;">.</span><span style="color: #b1b100;">default</span><span style="color: #339933;">.</span>gatewaydev<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;eth0&quot;</span></pre></div> <p>Statt eth0 muss die Bezeichnung der Netzwerkkarte verwendet werden.</p> <p>Anschließend muss das Routing im System in der Datei <strong>/etc/sysctl.d/99-hetzner.conf </strong>aktiviert werden:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">net<span style="color: #339933;">.</span>ipv4<span style="color: #339933;">.</span>ip_forward<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span></pre></div> <p>Anschließend laden der Konfigurationen:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">sysctl <span style="color: #339933;">-</span>p <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>sysctl<span style="color: #339933;">.</span>conf</pre></div> <h2>Konfiguration virtueller Maschinen</h2> <p>Nach der Einrichtung mit xen-tools existiert keine funktionierende Netzwerk-Konfiguration. Über die xen-Konsole muss das Netzwerk eingerichtet werden.</p> <h3>Netzwerk</h3> <p>Netzwerk-Einstellungen in <strong>/etc/systemd/network/10-eth0.network</strong>:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>Match<span style="color: #009900;">&#93;</span> Name<span style="color: #339933;">=</span>eth0 &nbsp; <span style="color: #009900;">&#91;</span>Address<span style="color: #009900;">&#93;</span> Address<span style="color: #339933;">=</span>aaa<span style="color: #339933;">.</span>bbb<span style="color: #339933;">.</span>ccc<span style="color: #339933;">.</span>ddd Peer<span style="color: #339933;">=</span>AAA<span style="color: #339933;">.</span>BBB<span style="color: #339933;">.</span>CCC<span style="color: #339933;">.</span>DDD<span style="color: #339933;">/</span><span style="color: #cc66cc;">32</span> &nbsp; <span style="color: #009900;">&#91;</span>Route<span style="color: #009900;">&#93;</span> Gateway<span style="color: #339933;">=</span>AAA<span style="color: #339933;">.</span>BBB<span style="color: #339933;">.</span>CCC<span style="color: #339933;">.</span>DDD</pre></div> <ul><li>aaa.bbb.ccc.ddd IP-Adresse der VM</li> <li>AAA.BBB.CCC.DDD IP-Adresse des Host-Systems</li> </ul><p>Durch die Verwendung von Peer (was PointToPoint) entspricht, können alle IP-Adressen eines Subnetzes verwendet werden, da kein Routing im Subnetz benötigt wird.</p> <h4>Konfiguration laden</h4> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">systemctl enable systemd<span style="color: #339933;">-</span>networkd service systemd<span style="color: #339933;">-</span>networkd start ip route add <span style="color: #b1b100;">default</span> via AAA<span style="color: #339933;">.</span>BBB<span style="color: #339933;">.</span>CCC<span style="color: #339933;">.</span>DDD </pre></div> <ul><li>AAA.BBB.CCC.DDD IP-Adresse des Host-Systems</li> </ul><h3>Nameserver ohne systemd</h3> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">systemctl disable systemd<span style="color: #339933;">-</span>resolved<span style="color: #339933;">.</span>service systemctl stop systemd<span style="color: #339933;">-</span>resolved &nbsp; rm <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>resolv<span style="color: #339933;">.</span>conf &nbsp; cat <span style="color: #339933;">&lt;&lt;</span> EOF <span style="color: #339933;">&gt;</span> <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>resolv<span style="color: #339933;">.</span>conf nameserver 213<span style="color: #339933;">.</span>133<span style="color: #339933;">.</span>98<span style="color: #339933;">.</span>98 nameserver 213<span style="color: #339933;">.</span>133<span style="color: #339933;">.</span>100<span style="color: #339933;">.</span>100 nameserver 213<span style="color: #339933;">.</span>133<span style="color: #339933;">.</span>99<span style="color: #339933;">.</span>99 EOF &nbsp; service postfix restart</pre></div> <h3>Nameserver mit systemd</h3> <p>In Datei <strong>/etc/systemd/resolved.conf</strong> ergänzen:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">DNS<span style="color: #339933;">=</span>213<span style="color: #339933;">.</span>133<span style="color: #339933;">.</span>98<span style="color: #339933;">.</span>98 213<span style="color: #339933;">.</span>133<span style="color: #339933;">.</span>100<span style="color: #339933;">.</span>100 213<span style="color: #339933;">.</span>133<span style="color: #339933;">.</span>99<span style="color: #339933;">.</span>99</pre></div> <h4>Konfiguration laden</h4> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">service systemd<span style="color: #339933;">-</span>resolved restart</pre></div> <h4>Resolver-Status kontrollieren</h4> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">systemd<span style="color: #339933;">-</span>resolve <span style="color: #339933;">--</span>status</pre></div> <h3>Löschen /etc/network/interfaces</h3> <p>Die alte Konfiguration muss noch gelöscht werden, damit diese nicht später genutzt wird.</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">rm <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>network<span style="color: #339933;">/</span>interfaces</pre></div> <h3>Weitere IP-Adressen konfigurieren</h3> <p>Werden weitere IP-Adressen benötigt (z.B. eine zusätzliche Failover-IP), wird diese als weitere IP-Adresse in der Xen-Gast-Konfiguration hinterlegt:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">vif <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span> <span style="color: #0000ff;">'ip=aaa.bbb.ccc.ddd/32 eee.fff.ggg.hhh/32 iii.jjj.kkk.lll/32,mac=AA:AA:AA:AA:AA:AA'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#93;</span></pre></div> <p>Es empfiehlt sich, eine MAC-Adresse zu vergeben, um nach dem Neustart eines Gastes nicht mit dem arp-cache des Hosts in Konflikt zu geraten.</p> <p>Die IP-Adressen werden alle auf eth0 im Gast zur Verfügung gestellt.</p> <p>Die Konfiguration von eth0 muss entsprchend in <strong>/etc/systemd/network/10-eth0.network</strong> angepasst werden:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>Match<span style="color: #009900;">&#93;</span> Name<span style="color: #339933;">=</span>eth0 &nbsp; <span style="color: #009900;">&#91;</span>Address<span style="color: #009900;">&#93;</span> Address<span style="color: #339933;">=</span>aaa<span style="color: #339933;">.</span>bbb<span style="color: #339933;">.</span>ccc<span style="color: #339933;">.</span>ddd Peer<span style="color: #339933;">=</span>AAA<span style="color: #339933;">.</span>BBB<span style="color: #339933;">.</span>CCC<span style="color: #339933;">.</span>DDD<span style="color: #339933;">/</span><span style="color: #cc66cc;">32</span> &nbsp; <span style="color: #009900;">&#91;</span>Address<span style="color: #009900;">&#93;</span> Address<span style="color: #339933;">=</span>eee<span style="color: #339933;">.</span>fff<span style="color: #339933;">.</span>ggg<span style="color: #339933;">.</span>hhh Peer<span style="color: #339933;">=</span>AAA<span style="color: #339933;">.</span>BBB<span style="color: #339933;">.</span>CCC<span style="color: #339933;">.</span>DDD<span style="color: #339933;">/</span><span style="color: #cc66cc;">32</span> &nbsp; <span style="color: #009900;">&#91;</span>Address<span style="color: #009900;">&#93;</span> Address<span style="color: #339933;">=</span>iii<span style="color: #339933;">.</span>jjj<span style="color: #339933;">.</span>kkk<span style="color: #339933;">.</span>lll Peer<span style="color: #339933;">=</span>AAA<span style="color: #339933;">.</span>BBB<span style="color: #339933;">.</span>CCC<span style="color: #339933;">.</span>DDD<span style="color: #339933;">/</span><span style="color: #cc66cc;">32</span> &nbsp; <span style="color: #009900;">&#91;</span>Route<span style="color: #009900;">&#93;</span> Gateway<span style="color: #339933;">=</span>AAA<span style="color: #339933;">.</span>BBB<span style="color: #339933;">.</span>CCC<span style="color: #339933;">.</span>DDD</pre></div> <ul><li>aaa.bbb.ccc.ddd IP-Adresse der ursprünglichen IP-Adresse</li> <li>eee.fff.ggg.hhh IP-Adresse der zusätzlichen IP-Adresse</li> <li>iii.hhh.jjj.lll IP-Adresse der weiteren zusätzlichen IP-Adresse</li> <li>AAA.BBB.CCC.DDD IP-Adresse des Host-Systems</li> </ul><p>Nicht immer funktioniert der Neustart von systemd-networkd sauber. Ein reboot des Systems liefert verlässlichere Ergebnisse.</p> <p>Aktualisiert am 2018-12-17. Die vorherige Lösung mit verschiedenen Netzwerk-Adaptern im Gast hat sich nicht bewährt.</p></div> <div class="field field--name-field-systems field--type-entity-reference field--label-inline"> <div class="field--label">Systeme</div> <a href="/de/systems/server" class="label label-default" hreflang="de">Server</a> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline"> <div class="field--label">Tags</div> <a href="/de/tags/ubuntu" class="label label-default" hreflang="de">ubuntu</a> <a href="/en/tags/network" class="label label-default" hreflang="en">network</a> <a href="/de/tags/xen" class="label label-default" hreflang="de">xen</a> </div> Fri, 06 Jul 2018 06:31:14 +0000 kelly 141 at https://blog.werk21.de Set Limit for open files for MySQL on Ubuntu 16.04 with systemd https://blog.werk21.de/en/2017/04/19/set-limit-open-files-mysql-ubuntu-1604-systemd <span>Limit für open files für MySQL auf Ubuntu 16.04 mit systemd neu setzen</span> <span><span lang="" about="/de/user/15" typeof="schema:Person" property="schema:name" datatype="">kelly</span></span> <span><time datetime="2017-04-19T17:59:37+02:00" title="Mittwoch, 19. April 2017 - 17:59 Uhr">Mi., 19.04.2017 - 17:59 Uhr</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>Um die Fehlermeldung</p> <blockquote>Out of resources when opening file './database/table.MYD' (Errcode: 24 - Too many open files)</blockquote> <p>auf Ubuntu 16.04 zu beheben, müssen die Limits erhöht und Änderungen an der systemd-Konfiguration vorgenommen werden.</p> <h2>1. Limits erhöhen</h2> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">vi <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>security<span style="color: #339933;">/</span>limits<span style="color: #339933;">.</span>d<span style="color: #339933;">/</span><span style="color: #cc66cc;">99</span><span style="color: #339933;">-</span>openfiles<span style="color: #339933;">.</span>conf</pre></div> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#&lt;domain&gt; &lt;type&gt; &lt;item&gt; &lt;value&gt; </span><a href="http://www.php.net/mysql"><span style="color: #990000;">mysql</span></a> soft nofile <span style="color: #cc66cc;">8192</span> <a href="http://www.php.net/mysql"><span style="color: #990000;">mysql</span></a> hard nofile <span style="color: #cc66cc;">8192</span></pre></div> <p>Wenn die Limits für alle user und root neu gesetzt werden sollen, können auch diese Einstellungen verwendet werden:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#&lt;domain&gt; &lt;type&gt; &lt;item&gt; &lt;value&gt; </span><span style="color: #339933;">*</span> soft nofile <span style="color: #cc66cc;">8192</span> <span style="color: #339933;">*</span> hard nofile <span style="color: #cc66cc;">8192</span> root soft nofile <span style="color: #cc66cc;">8192</span> root hard nofile <span style="color: #cc66cc;">8192</span></pre></div> <h2>2. Anpassen der systemd-Konfiguration</h2> <p>Auf Ubuntu 16.04 werden die Dienste mit systemd gestartet. Daher müssen auch hier noch Anpassungen vorgenommen werden:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">systemctl edit <a href="http://www.php.net/mysql"><span style="color: #990000;">mysql</span></a></pre></div> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>Service<span style="color: #009900;">&#93;</span> LimitNOFILE<span style="color: #339933;">=</span><span style="color: #cc66cc;">8192</span></pre></div> <p>(Editor verlassen mit <em>:x</em>)</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">systemctl daemon<span style="color: #339933;">-</span>reload service <a href="http://www.php.net/mysql"><span style="color: #990000;">mysql</span></a> restart</pre></div> <h2>3. Kontrollieren der MySQL-Einstellungen</h2> <p>Standardmäßig ist die MySQL-Variable open_files_limit auf 5000 gesetzt. Wenn der Wert erhöht werden muss:</p> <p>vi /etc/mysql/mysql.conf.d/xx-openfiles.cnf</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>mysqld<span style="color: #009900;">&#93;</span> open_files_limit <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20000</span></pre></div> <p>Alternativ kann natürlich auch diese Variable in der /etc/mysql/my.cnf im Abschnitt [mysqld] ergänzt werden.</p></div> <div class="field field--name-field-systems field--type-entity-reference field--label-inline"> <div class="field--label">Systeme</div> <a href="/de/systems/server" class="label label-default" hreflang="de">Server</a> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline"> <div class="field--label">Tags</div> <a href="/de/tags/mysql" class="label label-default" hreflang="de">mysql</a> <a href="/de/tags/ubuntu" class="label label-default" hreflang="de">ubuntu</a> <a href="/de/tags/server" class="label label-default" hreflang="de">server</a> <a href="/en/tags/open-files" class="label label-default" hreflang="en">open files</a> </div> Wed, 19 Apr 2017 15:42:40 +0000 kelly 118 at https://blog.werk21.de