StefanKonarski.de - Werkzeuge https://stefankonarski.de/category/tags/werkzeuge de MySQL Backup: Schreibe jede Datenbank in eine eigene Datei https://stefankonarski.de/content/mysql-backup-fuer-jede-datenbank-eine-datei <div class="field field-name-taxonomy-vocabulary-3 field-type-taxonomy-term-reference field-label-above"> <div class="field-items"> <div class="field-item even"><a href="/category/tags/administration">Administration</a></div> <div class="field-item odd"><a href="/category/tags/werkzeuge">Werkzeuge</a></div> <div class="field-item even"><a href="/category/tags/datenbanken">Datenbanken</a></div> <div class="field-item odd"><a href="/category/tags/mysql">MySQL</a></div> <div class="field-item even"><a href="/category/tags/shellscript">ShellScript</a></div> </div> </div> <div class="field field-name-body field-type-text-with-summary field-label-hidden"> <div class="field-items"> <div class="field-item even"><p>Dieses Script sichert alle MySQL-Tabellen und schreibt den Inhalt in jeweils eine eigene Datei.</p> <!--break--> <h2>Beschreibung der Funktionsweise</h2> <p>Das Skript sucht nach den ausführbaren Dateien mysql und mysqldump. Nach Eingabe des Passworts für den Datenbank Benutzer root wird mit der Sicherung begonnen. Der Inhalt einer Datenbank wird in eine eigene Datei im aktuellen Verzeichnis geschrieben.</p> <h2>Standard-Einstellungen</h2> <ul> <li>Datenbank-Benutzer: root</li> <li>Datenbank-Server: localhost</li> <li>Datenbank-Passwort: Eingabe erforderlich<br /></li> <li>Ausgeschlossene Datenbanken: information_schema performance_schema"</li> <li>Backup Files werden in das aktuelle Verzeichnis geschrieben</li> <li>Backup File Prefix: Aktuelles Datum und Name des Servers, z.B. 20120205_example</li> <li>Backup File Suffix: .sql</li> <li>Komprimieren: Nach Backup werden Dateien mit bzip2 komprimiert</li> </ul> <p>Die Einstellungen können im Skript geändert werden.</p> <h2>Das Script</h2> <div class="geshifilter"><pre class="bash geshifilter-bash" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;">#!/usr/bin/env sh</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;"># Dump mysql databases via mysqldump and write</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;"># each database in a single file</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;">#</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;"># @copyright 2012 Stefan Konarski</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;"># @license BSD License</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;"># @version 0.1</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;">#</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;"># Exclude the following databases</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #007800;">edb</span>=<span style="color: #ff0000;">&quot;information_schema performance_schema&quot;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;"># Use this prefix for backup file names </span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #007800;">prefix</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(date +'%Y-%m-%d')</span>_<span style="color: #007800;">$(hostname)</span>_&quot;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;"># Use this suffix for backup file names</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #007800;">suffix</span>=<span style="color: #ff0000;">&quot;.sql&quot;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;"># Compress backup files</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #007800;">pack</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">which</span> <span style="color: #c20cb9; font-weight: bold;">bzip2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #007800;">dump</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">which</span> mysqldump<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-x</span> <span style="color: #007800;">$dump</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$dump</span> not executable&quot;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #000000; font-weight: bold;">fi</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #007800;">mysql</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">which</span> mysql<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-x</span> <span style="color: #007800;">$mysql</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$mysql</span> not executable&quot;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #000000; font-weight: bold;">fi</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;"># Ask for password without prompt</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #c20cb9; font-weight: bold;">stty</span> <span style="color: #660033;">-echo</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-p</span> <span style="color: #ff0000;">&quot;Enter MySQL password for root: &quot;</span> pass; <span style="color: #7a0874; font-weight: bold;">echo</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #c20cb9; font-weight: bold;">stty</span> <span style="color: #7a0874; font-weight: bold;">echo</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;&quot;</span> = <span style="color: #ff0000;">&quot;<span style="color: #007800;">$pass</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Login without password&quot;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #007800;">dblogin</span>=<span style="color: #ff0000;">'-u root'</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #000000; font-weight: bold;">else</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #007800;">dblogin</span>=<span style="color: #ff0000;">&quot;-u root -p<span style="color: #007800;">$pass</span>&quot;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #000000; font-weight: bold;">fi</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;">######################</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;"># Execute backup #</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;">######################</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #007800;">out</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$($mysql $dblogin -Bse 'show databases')</span>&quot;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;"># List for compressing files</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #007800;">fc</span>=</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;"># Loop over all databases</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #000000; font-weight: bold;">for</span> db <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$out</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #000000; font-weight: bold;">do</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #666666; font-style: italic;"># Don't skip any database as default</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #007800;">skipdb</span>=<span style="color: #000000;">0</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #666666; font-style: italic;"># If excludable databases are defined</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$edb</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #666666; font-style: italic;"># Loop over excludable databases</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #000000; font-weight: bold;">for</span> n <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$edb</span>; <span style="color: #000000; font-weight: bold;">do</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$db</span>&quot;</span> = <span style="color: #ff0000;">&quot;<span style="color: #007800;">$n</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #007800;">skipdb</span>=<span style="color: #000000;">1</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #7a0874; font-weight: bold;">break</span>;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #000000; font-weight: bold;">fi</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #000000; font-weight: bold;">done</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #000000; font-weight: bold;">fi</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$skipdb</span>&quot;</span> = <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Skip database <span style="color: #007800;">$db</span>&quot;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #7a0874; font-weight: bold;">continue</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #000000; font-weight: bold;">fi</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #007800;">fn</span>=<span style="color: #ff0000;">&quot;./<span style="color: #007800;">$prefix</span><span style="color: #007800;">$db</span><span style="color: #007800;">$suffix</span>&quot;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Dump database <span style="color: #007800;">$db</span> to <span style="color: #007800;">$fn</span>&quot;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #007800;">$dump</span> <span style="color: #007800;">$dblogin</span> <span style="color: #660033;">--databases</span> <span style="color: #007800;">$db</span> <span style="color: #660033;">--result-file</span>=<span style="color: #007800;">$fn</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #007800;">fc</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$fc</span> <span style="color: #007800;">$fn</span>&quot;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #000000; font-weight: bold;">done</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;">######################</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;"># Compress backups #</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #666666; font-style: italic;">######################</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$pack</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</span> <span style="color: #007800;">$pack</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$fc</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Compress <span style="color: #007800;">$fc</span>&quot;</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"> <span style="color: #007800;">$pack</span> <span style="color: #007800;">$fc</span></div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #000000; font-weight: bold;">fi</span></div></li></ol></pre></div></div> </div> </div> Sun, 05 Feb 2012 17:25:05 +0000 stefan 259 at https://stefankonarski.de https://stefankonarski.de/content/mysql-backup-fuer-jede-datenbank-eine-datei#comments VNC Server und Client unter FreeBSD 9 einrichten https://stefankonarski.de/content/vnc <div class="field field-name-taxonomy-vocabulary-3 field-type-taxonomy-term-reference field-label-above"> <div class="field-items"> <div class="field-item even"><a href="/category/tags/administration">Administration</a></div> <div class="field-item odd"><a href="/category/tags/freebsd">FreeBSD</a></div> <div class="field-item even"><a href="/category/tags/werkzeuge">Werkzeuge</a></div> </div> </div> <div class="field field-name-body field-type-text-with-summary field-label-hidden"> <div class="field-items"> <div class="field-item even"><p>Beschreibung der Installation eines VNC-Servers und Aufbau eines SSH-Tunnels.</p> <!--break--> <h2>Window manager installieren</h2> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">portinstall -cP jwm</div></li></ol></pre></div> <h2>VNC-Server installieren</h2> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">portinstall -cP net/vnc</div></li></ol></pre></div> <h2>VNC-Server starten</h2> <p>Den Server einmal initial starten.</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">vncserver -depth 24 -geometry 1024x768</div></li></ol></pre></div> <p>und wieder beenden ...</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">vncserver -kill :1</div></li></ol></pre></div> <p>nun eine kleine Anpassung: In der Datei</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">vi ~/.vnc/xstartup</div></li></ol></pre></div> <p>folgende Anpassungen:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">#!/bin/sh</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">xsetroot -solid grey</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">xset +fp tcp/localhost:7100</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">exec jwm</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">[ -r $HOME/.Xresources ] &amp;&amp; xrdb $HOME/.Xresources</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">xsetroot -solid grey</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">vncconfig -iconic &amp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">xterm -geometry 80x24+10+10 -ls -title &quot;$VNCDESKTOP Desktop&quot; &amp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">twm &amp;</div></li></ol></pre></div> <p>Dann noch das eigene Passwort setzen:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">vncpasswd</div></li></ol></pre></div> <p>Beim nächsten Start des vncservers kann man sich von einem entfernten Rechner mit:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">vncviewer SERVER:1</div></li></ol></pre></div> <p>anmelden. Natürlich die Bezeichnung SERVER durch einen eigenen Namen oder IP ersetzen. Das funktioniert natürlich auch mit dem vncviewer unter Windows-Betriebssystemen.</p> <h2>Xterm</h2> <p>Da das System frisch aufgesetzt wurde, fehlte mir insbesondere eine Terminal:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">portinstall -cP xterm-278</div></li></ol></pre></div> <h2>Sicherheitspasekte</h2> <p>Die Verbindung ist unverschlüsselt und sollte nur im nach außen abgesicherten, privaten (vertrauenswürdigen) Intranet aufgebaut werden.</p> <h2>SSH Tunnel</h2> <p>Wenn der VNC-Server über eine IP oder einem Namen zu erreichen ist, ein ssh-Daemon läuft und auf dem lokalen Rechner ein ssh-Daemin installiert ist, kann ein SSH-Tunnel aufgebaut werden. Hierzu wird auf dem lokalen Rechner das folgende Kommando ausgeführt:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">ssh -L 5901:localhost:5901 -N -f -l user vnc.example.org</div></li></ol></pre></div> <p>Die Optionen haben folgende Bedeutung:</p> <ul> <li><strong>-L 5901:localhost:5901</strong><br />Der lokale Port 5901 wird über ssh weitergeleitet an den Port 5901 auf dem entfernten VNC-Server</li> <li><strong>-N</strong><br />Kein Kommando ausführen, nur Ports weiterleiten</li> <li><strong>-f</strong><br />Nachdem der Tunnel aufgebaut wurde, soll der Prozess im Hintergrund weiterlaufen</li> <li><strong>-l user</strong><br />Der Name des Users user, mit dem man sich per ssh auf dem entfernten Rechner anmelden kann</li> <li><strong>vnc.example.org</strong><br />Domain Name des entfernten Rechners</li> </ul> <p>Die VNC-Verbindung stellt man dann mit dem Kommando</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">vncviewer localhost:1</div></li></ol></pre></div> <p>her.</p></div> </div> </div> Fri, 27 Jan 2012 08:03:21 +0000 stefan 251 at https://stefankonarski.de https://stefankonarski.de/content/vnc#comments mysqldump: Restore von InnoDB Tabellen https://stefankonarski.de/content/mysqldump-restore-von-innodb-tabellen <div class="field field-name-taxonomy-vocabulary-3 field-type-taxonomy-term-reference field-label-above"> <div class="field-items"> <div class="field-item even"><a href="/category/tags/werkzeuge">Werkzeuge</a></div> <div class="field-item odd"><a href="/category/tags/datenbanken">Datenbanken</a></div> <div class="field-item even"><a href="/category/tags/mysql">MySQL</a></div> <div class="field-item odd"><a href="/category/tags/backup">Backup</a></div> </div> </div> <div class="field field-name-body field-type-text-with-summary field-label-hidden"> <div class="field-items"> <div class="field-item even"><p>Der Restore von InnoDB-Tabellen ist ein wenig komplizierter, als der von MyISAM-Tabellen.</p> <!--break--> <p>Es gibt zwei Möglichkeiten:</p> <h2>Editieren des mysqldump Backup-File</h2> <p>Am Anfang des SQL-Scripts folgende Zeilen einfügen:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">SET AUTOCOMMIT = 0;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">SET FOREIGN_KEY_CHECKS=0;</div></li></ol></pre></div> <p>und am Ende des SQL-Scripts folgendes:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">SET FOREIGN_KEY_CHECKS = 1;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">COMMIT;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">SET AUTOCOMMIT = 1;</div></li></ol></pre></div> <p>Dann lässt sich diese Datei <a href="/content/mysqldump-restore-von-myisam-tabellen">wie ein MyISAM Backup zurückschreiben</a>. <h2>Restore über die Kommandozeile</h2> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">mysql -u$USER -p</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">use $DATENBANKNAME;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">SET FOREIGN_KEY_CHECKS = 0;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">source $MYSQLDUMP_FILE_Name;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">SET FOREIGN_KEY_CHECKS = 1;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">COMMIT;</div></li></ol></pre></div></div> </div> </div> Thu, 29 Dec 2011 11:15:14 +0000 stefan 215 at https://stefankonarski.de https://stefankonarski.de/content/mysqldump-restore-von-innodb-tabellen#comments mysqldump: Restore von MyISAM Tabellen https://stefankonarski.de/content/mysqldump-restore-von-myisam-tabellen <div class="field field-name-taxonomy-vocabulary-3 field-type-taxonomy-term-reference field-label-above"> <div class="field-items"> <div class="field-item even"><a href="/category/tags/werkzeuge">Werkzeuge</a></div> <div class="field-item odd"><a href="/category/tags/mysql">MySQL</a></div> <div class="field-item even"><a href="/category/tags/backup">Backup</a></div> </div> </div> <div class="field field-name-body field-type-text-with-summary field-label-hidden"> <div class="field-items"> <div class="field-item even"><p>Zurückspielen eines Backups für MyISAM-Tabellen, das mit mysqldump erstellt wurde.</p> <!--break--> <p>Wurde der Inhalt, den mysqldump ausgegeben hat, in die Datei dbdata.sql geschrieben, so kann das Backup mit folgendem Befehl wiederhergestellt werden:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">mysql -u root -p &lt; dbdata.sql</div></li></ol></pre></div> <p>Wurde das Backup mit der standardmäßig aktivierten Option --opt erstellt, so gibt es beim Restore keine Probleme, da existierende Datenbanken und Tabellen vorm Zurückschreiben gelöscht werden!</p> <p>Wurden keine der Optionen <tt>--databases</tt> oder <tt>--all-databases</tt> verwendet, ist der folgende Weg sinnvoll.</p> <p>Eine Alternative ist das Kommando source auf der mysql-Kommandozeile:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">mysql -u root -p</div></li></ol></pre></div> <p>Damit wird die Kommandozeile aufgerufen:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">Enter password:</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">Welcome to the MySQL monitor. Commands end with ; or \g.</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">Your MySQL connection id is 165</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">Server version: 5.1.60-log FreeBSD port: mysql-server-5.1.60</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">Oracle is a registered trademark of Oracle Corporation and/or its</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">affiliates. Other names may be trademarks of their respective</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">owners.</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">mysql&gt; </div></li></ol></pre></div> <p>An dieser Stelle kann man eine Datenbank als aktive mit <tt>use db;</tt> auswählen. Steht im mysqldump-File eine entsprechender use-Befehl, wird gegebenenfalls eine andere Datenbank ausgewählt. Vorher sollte man einen Blick in die ersten Zeilen der Sicherungsdatei werfen.</p> <p>Mit dem source Befehl werden die Befehle in Dateien, wir sie von mysqldump erzeugt werden, ausgeführt.:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">mysql&gt; source dbdata.sql;</div></li></ol></pre></div> <p>Und das Backupfile wird zurückgespielt. Je nach Optionen muss vorher die richtige Datenbank ausgewählt werden. </p></div> </div> </div> Thu, 29 Dec 2011 11:08:06 +0000 stefan 213 at https://stefankonarski.de https://stefankonarski.de/content/mysqldump-restore-von-myisam-tabellen#comments mysqldump: die Option opt https://stefankonarski.de/content/mysqldump-die-option-opt <div class="field field-name-taxonomy-vocabulary-3 field-type-taxonomy-term-reference field-label-above"> <div class="field-items"> <div class="field-item even"><a href="/category/tags/werkzeuge">Werkzeuge</a></div> <div class="field-item odd"><a href="/category/tags/datenbanken">Datenbanken</a></div> <div class="field-item even"><a href="/category/tags/mysql">MySQL</a></div> </div> </div> <div class="field field-name-body field-type-text-with-summary field-label-hidden"> <div class="field-items"> <div class="field-item even"><p>Die Option --opt wird standardmäßig ausgeführt und bietet eine Sammlung von mysqldump Optionen.</p> <!--break--> <p>Die mysqldump option --opt ist eine Kürzel für folgende sinnvolle Optionen:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">mysqldump --create-options --disable-keys --extended-insert --lock-tables --add-drop-tables --quick --set-charset [...]</div></li></ol></pre></div> <p>Die einzelnen Optionen haben folgende Bedeutung:</p> <h2>mysqldump Option --create-options</h2> <p>In die Anweisung zum Erstellen einer Tabellen werden alle Tabellenoptionen geschrieben.</p> <h2>mysqldump Option --disable-keys</h2> <p>Nur bei MyIsam Tebellen wirksam. Die Keys werden erst nach vollständigen Zurückschreiben erstellt. Das Zurückschreiben wird dadurch beschleunigt.</p> <h2>Option --extended-insert</h2> <p>Innerhalb einer INSERT-Anweisung werden mehrere Datensätze geschrieben, z.B.:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">INSERT INTO `help_category` VALUES (1,'Geographic',0,''),(2,'Polygon properties',33,''), [...]</div></li></ol></pre></div> <p>an Stelle von</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">INSERT INTO `help_category` VALUES (1,'Geographic',0,'');</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">INSERT INTO `help_category` VALUES (2,'Polygon properties',33,'');</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">[...]</div></li></ol></pre></div> <h2>Option --add-drop-tables</h2> <p>Vor dem Befehl zum Anlegen einer Tabelle wird versucht eine Drop-Anweisung auszuführen. Wenn man den Dump zurück spielt werden also alle Tabellen vorher auf jeden Fall gelöscht:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">DROP TABLE IF EXISTS `columns_priv`;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">CREATE TABLE `columns_priv` (</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">[...]</div></li></ol></pre></div> <h2>Option --add-locks</h2> <p>Vorm Zurückschreiben wird für jede Tabelle ein lock gesetzt und anschließend wieder aufgehoben, z.B.:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">LOCK TABLES `columns_priv` WRITE;</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">[...]</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">UNLOCK TABLES;</div></li></ol></pre></div> <p>Während des Zurückspielens ist die Tabelle für alle Zugriffe gesperrt, aber Einfügevorgänge werden beschleunigt.</p> <h2>Option --quick</h2> <p>Jeder Datensatz einer Tabelle wird einzeln vom Server abgerufen. Ansonsten würde mysql versuchen, die gesamten Daten der Tabelle in den Speicher zu schreiben. Bei großen Tabellen kann das zu einer Fehlermeldung und Abbruch führen.</p> <h2>Option --set-charset</h2> <p>Fügt zum Beispiel folgende Zeile in das Dump-File ein:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">/*!40101 SET NAMES utf8 */;</div></li></ol></pre></div> <p>Natürlich kann es andere Standard-Zeichensätze geben.</p> <h2>mysqldump ohne Option --opt</h2> <p>Wer diese Option komplett überspringen will, gibt die Option --skip-opt an:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">mysqldump -u root -p --skip-opt --all-databases --result-file=dbdata.sql</div></li></ol></pre></div> <p>Es lassen sich aber auch nur einzelne Optionen mit --skip deaktivieren. Die Option --skip-opt hat fast die gleiche Bedeutung wie (Gilt nicht für die Option --skip-add-drop-tables):</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">mysqldump --skip-create-options --skip-disable-keys --skip-extended-insert --skip-lock-tables --skip-quick --skip-set-charset [...]</div></li></ol></pre></div></div> </div> </div> Thu, 29 Dec 2011 10:58:26 +0000 stefan 211 at https://stefankonarski.de https://stefankonarski.de/content/mysqldump-die-option-opt#comments MEncoder: Videos schneiden https://stefankonarski.de/content/mencoder-videos-schneiden <div class="field field-name-taxonomy-vocabulary-3 field-type-taxonomy-term-reference field-label-above"> <div class="field-items"> <div class="field-item even"><a href="/category/tags/werkzeuge">Werkzeuge</a></div> <div class="field-item odd"><a href="/category/tags/videobearbeitung">Videobearbeitung</a></div> </div> </div> <div class="field field-name-body field-type-text-with-summary field-label-hidden"> <div class="field-items"> <div class="field-item even"><p>Mit dem zum MPlayer-Paket gehörenden Kommandozeilenprogramm MEncoder lassen sich leicht Fragmente aus einem Video schneiden.</p> <!--break--> <p>Dazu benötigt man die Startzeit in H:m:s (Stunde:Minute:Sekunde) und die Länge des Videofragments in Sekunden. Werden Audio- und Videoeinstellungen einfach kopiert erhält man die allgemeine Befehlszeile für das Video in.avi aus dem das Fragment out.avi geschnitten werden soll:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">mencoder -ss H:m:s -endpos L -ovc copy -oac copy -o out.avi in.avi</div></li></ol></pre></div> <p>Beispiel: Das Fragment soll bei 0 Stunden, 5 Minuten und 30 Sekunden beginnen und genau 526.4 Sekunden lang sein. Der MEncoder Befehl lautet dann:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">mencoder -ss 0:05:30 -endpos 526.4 -ovc copy -oac copy -o out.avi in.avi</div></li></ol></pre></div> <p>Die Startzeit lässt sich auch in Sekunden angeben. Für die oben angegebene Zeile kann man also auch schreiben, weil 5 Minuten und 30 Sekunden 330 Sekunden sind:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">mencoder -ss 330 -endpos 526.4 -ovc copy -oac copy -o out.avi in.avi</div></li></ol></pre></div></div> </div> </div> Wed, 28 Dec 2011 11:01:55 +0000 stefan 199 at https://stefankonarski.de https://stefankonarski.de/content/mencoder-videos-schneiden#comments Verschlüsseltes Netzwerkdateisystem SSHFS unter FreeBSD https://stefankonarski.de/content/verschluesseltes-netzwerkdateisystem-sshfs-unter-freebsd <div class="field field-name-taxonomy-vocabulary-3 field-type-taxonomy-term-reference field-label-above"> <div class="field-items"> <div class="field-item even"><a href="/category/tags/services">Dienste</a></div> <div class="field-item odd"><a href="/category/tags/freebsd">FreeBSD</a></div> <div class="field-item even"><a href="/category/tags/werkzeuge">Werkzeuge</a></div> <div class="field-item odd"><a href="/category/tags/ssh">SSH</a></div> <div class="field-item even"><a href="/category/tags/fusefs">fusefs</a></div> </div> </div> <div class="field field-name-body field-type-text-with-summary field-label-hidden"> <div class="field-items"> <div class="field-item even"><p>Wenn NFS nicht in Frage kommt, lassen sich entfernte Dateisysteme via sshfs unter FreeBSD (natürlich auch unter anderen Betriebssystemen) einbinden.</p> <!--break--> <p>Voraussetzung natürlich: Auf dem entfernten Rechner muss ein ssh-Dämon laufen. Der Port sysutils/fusefs-sshfs ist auf dem lokalen Rechner schnell installiert. </p> <h2>Vorbereitung</h2> <p>Für sshfs wird fuse benötigt. Dieser Port, sowie das Kernel-Modul sollte also schon installiert sein. In die /etc/rc.conf nun folgende Zeile einfügen:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">fusefs_enable=&quot;YES&quot; </div></li></ol></pre></div> <p>Der Dienste muss natürlich jetzt noch auf dem üblichen Weg gestartet werden. Bei Problemen mit dem Kernel Modul lohnt es sich, den Port sysutils/fusefs-kmod neu zu bauen. Will man sshfs als normaler User nutzen, fehlt vielleicht noch</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"># sysctl vfs.usermount=1</div></li></ol></pre></div> <p>Permanent wird dieser Eintrag mit der folgenden Zeile in der Datei /etc/sysctl.conf</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">vfs.usermount=1</div></li></ol></pre></div> <p>Als letzten fehlen für einen normalen User noch die Rechte für das Device /dev/fuse0. Wenn man alle User, die Lese- und Schreibrechte haben dürfen, der Gruppe operator zufügt, ist dies erledigt. <br /> Es gibt nun 2 Wege, ein entferntes Verzeichnis einzubinden:</p> <h2>1. sshfs als normaler Benutzer</h2> <p>Voraussetzung: Auf dem entfernten Rechner steht ein Account zur Verfügung. Dann kann man mit der allgemeinen Befehlszeile</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">sshfs -o idmap=user username@example.org:/path /path/to/mount/point</div></li></ol></pre></div> <p>also z.B.</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">$ mkdir ~/mnt</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">$ sshfs -o idmap=user username@example.org:/usr/local/www ~/mnt</div></li></ol></pre></div> <p>Nach Eingabe des Passworts ist das entfernte Verzeichnis via ssh gemountet.</p> <h2>2. sshfs als root via mount_fusefs</h2> <p>Als root mit der Zeile</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">mount_fusefs auto /path/to/mount/point sshfs -o idmap=user username@example.org:</div></li></ol></pre></div> <p>Also z.B.</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"># mount_fusefs auto /mnt sshfs -o idmap=user username@example.org:</div></li></ol></pre></div> <h2>Fehlermeldungen</h2> <p>Es empfiehlt sich vor dem Mounten einmal den Anmeldeprozess durchzuführen:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"># ssh username@example.org</div></li></ol></pre></div> <p>damit der Schlüssel der Liste der bekannten Hosts hinzugefügt werden kann. Der mount-Befehl kann diesen Schritt nicht durchführen.</p> <p>Beim Versuch mount_fusefs als root auszuführen und auf das User-Verzeichnis auf dem entfernten Rechner zuzugreifen, kann folgendes Fehlerbild erscheinen:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"># mount_fusefs auto /mnt sshfs -o sshfs_debug,idmap=user username@example.org:</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"># SSHFS version 2.2</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">Password:</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">Password:</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">Password:</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">remote host has disconnected</div></li></ol></pre></div> <p>ohne dass man die Möglichkeit hat, ein Kennwort einzugeben. Auf dem entfernten Rechner steht in /var/log/messages:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">sshd[19152]: error: PAM: authentication error for username from XXX.XXX.XXX.XXX</div></li></ol></pre></div> <p>Dies kann umgangen werden, indem man mit ssh-keygen ein Schlüsselpaar erzeugt und den öffentlichen Schlüssel auf den entfernten Rechner kopiert, z.B. als root mit</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"># ssh-keygen</div></li><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal"># cat /root/.ssh/id_rsa.pub | ssh username@example.org 'cat &gt;&gt; .ssh/authorized_keys'</div></li></ol></pre></div> <p>Das setzt natürlich voraus, dass im Homedirectory des Users das Verzeichnis .ssh existiert.</p> <p>Weitere Fehlerquellen:</p> <ul> <li>/dev/null hat nicht die Rechte 0666 </li> <li>Auf dem entfernten Rechner ist in der sshd_config das sftp Subsystem deaktiviert</li> <li>Auf dem entfernten Rechner ist in der sshd_config UsePAM deaktiviert</li> </ul></div> </div> </div> Fri, 26 Mar 2010 15:49:35 +0000 stefan 153 at https://stefankonarski.de https://stefankonarski.de/content/verschluesseltes-netzwerkdateisystem-sshfs-unter-freebsd#comments WWW Linksammlung https://stefankonarski.de/content/www-linksammlung <div class="field field-name-taxonomy-vocabulary-3 field-type-taxonomy-term-reference field-label-above"> <div class="field-items"> <div class="field-item even"><a href="/category/tags/werkzeuge">Werkzeuge</a></div> <div class="field-item odd"><a href="/category/tags/www">WWW</a></div> <div class="field-item even"><a href="/category/tags/entwicklung">Entwicklung</a></div> </div> </div> <div class="field field-name-body field-type-text-with-summary field-label-hidden"> <div class="field-items"> <div class="field-item even"><p>Link-Sammlung zu Beiträgen rund ums WWW.</p>&#13; <!--break-->&#13; <p><b><a href="https://www.meine-erste-homepage.com/generatoren.php" onclick="window.open(this.href, '_new'); return false;">Generatoren</a></b><br />&#13; Zahlreiche Generatoren für die eigene Homepage, z.B. Generatoren für Stylesheets, 3D-Schrift, Menüs, Formulare, Ticker, Laufbänder uvm.</p>&#13; &#13; <p><b><a href="http://www.rehbein-dortmund.de/spamtrap.html" onclick="window.open(this.href, '_new'); return false;">Spam</a></b><br />&#13; Über Spam und die Sammler von Mailadressen. Der Autor stellt Maßnahmen für die Benutzung von E-Mails und E-Mail-Adressen auf Websites vor, sowie Techniken zu aktiver und passiver Spam-Abwehr.</p>&#13; &#13; <p><b><a href="http://www.w3.org/QA/Tips/" onclick="window.open(this.href, '_new'); return false;">Tipps vom World Wide Web Consortium</a></b><br />&#13; Qualitäts-Tipps für Webmaster.</p></div> </div> </div> Sat, 05 Sep 2009 10:57:29 +0000 stefan 129 at https://stefankonarski.de https://stefankonarski.de/content/www-linksammlung#comments Offene Ports: finden und zuordnen https://stefankonarski.de/content/nmap-sockstat <div class="field field-name-taxonomy-vocabulary-3 field-type-taxonomy-term-reference field-label-above"> <div class="field-items"> <div class="field-item even"><a href="/category/tags/administration">Administration</a></div> <div class="field-item odd"><a href="/category/tags/freebsd">FreeBSD</a></div> <div class="field-item even"><a href="/category/tags/werkzeuge">Werkzeuge</a></div> <div class="field-item odd"><a href="/category/tags/linux">Linux</a></div> </div> </div> <div class="field field-name-body field-type-text-with-summary field-label-hidden"> <div class="field-items"> <div class="field-item even"><p>Mit nmap nach offenen Ports scannen und mit sockstat zuordnen.</p> <!--break--> <p>Mit dem Programm <i>nmap</i> kann man nach den offenen Ports eines entfernten Rechenrs scannen, z.B.</p> <p> <tt>nmap -sS IP</tt> </p> <p>Mit <tt>sockstat</tt> bekommnt man eine Liste, mit der sich unter anderen zuordnen läßt, welches Programm gerade welchen Port offen hält.</p></div> </div> </div> Sat, 05 Sep 2009 09:59:03 +0000 stefan 109 at https://stefankonarski.de https://stefankonarski.de/content/nmap-sockstat#comments whois-Abfrage https://stefankonarski.de/content/whois-abfrage <div class="field field-name-taxonomy-vocabulary-3 field-type-taxonomy-term-reference field-label-above"> <div class="field-items"> <div class="field-item even"><a href="/category/tags/administration">Administration</a></div> <div class="field-item odd"><a href="/category/tags/werkzeuge">Werkzeuge</a></div> <div class="field-item even"><a href="/category/tags/dns">DNS</a></div> </div> </div> <div class="field field-name-body field-type-text-with-summary field-label-hidden"> <div class="field-items"> <div class="field-item even"><p>Syntax für die whois-Abfrage.</p> <!--break--> <p>Wenn die normale whois-Abfrage, wie z.B.:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">whois web.de</div></li></ol></pre></div> <p>nicht die gewünschten Informationen liefert, muss man wahrscheinlich den Host für die Abfrage mit angeben. So funktioniert es dann auf jeden Fall:</p> <div class="geshifilter"><pre class="text geshifilter-text" style="font-family:monospace;"><ol><li style="font-family: monospace; font-weight: normal;"><div style="font-family: monospace; font-weight: normal; font-style: normal">whois -h whois.denic.de -- &quot;-T dn web.de&quot;</div></li></ol></pre></div></div> </div> </div> Sat, 05 Sep 2009 09:56:54 +0000 stefan 107 at https://stefankonarski.de https://stefankonarski.de/content/whois-abfrage#comments