<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Alonso.ch</title>
	<atom:link href="http://blog.alonso.ch/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.alonso.ch</link>
	<description>Nonsport Blog</description>
	<lastBuildDate>Wed, 01 Feb 2012 08:33:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Abgleichen von Tabelleninhalten unter mySQL (Analog MERGE INTO)</title>
		<link>http://blog.alonso.ch/tech/database/mysql/abgleichen-von-tabelleninhalten-unter-mysql-analog-merge-into/</link>
		<comments>http://blog.alonso.ch/tech/database/mysql/abgleichen-von-tabelleninhalten-unter-mysql-analog-merge-into/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 23:05:45 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[mySQL]]></category>
		<category><![CDATA[Merge]]></category>
		<category><![CDATA[upsert]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=189</guid>
		<description><![CDATA[Für den performanten und sicheren Datenabgleich (&#8220;UPSERT&#8221;) stehen bei den grossen Datenbanksystemen die sogenannten Merge-Statements bereit (MERGE INTO &#8230;). Dies ist unter mySQL aktuell nicht möglich, kann jedoch sinngemäss mit INSERT .. ON DUPLICATE KEY gelöst werden. Für dieses Beispiel brauchen wir 2 Tabellen, genaugenommen je eine Quell &#8211; und Zieltabelle. CREATE TABLE src &#40; [...]]]></description>
			<content:encoded><![CDATA[<p>Für den performanten und sicheren Datenabgleich (&#8220;UPSERT&#8221;) stehen bei den grossen Datenbanksystemen die sogenannten Merge-Statements bereit (<em>MERGE INTO &#8230;</em>). Dies ist unter mySQL aktuell nicht möglich, kann jedoch sinngemäss mit <em>INSERT .. ON DUPLICATE KEY</em> gelöst werden.</p>
<p>Für dieses Beispiel brauchen wir 2 Tabellen, genaugenommen je eine Quell &#8211; und Zieltabelle.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> src <span style="color: #66cc66;">&#40;</span>
    src_id <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span>
    src_value1 <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
    src_value2 <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
    src_ts <span style="color: #993333; font-weight: bold;">TIMESTAMP</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">CURRENT_TIMESTAMP</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #993333; font-weight: bold;">CURRENT_TIMESTAMP</span><span style="color: #66cc66;">,</span>
    <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>src_id<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
    <span style="color: #993333; font-weight: bold;">KEY</span> idx_src_ts <span style="color: #66cc66;">&#40;</span>src_ts<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>InnoDB;
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> tgt <span style="color: #66cc66;">&#40;</span>
    tgt_id <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
    tgt_value1 <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
    tgt_value2 <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
    tgt_ts <span style="color: #993333; font-weight: bold;">TIMESTAMP</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">CURRENT_TIMESTAMP</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #993333; font-weight: bold;">CURRENT_TIMESTAMP</span><span style="color: #66cc66;">,</span>
    <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>tgt_id<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
    <span style="color: #993333; font-weight: bold;">KEY</span> idx_tgt_ts <span style="color: #66cc66;">&#40;</span>tgt_ts<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>InnoDB;</pre></div></div>

<p><span id="more-189"></span></p>
<p>Ein paar Testdaten dazu:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">INSERT</span> <span style="color: #990099; font-weight: bold;">INTO</span> src <span style="color: #FF00FF;">&#40;</span>src_value1<span style="color: #000033;">,</span> src_value2<span style="color: #FF00FF;">&#41;</span> 
<span style="color: #990099; font-weight: bold;">VALUES</span>
    <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'a'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'aa'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
    <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'b'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'bb'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
    <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'c'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'cc'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
    <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'d'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'dd'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
    <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'e'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'ee'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
    <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'f'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'ff'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
    <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'g'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'gg'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
    <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'h'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'hh'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div>

<p>Im Gegensatz zu <em>MERGE</em> ist es unter mySQL nicht möglich, die Verknüpfung direkt zu bestimmen (.. ON sourcetable.key = targettable.somekey.. ). Unter mySQL werden automatisch alle Unique Indexe angewendet (UNIQUE/PRIMARY).<br />
In den Beispieltabellen wurden daher jeweils ein Primary Key definiert, auf welchem der &#8220;Merge&#8221; stattfinden soll. Wird ein solcher beim Einfügen in die Zieltabelle &#8220;verletzt&#8221;, kann der Datensatz über ON DUPLICATE KEY abgefangen und weiter verarbeitet werden. Das ganze ist somit nichts anderes als ein normaler Insert mit &#8220;Errorhandling&#8221;.  </p>
<p>Beispiel</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">INSERT</span>
<span style="color: #993333; font-weight: bold;">INTO</span>
    tgt
    <span style="color: #66cc66;">&#40;</span>   
        tgt_id<span style="color: #66cc66;">,</span>
        tgt_value1<span style="color: #66cc66;">,</span>
        tgt_value2
    <span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">SELECT</span>
    src_id<span style="color: #66cc66;">,</span>
    src_value1<span style="color: #66cc66;">,</span>
    src_value2
<span style="color: #993333; font-weight: bold;">FROM</span>
    src
<span style="color: #993333; font-weight: bold;">ON</span> DUPLICATE <span style="color: #993333; font-weight: bold;">KEY</span> 
<span style="color: #993333; font-weight: bold;">UPDATE</span> 
    tgt_value1 <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">VALUES</span><span style="color: #66cc66;">&#40;</span>tgt_value1<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
    tgt_value2 <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">VALUES</span><span style="color: #66cc66;">&#40;</span>tgt_value2<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Existiert beim Insert der Key in der Zieltabelle bereits, werden lediglich alle (definierten) Attribute des Datensatzes aktualisiert, und in unserem Fall der Timestamp (<em>ON UPDATE ..</em>) aktualisert. Sind die Attribute des Datensatzes unverändert &#8211; erfolgt kein Update.</p>
<p>Das Statement oben kann daher beliebig oft ausgeführt werden &#8211; solange sich der Inhalt der Quelltabelle nicht verändert bleiben auch die Informationen inklusive Timestamp in der Zieltabelle unverändert.</p>
<p>Zu Testzwecken verändern wir nun einen Datensatz in der Quelltabelle:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">UPDATE</span> src <span style="color: #990099; font-weight: bold;">SET</span> src_value2 <span style="color: #CC0099;">=</span> <span style="color: #008000;">'wohooooooo'</span> <span style="color: #990099; font-weight: bold;">WHERE</span> src_value1 <span style="color: #CC0099;">=</span> <span style="color: #008000;">'a'</span></pre></div></div>

<p>Wird nun das &#8220;Merge&#8221; Statement erneut ausgeführt, wird der betroffene Datensatz auch in der Zieltabelle aktualisiert &#8211; und nur dieser.</p>
<p>Natürlich macht es in der Praxis keinen Sinn eine 1:1 Kopie einer Tabelle zu verwalten. Als Quelle kann natürlich auch eine komplexe Abfrage oder ein View dienen, resp. mehrere davon pro Zieltabelle. In diesem Fall muss auf der Zieltabelle der entsprechende Primary-Key, resp. besser Unique-Index angelegt werden.</p>
<p>Im Gegensatz zu den &#8220;echten&#8221; MERGE-Statements sind hier leider keine zusätzlichen Bedingungen beim Update möglich. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/tech/database/mysql/abgleichen-von-tabelleninhalten-unter-mysql-analog-merge-into/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Templates in Citrix Xenserver (5.6) löschen.</title>
		<link>http://blog.alonso.ch/tech/virtualisierung/xenserver/templates-in-citrix-xenserver-5-6-loschen/</link>
		<comments>http://blog.alonso.ch/tech/virtualisierung/xenserver/templates-in-citrix-xenserver-5-6-loschen/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 16:26:09 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[Citrix Xenserver]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=169</guid>
		<description><![CDATA[Das entfernen von vordefinierten Templates innerhalb eine Citrix Xenserver Installation ist nicht ganz selbsterklärend und zugegebenerweise etwas mühsam. Zur Vereinfachung habe ich ein simples Bash-Script gebaut: Anwendung: ./xe-remove-template.sh &#34;template-name&#34; xe-remove-template.sh #!/bin/bash ## xe-remove-template.sh, remove template by name on local xenserver instance ## Author: Michael Bieri &#60;mb@alonso.ch&#62; ## Warning: This script has no brain - use [...]]]></description>
			<content:encoded><![CDATA[<p>Das entfernen von vordefinierten Templates innerhalb eine Citrix Xenserver Installation ist nicht ganz selbsterklärend und zugegebenerweise etwas mühsam. Zur Vereinfachung habe ich ein simples Bash-Script gebaut:</p>
<p>Anwendung:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>xe-remove-template.sh <span style="color: #ff0000;">&quot;template-name&quot;</span></pre></div></div>

<p><span id="more-169"></span></p>
<p><em>xe-remove-template.sh</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">## xe-remove-template.sh, remove template by name on local xenserver instance</span>
<span style="color: #666666; font-style: italic;">## Author:  Michael Bieri &lt;mb@alonso.ch&gt;</span>
<span style="color: #666666; font-style: italic;">## Warning: This script has no brain - use your own!</span>
&nbsp;
<span style="color: #007800;">UUID</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>xe template-list name-label=<span style="color: #ff0000;">&quot;$1&quot;</span> --minimal<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$UUID</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Sorry - Template not found&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: $0 &lt;template-name&gt;&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;using UUID: <span style="color: #007800;">$UUID</span>&quot;</span>
&nbsp;
xe template-param-remove <span style="color: #007800;">uuid</span>=<span style="color: #007800;">$UUID</span> param-name=other-config param-key=default_template
xe template-uninstall template-uuid=<span style="color: #007800;">$UUID</span> <span style="color: #007800;">force</span>=<span style="color: #c20cb9; font-weight: bold;">true</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Done&quot;</span></pre></div></div>

<p>Das Script gibts auch <a href="http://download.alonso.ch/scripts/xenserver/xe-remove-template.sh" title="Download xe-remove-template.sh">hier</a> als Download.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/tech/virtualisierung/xenserver/templates-in-citrix-xenserver-5-6-loschen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mySQL Server 5.5 auf Debian Squeeze</title>
		<link>http://blog.alonso.ch/tech/linux/debian-linux-tech/mysql-server-5-5-auf-debian-squeeze/</link>
		<comments>http://blog.alonso.ch/tech/linux/debian-linux-tech/mysql-server-5-5-auf-debian-squeeze/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 21:25:44 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[InnoDB]]></category>
		<category><![CDATA[Squeeze]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=151</guid>
		<description><![CDATA[Wer einen performanten mySQL Server 5.5 unter Debian Squeeze betreiben will &#8211; muss auf das normale Debian Packet verzichten und manuell installieren, da die &#8220;offizielle&#8221; Variante aus dem Repositry leider etwas stark veraltet ist. Ist aber grundsätzlich kein Hexenwerk &#8211; so gehts: Sofern bestehende Datenbanken vorhanden sind &#8211; Backup erstellen! Ich gehe davon aus dass [...]]]></description>
			<content:encoded><![CDATA[<p>Wer einen performanten mySQL Server 5.5 unter Debian Squeeze betreiben will &#8211; muss auf das normale Debian Packet verzichten und manuell installieren, da die &#8220;offizielle&#8221; Variante aus dem Repositry leider etwas stark veraltet ist.</p>
<p>Ist aber grundsätzlich kein Hexenwerk &#8211; so gehts:</p>
<p>Sofern bestehende Datenbanken vorhanden sind &#8211; Backup erstellen! Ich gehe davon aus dass es hierzu kein HowTo braucht <img src='http://blog.alonso.ch/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Alte Installation bereinigen, sofern vorhanden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> remove mysql-server mysql-common <span style="color: #660033;">--purge</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> autoremove</pre></div></div>

<p><span id="more-151"></span><br />
Danach sollte die &#8220;asynchronous I/O library&#8221;, kurz AIO aus dem Repository installiert werden &#8211; damit kann die spätere Performance von InnoDB massiv verbessert werden.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libaio-dev</pre></div></div>

<p>Analog zu Debian, sollte mySQL auch weiterhin unter einem eigenen Benutzer laufen, dazu legen wir diesen mit entsprechender Gruppe an, sofern notwendig.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">useradd mysql
groupadd mysql</pre></div></div>

<p>Danach werden die benötigten Ordner auf dem Filesystem angelegt und mit den nötigen Rechten versehen. In diesem Beispiel wird die Struktur analog zur normalen Packetinstallation aufgebaut. Diese sollte aber wenn möglich weiter optimiert werden. Ein paar Gedanken dazu sind in einem anderen <a href="http://blog.alonso.ch/tech/database/mysql/ideales-mysql-server-setup/" title="mySQL Infrastruktur Setup">Artikel</a> zu finden.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>mysql <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> mysql:mysql <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>mysql
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>mysqld <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> mysql:root <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>mysqld <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> <span style="color: #000000;">755</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>mysqld
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> mysql:mysql <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> <span style="color: #000000;">700</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql</pre></div></div>

<p>Als nächstes brauchen wir nun das aktuellste &#8220;Linux Generic Tar Archive&#8221; von mySQL:<br />
<a href="http://www.mysql.com/downloads/mysql/#downloads" title="mySQL Community Server Download" target="_blank">http://www.mysql.com/downloads/mysql/#downloads</a></p>
<p>Wählen sie unbedingt das korrekte Packet. Sollten sie unsicher sein bezüglich 32 oder 64 Bit &#8211; Fragen sie doch mal ihr System dazu <img src='http://blog.alonso.ch/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">getconf LONG_BIT</pre></div></div>

<p>In meinem Fall wurde die Version 5.5.15 (64 Bit) von <a href="http://www.switch.ch" title="Switch mySQL Mirror" target="_blank">Switch.ch</a> heruntergeladen und entpackt:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> mysql5.5 <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">cd</span> mysql5.5
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>dev.mysql.com<span style="color: #000000; font-weight: bold;">/</span>get<span style="color: #000000; font-weight: bold;">/</span>Downloads<span style="color: #000000; font-weight: bold;">/</span>MySQL-<span style="color: #000000;">5.5</span><span style="color: #000000; font-weight: bold;">/</span>mysql-5.5.15-linux2.6-x86_64.tar.gz<span style="color: #000000; font-weight: bold;">/</span>from<span style="color: #000000; font-weight: bold;">/</span>http:<span style="color: #000000; font-weight: bold;">//</span>mirror.switch.ch<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>mirror<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-O</span> mysql-5.5.15-linux2.6-x86_64.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> xzvf mysql-5.5.15-linux2.6-x86_64.tar.gz</pre></div></div>

<p>In meinem Setup werden die Dateien anschliessen nach <em>/usr/share/mysql</em> verschoben und an den User <em>mysql</em> zugewiesen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mv</span> mysql-5.5.15-linux2.6-x86_64 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql
<span style="color: #c20cb9; font-weight: bold;">chown</span> mysql:mysql <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-R</span></pre></div></div>

<p>Als nächstes muss das mySQL-Bin Verzeichniss noch in den Path aufgenommen werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$PATH</span></pre></div></div>

<p>Wenn alles klappt &#8211; sollte mySQL nun startklar sein. Ein kleiner Test schaded aber sicherlich nicht:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql <span style="color: #660033;">-V</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> mysqld <span style="color: #660033;">-V</span></pre></div></div>

<p>Sollte folgendes ans Licht bringen:</p>
<pre>
mysql  Ver 14.14 Distrib 5.5.15, for linux2.6 (x86_64) using readline 5.1
mysqld  Ver 5.5.15 for linux2.6 on x86_64 (MySQL Community Server (GPL))
</pre>
<p>Wenn alles geklappt hat, sollte noch die <em>/etc/profile</em> mit dem neuen Pfad ergänz werden damit diese Änderung permant wird. Auszug:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">...
<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: #780078;">`id -u`</span>&quot;</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #007800;">PATH</span>=<span style="color: #ff0000;">&quot;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/mysql/bin&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
  <span style="color: #007800;">PATH</span>=<span style="color: #ff0000;">&quot;/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/mysql/bin&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">export</span> PATH
...</pre></div></div>

<p>Nun brauchen wir noch die Konfiguration als /etc/mysql/my.cnf. Hierzu gibt es gute Templates welche übernommen werden können. In meinem Beispiel wurde die my-innodb-heavy-4G.cnf gewählt &#8211; es gäbe aber noch diverse Alternativen &#8211; am identischen Ort.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>support-files<span style="color: #000000; font-weight: bold;">/</span>my-innodb-heavy-4G.cnf <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>my.cnf</pre></div></div>

<p>Folgende Anpassungen sind hier notwendig (anpassen/ergänzen):</p>
<pre>
[client]
socket          = /var/run/mysqld/mysqld.sock

[mysqld]
socket          = /var/run/mysqld/mysqld.sock
basedir         = /usr/local/mysql
datadir         = /usr/local/mysql/data
tmpdir          = /tmp
log_error       = /var/log/mysql/error.log
</pre>
<p>init.d Script erstellen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>support-files<span style="color: #000000; font-weight: bold;">/</span>mysql.server <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>mysql <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>mysql</pre></div></div>

<p>Hier sind nun noch 2 weitere Anpassungen notwendig:</p>
<pre>
basedir=/usr/local/mysql
datadir=/var/lib/mysql/data
</pre>
<p>Basisdatenbanken anlegen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>mysql_install_db <span style="color: #660033;">--user</span>=mysql <span style="color: #660033;">--basedir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql</pre></div></div>

<p>Fertig &#8211; ein erster Startversuch:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>mysql start</pre></div></div>

<p>Sicherheits-Konfiguration setzten, dafür braucht es allerdings noch einen Symlink für den Socken:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>mysqld<span style="color: #000000; font-weight: bold;">/</span>mysqld.sock <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>mysql.sock
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysql_secure_installation</pre></div></div>

<p>Wird AIO auch wirklich angewendet? Ein Blick ins Log hilft weiter, folgender Eintrag muss erscheinen:</p>
<pre>
****** **:**:** InnoDB: Using Linux native AIO
</pre>
<p>Wenn alls OK ist &#8211; Server automatisch mit Bootprozess starten:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">update-rc.d mysql defaults</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/tech/linux/debian-linux-tech/mysql-server-5-5-auf-debian-squeeze/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Howto: SNMP(D) unter Debian Squeeze</title>
		<link>http://blog.alonso.ch/paste-bin/howto-snmpd-unter-debian-squeeze/</link>
		<comments>http://blog.alonso.ch/paste-bin/howto-snmpd-unter-debian-squeeze/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 00:06:45 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[paste.bin]]></category>
		<category><![CDATA[Cacti]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[snmp]]></category>
		<category><![CDATA[Squeeze]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=141</guid>
		<description><![CDATA[Dieses Howto soll ein kleiner Quickstart in den &#8220;neuen&#8221; SNMPD-Deamon unter Debian Squeeze sein. In diesem Fall soll der Dienst so konfiguriert werden, dass Systeminformationen über SNMP (z.B. Nagios,Cacti) abgefragt werden können. Installation der Pakete: apt-get install snmp Wer auch zukünftig seine OID&#8217;s auflösen möchte, muss sich nun neu im Non-Free Repository bedienen. Dort steht [...]]]></description>
			<content:encoded><![CDATA[<p>Dieses Howto soll ein kleiner Quickstart in den &#8220;neuen&#8221; SNMPD-Deamon unter Debian Squeeze sein. In diesem Fall soll der Dienst so konfiguriert werden, dass Systeminformationen über SNMP (z.B. <a href="http://blog.alonso.ch/tag/nagios/">Nagios</a>,<a href="http://blog.alonso.ch/tag/cacti/">Cacti</a>) abgefragt werden können.</p>
<p>Installation der Pakete:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> snmp</pre></div></div>

<p>Wer auch zukünftig seine OID&#8217;s auflösen möchte, muss sich nun neu im Non-Free Repository bedienen. Dort steht das entsprechende Paket &#8220;<em>snmp-mibs-downloader</em>&#8221; bereit.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> snmp-mibs-downloader</pre></div></div>

<p>Das wars, der SNMPD-Deamon müsste mal &#8220;laufen&#8221;. Test mittels dem entsprechenden init.d Script möglich</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>snmpd status</pre></div></div>

<p>Dort müsste man den Erfolg der bisher äussert komplexen Installation nun mittels &#8220;<em>snmpd is running</em>&#8221; bestätigt kriegen.</p>
<p><strong>Weiter gehts mit der Konfiguration:</strong><br />
<span id="more-141"></span></p>
<p>Offiziell steht das Tool <em>snmpconf</em> bereit, mit welchem man per Wizzard den Dienst konfigurieren kann. Ich pers. finde dieses Tool allerdings eher verwirrend und ineffizient. In diesem Beispiel sollen lediglich die Systeminformationen plus ein paar &#8220;externe&#8221; Scripts auf Distanz mittes SNMP v1/v2 abgefragt werden können, daher reicht eine recht magere Konfiguration. </p>
<p>/etc/snmp/snmpd.conf</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># Netzwerk
agentAddress  udp:161
&nbsp;
#Zugriffsteuerung
rocommunity public nagioshost.hallo.welt
&nbsp;
# Kontaktinformationen
syslocation Ich bin hier
syscontact ich@hallo.welt
&nbsp;
# Systemchecks
includeAllDisks  10%
load   12 10 5
&nbsp;
#Erweiterungen
exec meintest   /usr/local/bin/meintest.sh</pre></div></div>

<p>Erwähnenswert ist hier der &#8220;neue&#8221; Parameter <em>agentAddress</em> , welcher den Deamon standartmässig nur auf localhost (udp:127.0.0.1:161) bindet. Hier wahlweise die gewünschte Interface-Adresse verwenden, oder wie in meinem Beispiel auf allen IP&#8217;s des Systems horchen lassen. Alle übrigen Parameter haben sich bei Squeeze wenig verändert. Die Zugriffsteuerung wurde sogar wesentlich vereinfacht über ein view konzept &#8211; welches im aufgezeigten Beispiel allerdings komplett weggelassen wurde. Die definierte Host/Community Kombination hat so einen kompletten Lesezugriff.</p>
<p>Den Deamon neu starten &#8211; fertig:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>snmpd restart</pre></div></div>

<p>Auch hier lohnt es sich danach ein weiteres mal den &#8220;status&#8221; abzufragen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>snmpd status</pre></div></div>

<p>Sofern vorhanden, müssen nun noch die entsprechenden Regeln in der Firewall ergänzt werden (TCP/UDP Port 161), damit der Zugriff auf Distanz auch wirklich klappt.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/paste-bin/howto-snmpd-unter-debian-squeeze/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Courier SSL Zertifikate erneuern (Debian)</title>
		<link>http://blog.alonso.ch/paste-bin/courier-ssl-zertifikate-erneuern-debian/</link>
		<comments>http://blog.alonso.ch/paste-bin/courier-ssl-zertifikate-erneuern-debian/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 23:58:59 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[Courier]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[paste.bin]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=136</guid>
		<description><![CDATA[Wenn der Courier IMAP und/oder POP3 Server unter Debian als Paket installiert wird, erstellt selbiges automatisch die selbstsignierten SSL-Zertifikate. Diese haben per default eine Laufzeit von 1 Jahr und müssen entsprechend erneuert werden. Unter Debian gibts dazu direkt passende Werkzeuge.. Alte Zertifikate sichern: cd /etc/courier/ mv imapd.pem imapd.pem.old mv pop3d.pem pop3d.pem.old Neue Zertifikate erstellen: mkimapdcert [...]]]></description>
			<content:encoded><![CDATA[<p>Wenn der Courier IMAP und/oder POP3 Server unter Debian als Paket installiert wird, erstellt selbiges automatisch die selbstsignierten SSL-Zertifikate. Diese haben per default eine Laufzeit von 1 Jahr und müssen entsprechend erneuert werden. Unter Debian gibts dazu direkt passende Werkzeuge..</p>
<p>Alte Zertifikate sichern:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>courier<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> imapd.pem imapd.pem.old
<span style="color: #c20cb9; font-weight: bold;">mv</span> pop3d.pem pop3d.pem.old</pre></div></div>

<p><span id="more-136"></span><br />
Neue Zertifikate erstellen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mkimapdcert
mkpop3dcert</pre></div></div>

<p>Courier-SSL Dienste neu starten:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>courier-pop-ssl restart <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>courier-imap-ssl restart</pre></div></div>

<p>So &#8211; schon hat man wieder 1 Jahr lang Ruhe.. <img src='http://blog.alonso.ch/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/paste-bin/courier-ssl-zertifikate-erneuern-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mySQL Information Schema: Tables</title>
		<link>http://blog.alonso.ch/paste-bin/mysql-information-schema-tables/</link>
		<comments>http://blog.alonso.ch/paste-bin/mysql-information-schema-tables/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 23:22:48 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[mySQL]]></category>
		<category><![CDATA[paste.bin]]></category>
		<category><![CDATA[Query]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=117</guid>
		<description><![CDATA[Die Information Schemas unter mySQL liefern praktisch alle relevanten Informationen über die DB und deren Inhalt. Besonders praktisch für Anwender welche kein UI (z.B. phpmyadmin) zur Verfügung haben und mit der mySQL-Konsole arbeiten müssen (dürfen/können!). Sehr informativ sind die Table Schemas. Folgendes Query listet alle Tabellen, deren Storage Engine, Kollation und die Anzahl Datensätze zurück: [...]]]></description>
			<content:encoded><![CDATA[<p>Die <a href="http://dev.mysql.com/doc/refman/5.1/de/information-schema.html">Information Schemas</a> unter mySQL liefern praktisch alle relevanten Informationen über die DB und deren Inhalt. Besonders praktisch für Anwender welche kein UI (z.B. <a href="http://www.phpmyadmin.net">phpmyadmin</a>) zur Verfügung haben und mit der mySQL-Konsole arbeiten müssen (dürfen/können!). </p>
<p>Sehr informativ sind die <a href="http://dev.mysql.com/doc/refman/5.1/de/tables-table.html">Table Schemas</a>.</p>
<p>Folgendes Query listet alle Tabellen, deren <a href="http://blog.alonso.ch/tech/database/mysql/vergleich-der-wichtigsten-storage-engines-memory-innodb-und-myisam/">Storage Engine</a>, Kollation und die Anzahl Datensätze zurück:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> table_schema<span style="color: #000033;">,</span> table_name<span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">engine</span><span style="color: #000033;">,</span> table_collation<span style="color: #000033;">,</span> table_rows 
<span style="color: #990099; font-weight: bold;">from</span> information_schema.<span style="color: #990099; font-weight: bold;">tables</span> 
<span style="color: #990099; font-weight: bold;">where</span> table_schema <span style="color: #CC0099; font-weight: bold;">like</span> <span style="color: #008000;">'mydb<span style="color: #008080; font-weight: bold;">%</span>'</span><span style="color: #000033;">;</span></pre></div></div>

<p><span id="more-117"></span></p>
<p>Resultat (z.B. WordPress Blog DB):</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">select</span> table_schema<span style="color: #000033;">,</span> table_name<span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">engine</span><span style="color: #000033;">,</span> table_collation<span style="color: #000033;">,</span> table_rows 
<span style="color: #990099; font-weight: bold;">from</span> information_schema.<span style="color: #990099; font-weight: bold;">tables</span> 
<span style="color: #990099; font-weight: bold;">where</span> table_schema <span style="color: #CC0099; font-weight: bold;">like</span> <span style="color: #008000;">'mydb<span style="color: #008080; font-weight: bold;">%</span>'</span><span style="color: #000033;">;</span>
<span style="color: #CC0099;">+--------------+-----------------------+--------+-----------------+------------+</span>
<span style="color: #CC0099;">|</span> table_schema <span style="color: #CC0099;">|</span> table_name            <span style="color: #CC0099;">|</span> <span style="color: #990099; font-weight: bold;">engine</span> <span style="color: #CC0099;">|</span> table_collation <span style="color: #CC0099;">|</span> table_rows <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+--------------+-----------------------+--------+-----------------+------------+</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_commentmeta        <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">0</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_comments           <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">3</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_contact_form_7     <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">1</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_links              <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">2</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_options            <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>        <span style="color: #008080;">269</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_postmeta           <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>         <span style="color: #008080;">69</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_posts              <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>        <span style="color: #008080;">103</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_prli_clicks        <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">1</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_prli_groups        <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">0</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_prli_link_metas    <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">0</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_prli_links         <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">1</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_term_relationships <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>        <span style="color: #008080;">163</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_term_taxonomy      <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>         <span style="color: #008080;">56</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_terms              <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>         <span style="color: #008080;">50</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_usermeta           <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>         <span style="color: #008080;">16</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_users              <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">1</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+--------------+-----------------------+--------+-----------------+------------+</span>
<span style="color: #008080;">16</span> rows <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.74</span> sec<span style="color: #FF00FF;">&#41;</span></pre></div></div>

<p>Natürlich sind hier auch weitere Informationen abrufbar. Erste Hilfe bietet hier einmal mehr die <a href="http://dev.mysql.com/doc/refman/5.1/de/tables-table.html">mySQL Dok</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/paste-bin/mysql-information-schema-tables/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t: Produktive Datenbankabfragen mit Select * from &#8230;</title>
		<link>http://blog.alonso.ch/tech/database/dont-produktive-datenbankabfragen-mit-select-from/</link>
		<comments>http://blog.alonso.ch/tech/database/dont-produktive-datenbankabfragen-mit-select-from/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 15:34:08 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[Datenbanken]]></category>
		<category><![CDATA[Dos & Don'ts]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=111</guid>
		<description><![CDATA[Mittels Cacti konnten wir einen beachtlichen Anstieg des mySQL Traffics auf einem Shared Hosting Server feststellen &#8211; welcher langsam aber sicher die Performance des Servers beeinträchtigte. Ein einfaches SHOW FULL PROCESSLIST; auf der mySQL-Konsole dieses Servers brachte folgendes Query mit sehr kurzen Intervallen und einer grossen Laufzeit zum vorschein: SELECT * FROM hits ORDER by [...]]]></description>
			<content:encoded><![CDATA[<p>Mittels <a href="http://www.cacti.net">Cacti</a> konnten wir einen beachtlichen Anstieg des mySQL Traffics auf einem Shared Hosting Server feststellen &#8211; welcher langsam aber sicher die Performance des Servers beeinträchtigte.</p>
<p>Ein einfaches</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SHOW</span> <span style="color: #990099; font-weight: bold;">FULL</span> PROCESSLIST<span style="color: #000033;">;</span></pre></div></div>

<p> auf der mySQL-Konsole dieses Servers brachte folgendes Query mit sehr kurzen Intervallen und einer grossen Laufzeit zum vorschein:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">FROM</span> hits <span style="color: #990099; font-weight: bold;">ORDER by</span> userid <span style="color: #990099; font-weight: bold;">DESC</span></pre></div></div>

<p>Somit war auch die verdächtige Datenbank &#8211; und dadurch auch der verantwortliche Account erruiert. Ein kurzer Blick auf das Schema dieser Datenbank/Tabelle zeigte folgendes:</p>
<ul>
<li>> 1&#8217;000&#8217;000 Datensätze!</li>
<li>Kein Index auf userid!</li>
</ul>
<p><span id="more-111"></span></p>
<p>Als erstes wurde mal userid indexiert, was zwar die Queryperformance deutlich verbesserte &#8211; aber die Last des Servers immernoch überdurchschnittlich beanspruchte.</p>
<p>Ich konnte mir spontan nicht erklären, wesshalb jemand den kompletten Inhalt dieser Tabelle auslesen sollte. Alleine der fehlende Index und das &#8220;Select *&#8221; waren für mich ein Indiz, dass hier KEIN Profi am Werk war. Mich packte der Ergeiz und ich warf einen Blick auf den PHP-Code der entsprechenden Applikation. Es handelte sich dabei um ein gut frequentiertes Toplisten-Script. Irgendwo im Code fand ich folgendes:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">..</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$useridgen</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM hits ORDER BY userid DESC&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$idgenaray</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$useridgen</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$userid</span><span style="color: #339933;">=</span><span style="color: #000088;">$idgenaray</span><span style="color: #009900;">&#91;</span>userid<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">..</span></pre></div></div>

<p>Toll, diese Funktion macht also nichts anderes als die nächste ID für einen Datenbankeintrag zu ermitteln. <img src='http://blog.alonso.ch/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
<a href="http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html">Auto_Increment</a> war hier offenbar ein Fremdwort..</p>
<p>Nach einer Rücksprache mit dem betroffenen Kunden wurde die Applikation so minimal wie möglich angepasst.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$useridgen</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT max(userid) as userid FROM hits&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$idgenaray</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$useridgen</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$userid</span><span style="color: #339933;">=</span><span style="color: #000088;">$idgenaray</span><span style="color: #009900;">&#91;</span>userid<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Das neue Query liefert durch den SELECT max() nur noch genau 1 Datensatz zurück (statt > 1&#8217;000&#8217;000 vorher)! &#8211; erfüllt aber genau dieselbe Funktion innerhalb dieses Scriptes. Das Script selbst musste somit nicht weiter angepasst werden.</p>
<p>Die Auswirkung dieses Korrektur lässt sich auf folgenden Graphen auf beeindruckende Art und Weise erkennen:<br />
<a href="http://blog.alonso.ch/wp-content/uploads/cacti1.png"><img src="http://blog.alonso.ch/wp-content/uploads/cacti1.png" alt="" title="cacti" width="587" height="223" class="aligncenter size-full wp-image-113" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/tech/database/dont-produktive-datenbankabfragen-mit-select-from/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Querys so kompakt wie möglich halten</title>
		<link>http://blog.alonso.ch/tech/database/mysql/sql-querys-so-kompakt-wie-moglich-halten/</link>
		<comments>http://blog.alonso.ch/tech/database/mysql/sql-querys-so-kompakt-wie-moglich-halten/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 12:45:52 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[Dos & Don'ts]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=98</guid>
		<description><![CDATA[Setzten sie keine SELECT * FROM Statements ein wenn sie nicht zwingend ALLE informationen benötigen! Natürlich sollten auch unnötigen keine JOINS erstellt werden. Praxisbeispiel: Ein Kundenserver viel immer wieder durch schlechte Performance auf. Es handelte sich dabei um eine Forensoftware von Woltlab, welche mit ein paar Hacks erweitert wurde. Insgesammt umfasst die Datenbank an die [...]]]></description>
			<content:encoded><![CDATA[<p>Setzten sie keine SELECT * FROM Statements ein wenn sie nicht zwingend ALLE informationen benötigen! Natürlich sollten auch unnötigen keine JOINS erstellt werden.</p>
<p>Praxisbeispiel:<br />
Ein Kundenserver viel immer wieder durch schlechte Performance auf. Es handelte sich dabei um eine Forensoftware von Woltlab, welche mit ein paar Hacks erweitert wurde. Insgesammt umfasst die Datenbank an die 1.5 Millionen Posts in 300&#8217;000 Threads. Das Datenvolumen der Datenbank lag zu diesem Zeitpunkt bei rund  1.4GB. Zu Stosszeiten waren jeweils an die 250 User und Bots unterwegs..</p>
<p><span id="more-98"></span></p>
<p>Ein einfaches</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SHOW</span> <span style="color: #990099; font-weight: bold;">FULL</span> PROCESSLIST<span style="color: #000033;">;</span></pre></div></div>

<p> auf der mySQL-Konsole brachte folgendes Query mit einer sehr grossen Laufzeit zum vorschein:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span>
bb2_threads.<span style="color: #CC0099;">*</span><span style="color: #000033;">,</span>
bb2_icons.<span style="color: #CC0099;">*</span><span style="color: #000033;">,</span>
bb2_boards.<span style="color: #CC0099;">*</span><span style="color: #000033;">,</span>
bb2_users.username <span style="color: #990099; font-weight: bold;">as</span> lastposter
<span style="color: #990099; font-weight: bold;">FROM</span> bb2_threads
<span style="color: #000099;">LEFT</span> <span style="color: #990099; font-weight: bold;">JOIN</span> bb2_icons <span style="color: #990099; font-weight: bold;">USING</span> <span style="color: #FF00FF;">&#40;</span>iconid<span style="color: #FF00FF;">&#41;</span>
<span style="color: #000099;">LEFT</span> <span style="color: #990099; font-weight: bold;">JOIN</span> bb2_boards <span style="color: #990099; font-weight: bold;">ON</span> <span style="color: #FF00FF;">&#40;</span>bb2_threads.boardid<span style="color: #CC0099;">=</span>bb2_boards.boardid<span style="color: #FF00FF;">&#41;</span>
<span style="color: #000099;">LEFT</span> <span style="color: #990099; font-weight: bold;">JOIN</span> bb2_users <span style="color: #990099; font-weight: bold;">ON</span> <span style="color: #FF00FF;">&#40;</span>bb2_threads.lastposterid<span style="color: #CC0099;">=</span>bb2_users.userid<span style="color: #FF00FF;">&#41;</span>
<span style="color: #990099; font-weight: bold;">WHERE</span> bb2_threads.closed<span style="color: #CC0099;">!=</span><span style="color: #008080;">3</span> 
<span style="color: #990099; font-weight: bold;">ORDER BY</span> bb2_threads.lastposttime <span style="color: #990099; font-weight: bold;">DESC</span> <span style="color: #990099; font-weight: bold;">LIMIT</span> <span style="color: #008080;">0</span><span style="color: #000033;">,</span> <span style="color: #008080;">5</span></pre></div></div>

<p>Dieses Query ermittelt also die 5 aktuellsten Threads sammt Titel, Author und die entsprechenden ID&#8217;s für die Verlinkung und zeigt diese infos auf der Startseite an. Das Query hatte unverändert auf der Konsole trotz allen notwendigen Indexen eine Laufzeit von gut 3s &#8211; verursacht durch die gigantische Datenmenge und den notwendigen Filesort.</p>
<p>Nachdem ich mich in das Datenbankschema eingearbeitet habe &#8211; konnte ich das Query &#8220;etwas&#8221; bereinigen:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span>
bb2_threads.threadid<span style="color: #000033;">,</span>
bb2_threads.views<span style="color: #000033;">,</span>
bb2_threads.lastposterid<span style="color: #000033;">,</span>
bb2_threads.topic<span style="color: #000033;">,</span>
bb2_threads.lastposter
<span style="color: #990099; font-weight: bold;">FROM</span> bb2_threads
<span style="color: #000099;">LEFT</span> <span style="color: #990099; font-weight: bold;">JOIN</span> bb2_boards <span style="color: #990099; font-weight: bold;">ON</span> <span style="color: #FF00FF;">&#40;</span>bb2_threads.boardid<span style="color: #CC0099;">=</span>bb2_boards.boardid<span style="color: #FF00FF;">&#41;</span>
<span style="color: #990099; font-weight: bold;">WHERE</span> bb2_threads.closed<span style="color: #CC0099;">!=</span><span style="color: #008080;">3</span> 
<span style="color: #990099; font-weight: bold;">ORDER BY</span> bb2_threads.lastposttime <span style="color: #990099; font-weight: bold;">DESC</span> <span style="color: #990099; font-weight: bold;">LIMIT</span> <span style="color: #008080;">0</span><span style="color: #000033;">,</span> <span style="color: #008080;">5</span></pre></div></div>

<p>Der Output ist 100% identisch zum Original. Die Abfrage dauert jetzt allerdings nur noch knapp 0.2s!</p>
<p>Nur diese eine Anpassung hatte folgende Auswirkung auf die Serverlast (Ab KW51):<br />
<a href="http://blog.alonso.ch/wp-content/uploads/cacti.png"><img src="http://blog.alonso.ch/wp-content/uploads/cacti-300x129.png" alt="Cacti mySQL Graph" title="cacti" width="300" height="129" class="aligncenter size-medium wp-image-101" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/tech/database/mysql/sql-querys-so-kompakt-wie-moglich-halten/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mySQL Tuning Primer</title>
		<link>http://blog.alonso.ch/paste-bin/mysql-tuning-primer/</link>
		<comments>http://blog.alonso.ch/paste-bin/mysql-tuning-primer/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 12:40:58 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[mySQL]]></category>
		<category><![CDATA[paste.bin]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Tool]]></category>
		<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=96</guid>
		<description><![CDATA[Der mySQL Tuning Primer ist ein kleines Shellscript welches die mySQL-Statusinformationen (&#8220;SHOW STATUS&#8221;, &#8220;SHOW VARIABLES&#8221;) analysiert und in einen übersichtlichen Report mit Optimierungstips umwandelt. Ein gutes und effizientes Hilfsmittel zur Optimierung der Serverkonfiguration (my.cnf). Hilft beim optimieren von: Slow Query Log Max Connections Worker Threads Key Buffer Query Cache Sort Buffer Joins Temp Tables Table [...]]]></description>
			<content:encoded><![CDATA[<p>Der mySQL Tuning Primer ist ein kleines Shellscript welches die mySQL-Statusinformationen (&#8220;SHOW STATUS&#8221;, &#8220;SHOW VARIABLES&#8221;) analysiert und in einen übersichtlichen Report mit Optimierungstips umwandelt. Ein gutes und effizientes Hilfsmittel zur Optimierung der Serverkonfiguration (my.cnf).<br />
<span id="more-96"></span><br />
Hilft beim optimieren von:</p>
<ul>
<li>Slow Query Log</li>
<li>Max Connections</li>
<li>Worker Threads</li>
<li>Key Buffer</li>
<li>Query Cache</li>
<li>Sort Buffer</li>
<li>Joins</li>
<li>Temp Tables</li>
<li>Table (Open &#038; Definition) Cache</li>
<li>Table Locking</li>
<li>Table Scans (read_buffer)</li>
<li>Innodb Status </li>
</ul>
<p>Kompatibel mit allen gängigen mySQL Versionen.</p>
<p>Bereitgestellt wird der Tuning Primer von <a href="http://www.day32.com/MySQL/">Day32.com</a>. Download: <a href="http://www.day32.com/MySQL/tuning-primer.sh">mySQL Tuning primer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/paste-bin/mysql-tuning-primer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ideales mySQL Server Setup</title>
		<link>http://blog.alonso.ch/tech/database/mysql/ideales-mysql-server-setup/</link>
		<comments>http://blog.alonso.ch/tech/database/mysql/ideales-mysql-server-setup/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 12:39:00 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[mySQL]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=94</guid>
		<description><![CDATA[Die Optimierung des &#8220;Serversetups&#8221; wird in der Praxis gerne auf die Parameter in der zentralen Konfigurationsdatei my.cnf beschränkt. Folgende Punkte sollten allerdings (idealerweise) vorgängig beim Setup des Servers und beim zuweisen/mounten der Filesysteme beachtet werden, bedingt natürlich auch dass die Anforderungen und der Einsatzzweck der Datenbank bekannt sind. Verwenden sie einen möglichst aktuellen Kernel Verwenden [...]]]></description>
			<content:encoded><![CDATA[<p>Die Optimierung des &#8220;Serversetups&#8221; wird in der Praxis gerne auf die Parameter in der zentralen Konfigurationsdatei my.cnf beschränkt. Folgende Punkte sollten allerdings (idealerweise) vorgängig beim Setup des Servers und beim zuweisen/mounten der Filesysteme beachtet werden, bedingt natürlich auch dass die Anforderungen und der Einsatzzweck der Datenbank bekannt sind. </p>
<p><span id="more-94"></span></p>
<ul>
<li>Verwenden sie einen möglichst aktuellen Kernel</li>
<li>Verwenden möglichst keine Hardware-Virtualisierung (z.B. VMware, Virtual PC). </li>
<li>Legen sie die mySQL-Daten auf eigenes Filesystem/Partition, bzw. idealerweise auf eigene Disks</li>
<li>Verwenden sie für diese Datenpartition ein Raid-Setup mit hohem Schreibdurchsatz, also z.B. Raid1 statt Raid5. Dieser Punkt gewinnt an Priorität bei Datenbanken mit einem hohen Anteil an Insert/Update/Delete Statements.</li>
<li>Wählen sie bewusst das passende Filesystem und die Parameter für die Datenpartition. <a href="http://www.bullopensource.org/ext4/sqlbench/MyISAM/2GB/">Hier</a> finden sie einige Benchmarks zu diesem Thema. Beachten sie unbedingt die entsprechenden Risiken und Eigenschaften.</li>
<li>Mounten sie das Filesystem mit der Option &#8220;noatime&#8221;. Dadurch wird vermieden, dass der Kernel bei jedem Zugriff auf eine Datendatei den Inode aktualisert.
</li>
</ul>
<p>Das Optimieren mittels der my.cnf wird in einem späteren Artikel behandelt.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/tech/database/mysql/ideales-mysql-server-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

