<?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>Ta vie on s&#039;en fout!</title>
	<atom:link href="http://tavie.onsenfout.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tavie.onsenfout.com</link>
	<description>Mon bazar techno-miam</description>
	<lastBuildDate>Thu, 17 May 2012 10:11:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>DNS dynamique sécurisé avec nsupdate et BIND9</title>
		<link>http://tavie.onsenfout.com/2012/04/04/dns-dynamique-securise-avec-nsupdate-et-bind9/</link>
		<comments>http://tavie.onsenfout.com/2012/04/04/dns-dynamique-securise-avec-nsupdate-et-bind9/#comments</comments>
		<pubDate>Wed, 04 Apr 2012 17:45:58 +0000</pubDate>
		<dc:creator>François</dc:creator>
				<category><![CDATA[Bits]]></category>
		<category><![CDATA[bind 9]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[nsupdate]]></category>
		<category><![CDATA[squeeze]]></category>

		<guid isPermaLink="false">http://tavie.onsenfout.com/?p=1064</guid>
		<description><![CDATA[Testé avec Bind 9.7.3 sous Debian Squeeze, poste moniteur sous Debian Squeeze De nombreuses connexions internet ADSL ou satellite ne disposent pas d&#8217;une adresse IP publique fixe. Dès lors qu&#8217;on veut installer un serveur derrière ce type de liaison ou mettre en place un accès distant, on utilise généralement des services de DNS dynamique tels [...]<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><em>Testé avec Bind 9.7.3 sous Debian Squeeze, poste moniteur sous Debian Squeeze</em></p>
<p>De nombreuses connexions internet ADSL ou satellite ne disposent pas d&#8217;une adresse IP publique fixe. Dès lors qu&#8217;on veut installer un serveur derrière ce type de liaison ou mettre en place un accès distant, on utilise généralement des services de DNS dynamique tels que <a href="http://dyn.com/dns/" title="Dyn" target="_blank">Dyn</a> ou <a href="http://www.no-ip.com/" title="no-ip" target="_blank">no-ip</a>. Ces services restent très limités dans leur version gratuite.</p>
<p>L&#8217;idée est donc de pouvoir s&#8217;en passer en utilisant notre propre serveur DNS pour tenir à jour un enregistrement DNS du type monip.mondomaine.com qui pointera sur l&#8217;adresse IP externe courante de la connexion. L&#8217;enregistrement DNS sera mis à jour de façon sécurisée par l&#8217;utilitaire DNS <a href="http://www.debian-administration.org/articles/591" title="Using the dynamic DNS editor: nsupdate" target="_blank">nsupdate</a>.<span id="more-1064"></span></p>
<h3>Pré-requis</h3>
<ul>
<li>Un serveur DNS Bind 9.2 ou plus récent connecté directement à internet. Ce serveur doit être maître pour la zone qui contiendra l&#8217;enregistrement DNS choisi :<br />
Pour l&#8217;enregistrement <code>monip.onsenfout.com</code> le serveur doit être maître pour la zone <code>onsenfout.com</code>.</li>
<li>Une machine linux derrière la connexion à surveiller, ici j&#8217;utilise un serveur Debian Squeeze. Je l&#8217;appelle poste moniteur dans la suite de l&#8217;article.</li>
</ul>
<p></p>
<h3>Préparation du poste moniteur</h3>
<p>installer les utilitaires DNS</p>

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

<h3>Générer la paire de clés TSIG</h3>
<p>Il y a 2 méthodes pour sécuriser les mises à jours dynamiques du DNS : avec des clés TSIG ou avec des clés SIG(0). Les clés TSIG sont symétriques, la même clé est utilisée par le client et le serveur. A l&#8217;inverse, les clés SIG(0) sont asymétriques, ce qui est à priori plus sécurisé, mais la version actuelle de nsupdate dans Squeeze (<code>dnsutils 1:9.7.3.dfsg-1~squeeze4</code>) <a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=622084" target="_blank">plante avec les clés SIG(0)</a>. Je me suis donc rabattu sur TSIG en attendant que ça sèche.</p>
<p>La clé sera générée avec <a href="http://www.manpagez.com/man/8/dnssec-keygen/" title="man dnssec-keygen" target="_blank">dnssec-keygen</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dnssec-keygen <span style="color: #660033;">-a</span> HMAC-MD5 <span style="color: #660033;">-b</span> <span style="color: #000000;">512</span> <span style="color: #660033;">-n</span> HOST monip.onsenfout.com</pre></div></div>

<p>On obtient deux fichiers :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Kmonip.onsenfout.com.+157+?????.private
Kmonip.onsenfout.com.+157+?????.key</pre></div></div>

<p>Le contenu du fichier Kmonip.onsenfout.com.+157+13642.private est le suivant :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cat</span> Kmonip.onsenfout.com.+<span style="color: #000000;">157</span>+<span style="color: #000000;">13642</span>.private 
Private-key-format: v1.3
Algorithm: <span style="color: #000000;">157</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>HMAC_MD5<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Key: BXLFFCyzbVK1OxTu+<span style="color: #000000;">3</span><span style="color: #007800;">HaJ2YytB64Rxplat738Zk3UFWDeLtkfUYIwgbX83LYR5W6z7fRgGBcwgVD191KtOErMQ</span>==
Bits: <span style="color: #007800;">AAA</span>=
Created: <span style="color: #000000;">20120404104934</span>
Publish: <span style="color: #000000;">20120404104934</span>
Activate: <span style="color: #000000;">20120404104934</span></pre></div></div>

<p>C&#8217;est le moment de copier la valeur de la clé (après Key: ) dans le presse-papiers, on en aura besoin pour configurer le serveur DNS.</p>
<h3>Configuration du serveur DNS</h3>
<p>créer un fichier /etc/bind/keys.conf et y ajouter la clé publique :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">key monip.onsenfout.com {
	algorithm HMAC-MD5;
	secret &quot;BXLFFCyzbVK1OxTu+3HaJ2YytB64Rxplat738Zk3UFWDeLtkfUYIwgbX83LYR5W6z7fRgGBcwgVD191KtOErMQ==&quot;;
};</pre></div></div>

<p>Editer /etc/bind/named.conf.local et inclure le fichier de clé :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">include &quot;/etc/bind/keys.conf&quot;;</pre></div></div>

<p>Côté serveur il ne reste plus qu&#8217;à définir les autorisations de mise à jour de la zone. L&#8217;instruction update-policy va nous permettre d&#8217;autoriser la clé <code>monip.onsenfout.com</code> à modifier l&#8217;enregistrement DNS de type A <code>monip.onsenfout.com</code>, et seulement celui là :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">zone	&quot;onsenfout.com&quot; in {
	type master;
	file &quot;db.onsenfout.com&quot;;
	update-policy {
		grant monip.onsenfout.com. name monip.onsenfout.com. A;
	};</pre></div></div>

<p>On redémarre Bind :</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>bind9 restart</pre></div></div>

<h3>Test de la mise à jour dynamique</h3>
<p>Le serveur est prêt à recevoir des mises à jour dynamiques. Nous allons pouvoir vérifier que tout fonctionne en initialisant l&#8217;enregistrement DNS avec <code>nsupdate</code> à partir du poste moniteur. La <a href="http://linux.die.net/man/8/nsupdate" title="man nsupdate" target="_blank">syntaxe de nsupdate</a> est:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">nsupdate -k &lt;fichier clé privée&gt; -v &lt;fichier&gt;</pre></div></div>

<p><code>-v</code> force l&#8217;utilisation de TCP au lieu d&#8217;UDP<br />
<code>fichier</code> contient le jeu d&#8217;instructions à envoyer au serveur, s&#8217;il est omis nsupdate passe en mode interactif. </p>
<p>C&#8217;est ce qu&#8217;on va faire pour initialiser l&#8217;enregistrement <code>monip.onsenfout.com</code> avec l&#8217;adresse 0.0.0.0 et un TTL de 30. La commande <code>show</code> affiche la requète de mise à jour, <code>send</code> l&#8217;envoie au serveur :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">nsupdate -k Kmonip.onsenfout.com.+157+13642.private -v
&gt; zone onsenfout.com
&gt; update add monip.onsenfout.com. 30 A 0.0.0.0
&gt; show
Outgoing update query:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: UPDATE, status: NOERROR, id:      0
;; flags:; ZONE: 0, PREREQ: 0, UPDATE: 0, ADDITIONAL: 0
;; ZONE SECTION:
;onsenfout.com.			IN	SOA
&nbsp;
;; UPDATE SECTION:
monip.onsenfout.com.		30	IN	A	0.0.0.0
&gt; send
&gt; quit</pre></div></div>

<p>On vérifie que tout s&#8217;est bien passé en regardant les logs de Bind et en faisant un dig sur le serveur DNS :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">dig</span> +nocmd monip.onsenfout.com +noall +answer
monip.onsenfout.com.		<span style="color: #000000;">30</span>	IN	A	0.0.0.0</pre></div></div>

<h3>Le fichier journal</h3>
<p>Après la première mise à jour dynamique, on s&#8217;aperçoit qu&#8217;un nouveau fichier <code>db.onsenfout.com.jnl</code> a été créé dans le répertoire des fichiers de zones, <code>/var/cache/bind/</code> chez moi. On constate aussi que la commande dig retourne bien l&#8217;enregistrement demandé, mais que celui-ci n’apparaît pas dans le fichier de zone : lors des mises à jour dynamiques, Bind modifie la zone chargée en mémoire, stocke l&#8217;information dans le fichier journal de la zone avec une extension <code>.jnl</code>, et attend d&#8217;être peinard pour mettre à jour le fichier de zone. C&#8217;est un point important à prendre en compte si on doit éditer manuellement une zone comportant des enregistrements dynamiques.</p>
<p>Dans ce cas il faut suspendre les mises à jour de la zone et forcer l&#8217;écriture du journal avec <code>rndc freeze</code> :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rndc freeze onsenfout.com</pre></div></div>

<p>Editer la zone sans oublier d&#8217;incrémenter le numéro de série, rétablir les mises à jour et recharger la zone avec <code>rndc thaw</code> :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rndc thaw onsenfout.com</pre></div></div>

<p>Le fichier journal n&#8217;est pas directement lisible mais l&#8217;utilitaire <a href="http://linux.die.net/man/8/named-journalprint" title="man named-journalprint" target="_blank">named-journalprint</a> remédie au problème.</p>
<h3>Un p&#8217;tit script pour finir</h3>
<p>Maintenant que tout fonctionne il ne manque plus qu&#8217;un script placé en crontab, toutes les minutes par exemple :</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;"># Teste si l'ip publique a été modifiée et met à jour l'enregistrement DNS</span>
<span style="color: #666666; font-style: italic;"># Utilise la clé TSIG</span>
<span style="color: #666666; font-style: italic;"># François Grange 2012</span>
<span style="color: #666666; font-style: italic;"># Inits</span>
<span style="color: #007800;">ADMIN</span>=<span style="color: #ff0000;">&quot;xxxx@onsenfout.com&quot;</span>
<span style="color: #007800;">ZONE</span>=<span style="color: #ff0000;">&quot;onsenfout.com&quot;</span>
<span style="color: #007800;">RR</span>=<span style="color: #ff0000;">&quot;monip.<span style="color: #007800;">$ZONE</span>.&quot;</span>
<span style="color: #007800;">TTL</span>=<span style="color: #000000;">30</span>
<span style="color: #007800;">LAST_IP</span>=<span style="color: #ff0000;">&quot;0.0.0.0&quot;</span>
<span style="color: #007800;">LAST_IP_FILE</span>=<span style="color: #ff0000;">&quot;/var/local/lastip&quot;</span>
<span style="color: #007800;">FLAG_ERR</span>=<span style="color: #000000;">0</span>
<span style="color: #007800;">ERR_FILE</span>=<span style="color: #ff0000;">&quot;/var/local/dyndns.err&quot;</span>
<span style="color: #007800;">KEY_FILE</span>=<span style="color: #ff0000;">&quot;/etc/bind/keys/Kmonip.onsenfout.com.+157+13642.private&quot;</span>
<span style="color: #007800;">TMP_FILE</span>=<span style="color: #ff0000;">&quot;/tmp/dyndns.tmp&quot;</span>
<span style="color: #007800;">CUR_IP</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-O</span> - whatismyip.org<span style="color: #000000; font-weight: bold;">`</span>
sortie<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># mail si erreur ou modification</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$1</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<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;">-f</span> <span style="color: #007800;">$ERR_FILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #007800;">$ERR_FILE</span>
			<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$TMP_FILE</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;Erreur de mise à jour de <span style="color: #007800;">$RR</span>&quot;</span> <span style="color: #007800;">$ADMIN</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$TMP_FILE</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;Changement d'IP pour <span style="color: #007800;">$RR</span>&quot;</span> <span style="color: #007800;">$ADMIN</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$ERR_FILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$ERR_FILE</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<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;">$CUR_IP</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CUR_IP</span>&quot;</span> = <span style="color: #ff0000;">&quot;unknown&quot;</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;Impossible de récupérer l'IP actuelle - Abandon&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$TMP_FILE</span>
	sortie <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$LAST_IP_FILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #007800;">LAST_IP</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$LAST_IP_FILE</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<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: #ff0000;">&quot;<span style="color: #007800;">$LAST_IP</span>&quot;</span> = <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CUR_IP</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #666666; font-style: italic;"># L'adresse a changé</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;IP actuelle : <span style="color: #007800;">$CUR_IP</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$TMP_FILE</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;IP précédente : <span style="color: #007800;">$LAST_IP</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$TMP_FILE</span>
	<span style="color: #7a0874; font-weight: bold;">&#40;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;zone <span style="color: #007800;">$ZONE</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;update delete <span style="color: #007800;">$RR</span> A&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;update add <span style="color: #007800;">$RR</span> <span style="color: #007800;">$TTL</span> A <span style="color: #007800;">$CUR_IP</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;send&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> nsupdate <span style="color: #660033;">-k</span> <span style="color: #007800;">$KEY_FILE</span> <span style="color: #660033;">-v</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</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: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Echec de la mise à jour de <span style="color: #007800;">$RR</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$TMP_FILE</span>
		<span style="color: #007800;">FLAG_ERR</span>=<span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$CUR_IP</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$LAST_IP_FILE</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	sortie <span style="color: #007800;">$FLAG_ERR</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<h3>Liens</h3>
<p><span class="removed_link" title="http://ops.ietf.org/dns/dynupd/secure-ddns-howto.html">Secure dynamic DNS howto</span><br />
<a href="http://linux.yyz.us/nsupdate/" target="_blank">nsupdate: Painless Dynamic DNS</a><br />
<a href="http://www.mimiz.fr/linux/mise-en-place-dun-serveur-dns-dynamique/" target="_blank">Mise en place d&#8217;un serveur DNS dynamique</a></p>
<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></content:encoded>
			<wfw:commentRss>http://tavie.onsenfout.com/2012/04/04/dns-dynamique-securise-avec-nsupdate-et-bind9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Obtenir l&#8217;adresse IP publique en ligne de commande</title>
		<link>http://tavie.onsenfout.com/2012/03/26/obtenir-ladresse-ip-publique-en-ligne-de-commande/</link>
		<comments>http://tavie.onsenfout.com/2012/03/26/obtenir-ladresse-ip-publique-en-ligne-de-commande/#comments</comments>
		<pubDate>Mon, 26 Mar 2012 14:10:47 +0000</pubDate>
		<dc:creator>François</dc:creator>
				<category><![CDATA[Bits]]></category>
		<category><![CDATA[ligne de commande]]></category>
		<category><![CDATA[réseau]]></category>
		<category><![CDATA[wget]]></category>

		<guid isPermaLink="false">http://tavie.onsenfout.com/?p=1060</guid>
		<description><![CDATA[On peut utiliser un service web existant : wget -q -O - whatismyip.org Si on a un serveur web ce service est très facile à implémenter avec une page php d&#8217;une seule ligne : &#60;?php print $_SERVER&#91;'REMOTE_ADDR'&#93; ?&#62; Rating: 0.0/5 (0 votes cast)<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p>On peut utiliser un service web existant :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-O</span> - whatismyip.org</pre></div></div>

<p>Si on a un serveur web ce service est très facile à implémenter avec une page php d&#8217;une seule ligne :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">print</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></content:encoded>
			<wfw:commentRss>http://tavie.onsenfout.com/2012/03/26/obtenir-ladresse-ip-publique-en-ligne-de-commande/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimisations LogAnalyser</title>
		<link>http://tavie.onsenfout.com/2012/03/08/optimisations-loganalyser/</link>
		<comments>http://tavie.onsenfout.com/2012/03/08/optimisations-loganalyser/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 16:25:09 +0000</pubDate>
		<dc:creator>François</dc:creator>
				<category><![CDATA[Bits]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[loganalyser]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rsyslog]]></category>

		<guid isPermaLink="false">http://tavie.onsenfout.com/?p=1040</guid>
		<description><![CDATA[Dans un billet précédent je parlais de mon installation d&#8217;un serveur de logs centralisé avec rsyslog et LogAnalyser. Après quelques mois d&#8217;exploitation, les requêtes lancées depuis LogAnalyser sont devenues de plus en plus lentes, rendant l&#8217;outil pénible à utiliser. Il y a une bonne raison à ça : Avec la version actuelle du plugin MySQL [...]<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p>Dans un <a href="http://tavie.onsenfout.com/2011/07/05/consolidation-des-logs-avec-rsyslog-mysql-et-loganalyser/" title="Consolidation des logs avec rsyslog, MySQL et LogAnalyser" target="_blank">billet précédent</a> je parlais de mon installation d&#8217;un serveur de logs centralisé avec <a href="http://www.rsyslog.com/" target="_blank">rsyslog</a> et <a href="http://loganalyzer.adiscon.com/" target="_blank">LogAnalyser</a>. Après quelques mois d&#8217;exploitation, les requêtes lancées depuis LogAnalyser sont devenues de plus en plus lentes, rendant l&#8217;outil pénible à utiliser. Il y a une bonne raison à ça : Avec la version actuelle du plugin MySQL de rsyslog (v 4.6.4) les index ne sont pas créés dans la table SystemEvents à l&#8217;installation. Au début ça va, mais quand on a 25 millions d&#8217;enregistrements dans la table c&#8217;est pas vraiment optimal!<span id="more-1040"></span></p>
<p>La solution est d&#8217;indexer les champs qui serviront le plus souvent dans les requêtes, dans mon cas j&#8217;ai choisi <em>Facility</em>, <em>Priority</em>, <em>FromHost</em>, <em>SysLogTag</em> et <em>DeviceReportedTime</em>.</p>
<p>Voici les requêtes que j&#8217;ai exécutées sur la base Syslog :</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">ALTER</span> <span style="color: #990099; font-weight: bold;">TABLE</span> <span style="color: #008000;">`SystemEvents`</span> <span style="color: #990099; font-weight: bold;">ADD</span> <span style="color: #990099; font-weight: bold;">INDEX</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`Facility`</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">ALTER</span> <span style="color: #990099; font-weight: bold;">TABLE</span> <span style="color: #008000;">`SystemEvents`</span> <span style="color: #990099; font-weight: bold;">ADD</span> <span style="color: #990099; font-weight: bold;">INDEX</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`Priority`</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">ALTER</span> <span style="color: #990099; font-weight: bold;">TABLE</span> <span style="color: #008000;">`SystemEvents`</span> <span style="color: #990099; font-weight: bold;">ADD</span> <span style="color: #990099; font-weight: bold;">INDEX</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`FromHost`</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">ALTER</span> <span style="color: #990099; font-weight: bold;">TABLE</span> <span style="color: #008000;">`SystemEvents`</span> <span style="color: #990099; font-weight: bold;">ADD</span> <span style="color: #990099; font-weight: bold;">INDEX</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`SysLogTag`</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">ALTER</span> <span style="color: #990099; font-weight: bold;">TABLE</span> <span style="color: #008000;">`SystemEvents`</span> <span style="color: #990099; font-weight: bold;">ADD</span> <span style="color: #990099; font-weight: bold;">INDEX</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`DeviceReportedTime`</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div>

<p>Autant dire qu&#8217;il vaut mieux créer les index à l&#8217;installation, j&#8217;ai perdu une bonne demie-heure de logs à faire la manip sur un serveur en prod <img src='http://tavie.onsenfout.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Ça augmente la taille de la base d&#8217;environ 15%, mais les temps de réponse de LogAnalyser sont nettement améliorés.</p>
<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></content:encoded>
			<wfw:commentRss>http://tavie.onsenfout.com/2012/03/08/optimisations-loganalyser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dump lisible avec hexdump</title>
		<link>http://tavie.onsenfout.com/2012/03/07/dump-lisible-avec-hexdump/</link>
		<comments>http://tavie.onsenfout.com/2012/03/07/dump-lisible-avec-hexdump/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 13:09:02 +0000</pubDate>
		<dc:creator>François</dc:creator>
				<category><![CDATA[Bits]]></category>
		<category><![CDATA[dump]]></category>
		<category><![CDATA[hexdump]]></category>

		<guid isPermaLink="false">http://tavie.onsenfout.com/?p=1033</guid>
		<description><![CDATA[Un petit mémo sur la commande hexdump, très commode pour visualiser les caractères non affichables dans une chaine ou un fichier, mais dont la syntaxe est quelque peu rébarbative. echo -e &#34;ligne1\nligne2&#34;&#124;hexdump -v -e '&#34;x&#34; 1/1 &#34;%02X&#34; &#34; &#34;' x6C x69 x67 x6E x65 x31 x0A x6C x69 x67 x6E x65 x32 x0A En plus [...]<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p>Un petit mémo sur la commande hexdump, très commode pour visualiser les caractères non affichables dans une chaine ou un fichier, mais dont la syntaxe est quelque peu rébarbative.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;ligne1<span style="color: #000099; font-weight: bold;">\n</span>ligne2&quot;</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">hexdump</span> <span style="color: #660033;">-v</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'&quot;x&quot; 1/1 &quot;%02X&quot; &quot; &quot;'</span>
x6C x69 x67 x6E x65 x31 x0A x6C x69 x67 x6E x65 x32 x0A</pre></div></div>

<p>En plus mémorisable il y a ça aussi :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;ligne1<span style="color: #000099; font-weight: bold;">\n</span>ligne2&quot;</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">hexdump</span> <span style="color: #660033;">-v</span> <span style="color: #660033;">-C</span>
00000000  6c <span style="color: #000000;">69</span> <span style="color: #000000;">67</span> 6e <span style="color: #000000;">65</span> <span style="color: #000000;">31</span> 0a 6c  <span style="color: #000000;">69</span> <span style="color: #000000;">67</span> 6e <span style="color: #000000;">65</span> <span style="color: #000000;">32</span> 0a        <span style="color: #000000; font-weight: bold;">|</span>ligne1.ligne2.<span style="color: #000000; font-weight: bold;">|</span>
0000000e</pre></div></div>

<h3>Liens</h3>
<p><a href="http://www.manpagez.com/man/1/hexdump/">La manpage (courage!)</a><br />
<a href="http://256.com/gray/docs/misc/hexdump_manual_how_to.html">Manual on How to Use the Hexdump Unix Utility</a></p>
<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></content:encoded>
			<wfw:commentRss>http://tavie.onsenfout.com/2012/03/07/dump-lisible-avec-hexdump/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mettre en oeuvre la réplication MySQL</title>
		<link>http://tavie.onsenfout.com/2012/03/06/mettre-en-oeuvre-la-replication-mysql/</link>
		<comments>http://tavie.onsenfout.com/2012/03/06/mettre-en-oeuvre-la-replication-mysql/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 18:11:06 +0000</pubDate>
		<dc:creator>François</dc:creator>
				<category><![CDATA[Bits]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://tavie.onsenfout.com/?p=1003</guid>
		<description><![CDATA[Testé sur Debian Lenny et Debian Squeeze &#8211; MySQL 5.0 et 5.1 La réplication MySQL permet de maintenir en temps réel une copie d&#8217;une ou plusieurs bases d&#8217;un serveur maître vers un serveur esclave. Ce n&#8217;est pas à proprement parler une technique de sauvegarde, mysqldump est plus adapté pour ça, mais c&#8217;est très efficace pour [...]<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><em>Testé sur Debian Lenny et Debian Squeeze &#8211; MySQL 5.0 et 5.1</em></p>
<p>La réplication MySQL permet de maintenir en temps réel une copie d&#8217;une ou plusieurs bases d&#8217;un serveur maître vers un serveur esclave. Ce n&#8217;est pas à proprement parler une technique de sauvegarde, <a href="http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html">mysqldump</a> est plus adapté pour ça, mais c&#8217;est très efficace pour implémenter un système à tolérance de panne. La mise en oeuvre n&#8217;est pas très compliquée mais un peu laborieuse et demande un minimum de rigueur dans la planification des étapes.<span id="more-1003"></span></p>
<p>Les tâches à réaliser seront les suivantes :</p>
<h3>sur le serveur maître </h3>
<p>Créer un utilisateur MySQL, ici ce sera <strong>replicuser</strong> avec le privilège &laquo;&nbsp;REPLICATION SLAVE&nbsp;&raquo;, et le droit de connexion depuis le serveur esclave.</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #000099;">USER</span> <span style="color: #008000;">'replicuser'</span>@<span style="color: #008000;">'serveur.esclave'</span> IDENTIFIED BY  <span style="color: #008000;">'&lt;mot<span style="color: #008080; font-weight: bold;">_</span>de<span style="color: #008080; font-weight: bold;">_</span>passe&gt;'</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">GRANT</span> REPLICATION SLAVE <span style="color: #990099; font-weight: bold;">ON</span> <span style="color: #CC0099;">*</span> . <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">TO</span>  <span style="color: #008000;">'replicuser'</span>@<span style="color: #008000;">'serveur.esclave'</span> IDENTIFIED BY  <span style="color: #008000;">'&lt;mot<span style="color: #008080; font-weight: bold;">_</span>de<span style="color: #008080; font-weight: bold;">_</span>passe&gt;'</span> <span style="color: #000033;">;</span></pre></div></div>

<p>Configurer l&#8217;enregistrement des logs binaires dans le fichier <strong>/etc/mysql/my.cnf</strong></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[mysqld]
# Un nombre entre 1 et 2^32-1, unique dans la communauté de réplication
server-id		= 123456
# Fichier des logs binaires
log_bin			= /var/log/mysql/mysql-bin.log
# Fichier des logs d'erreur (facultatif)
log_error		= /var/log/mysql/mysql-bin.err
# Liste des bases à répliquer
binlog_do_db	= base1, base2
# Si on veut répliquer toutes les bases, on ignorera binlog_do_db
# et on exclura les bases système avec bin_log_ignore_db :
#binlog_ignore_db	= mysql, information_schema
# Durée de rétention des logs
expire_logs_days	= 10
# Taille maxi des logs
max_binlog_size	= 100M</pre></div></div>

<p>redémarrer le serveur MySQL :</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 restart</pre></div></div>

<h3>sur le serveur esclave</h3>
<p>Donner un server-id dans le fichier <strong>/etc/mysql/my.cnf</strong></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[mysqld]
# Un nombre entre 1 et 2^32-1, unique dans la communauté de réplication
server-id		= 456789</pre></div></div>

<p>redémarrer le serveur MySQL :</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 restart</pre></div></div>

<p>Les deux serveurs sont maintenant configurés, il ne reste plus qu&#8217;à initialiser les bases sur le serveur esclave et démarrer la réplication. Les étapes détaillées sont les suivantes :</p>
<h3>sur le serveur maître </h3>
<p>Verrouiller les tables en écriture :</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">FLUSH <span style="color: #990099; font-weight: bold;">TABLES</span> <span style="color: #990099; font-weight: bold;">WITH</span> <span style="color: #990099; font-weight: bold;">READ</span> <span style="color: #990099; font-weight: bold;">LOCK</span><span style="color: #000033;">;</span></pre></div></div>

<p>Noter les valeurs &laquo;&nbsp;File&nbsp;&raquo; et &laquo;&nbsp;Position&nbsp;&raquo; de l&#8217;enregistrement des logs binaires avec la commande &laquo;&nbsp;SHOW MASTER STATUS&nbsp;&raquo;. Ces valeurs serviront à positionner les paramètres &laquo;&nbsp;MASTER_LOG_FILE&nbsp;&raquo; et &laquo;&nbsp;MASTER_LOG_POS&nbsp;&raquo; sur l&#8217;esclave :</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SHOW</span> MASTER <span style="color: #990099; font-weight: bold;">STATUS</span><span style="color: #000033;">;</span>
<span style="color: #CC0099;">+------------------+----------+--------------------------+------------------+</span>
<span style="color: #CC0099;">|</span> File             <span style="color: #CC0099;">|</span> <span style="color: #000099;">Position</span> <span style="color: #CC0099;">|</span> Binlog_Do_DB             <span style="color: #CC0099;">|</span> Binlog_Ignore_DB <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------------------+----------+--------------------------+------------------+</span>
<span style="color: #CC0099;">|</span> mysql<span style="color: #CC0099;">-</span><span style="color: #000099;">bin</span><span style="color: #008080;">.000029</span> <span style="color: #CC0099;">|</span>      <span style="color: #008080;">106</span> <span style="color: #CC0099;">|</span> base1<span style="color: #000033;">,</span> base2             <span style="color: #CC0099;">|</span>                  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------------------+----------+--------------------------+------------------+</span>
<span style="color: #008080;">1</span> row <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.00</span> sec<span style="color: #FF00FF;">&#41;</span></pre></div></div>

<h3>sur le serveur esclave </h3>
<p>Recopier les bases du serveur maître avec la commande mysqldump. On suppose ici que le serveur esclave puisse faire une connexion MySQL en root sur le serveur maître :</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysqldump <span style="color: #CC0099;">--</span>host serveur.maitre <span style="color: #CC0099;">--</span><span style="color: #000099;">user</span> root <span style="color: #CC0099;">--</span><span style="color: #000099;">password</span><span style="color: #CC0099;">=</span>mot.de.passe base1 <span style="color: #CC0099;">|</span> mysql <span style="color: #CC0099;">--</span><span style="color: #000099;">user</span> root <span style="color: #CC0099;">--</span><span style="color: #000099;">password</span><span style="color: #CC0099;">=</span>mot.de.passe base1
mysqldump <span style="color: #CC0099;">--</span>host serveur.maitre <span style="color: #CC0099;">--</span><span style="color: #000099;">user</span> root <span style="color: #CC0099;">--</span><span style="color: #000099;">password</span><span style="color: #CC0099;">=</span>mot.de.passe base2 <span style="color: #CC0099;">|</span> mysql <span style="color: #CC0099;">--</span><span style="color: #000099;">user</span> root <span style="color: #CC0099;">--</span><span style="color: #000099;">password</span><span style="color: #CC0099;">=</span>mot.de.passe base2</pre></div></div>

<h3>sur le serveur maître </h3>
<p>Déverrouiller les tables :</p>

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

<h3>sur le serveur esclave </h3>
<p>Stopper les threads esclaves :</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">STOP SLAVE<span style="color: #000033;">;</span></pre></div></div>

<p>Appliquer les paramètres de réplication. Les paramètres &laquo;&nbsp;MASTER_LOG_FILE&nbsp;&raquo; et &laquo;&nbsp;MASTER_LOG_POS&nbsp;&raquo; ont été récupérés précédemment sur le maître :</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">CHANGE MASTER <span style="color: #990099; font-weight: bold;">TO</span> \
	MASTER_HOST<span style="color: #CC0099;">=</span><span style="color: #008000;">'serveur.maitre'</span><span style="color: #000033;">,</span> \
	MASTER_USER<span style="color: #CC0099;">=</span><span style="color: #008000;">'replicuser'</span><span style="color: #000033;">,</span> \
	MASTER_PASSWORD<span style="color: #CC0099;">=</span><span style="color: #008000;">'mot<span style="color: #008080; font-weight: bold;">_</span>de<span style="color: #008080; font-weight: bold;">_</span>passe'</span><span style="color: #000033;">,</span> \
	MASTER_LOG_FILE<span style="color: #CC0099;">=</span><span style="color: #008000;">'log<span style="color: #008080; font-weight: bold;">_</span>binaire<span style="color: #008080; font-weight: bold;">_</span>courante'</span><span style="color: #000033;">,</span> \
	MASTER_LOG_POS<span style="color: #CC0099;">=</span>Position_log_binaire<span style="color: #000033;">;</span></pre></div></div>

<p>Lancer la réplication :</p>

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

<p>On peut vérifier l&#8217;état de la réplication avec la commande MySQL &laquo;&nbsp;SHOW PROCESSLIST&nbsp;&raquo;</p>
<h3>sur le serveur maître </h3>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">SHOW PROCESSLIST\G
*************************** 1. row ***************************
     Id: 27037
   User: replicuser
   Host: serveur.maitre:53723
     db: NULL
Command: Binlog Dump
   Time: 1172
  State: Has sent all binlog to slave; waiting for binlog to be updated
   Info: NULL</pre></div></div>

<h3>sur le serveur esclave</h3>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">SHOW PROCESSLIST\G
&nbsp;
*************************** 1. row ***************************
     Id: 1
   User: system user
   Host: 
     db: NULL
Command: Connect
   Time: 155886
  State: Waiting for master to send event
   Info: NULL
*************************** 2. row ***************************
     Id: 2
   User: system user
   Host: 
     db: NULL
Command: Connect
   Time: 1625
  State: Has read all relay log; waiting for the slave I/O thread to update it
   Info: NULL</pre></div></div>

<p>L&#8217;initialisation de la réplication étant assez fastidieuse, un petit script simplifiera la vie. En voici un plutôt basique, à configurer avec les valeurs de réplication réelles, et à exécuter sur le serveur esclave. Les tests sont sommaires, je ne donne aucune garantie sur le bon fonctionnement du script dans votre environnement!</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;"># --------------------------------------</span>
<span style="color: #666666; font-style: italic;"># Template initialisation de la réplication MySQL</span>
<span style="color: #666666; font-style: italic;"># A exécuter sur le serveur esclave</span>
<span style="color: #666666; font-style: italic;"># François Grange 2012</span>
<span style="color: #666666; font-style: italic;"># --------------------------------------</span>
<span style="color: #666666; font-style: italic;"># Inits</span>
<span style="color: #666666; font-style: italic;"># User MySQL esclave avec droits root</span>
<span style="color: #007800;">MYSQL_LUSER</span>=<span style="color: #ff0000;">&quot;root&quot;</span>
<span style="color: #007800;">MYSQL_LPASSWD</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #666666; font-style: italic;"># Saisie interactive</span>
<span style="color: #666666; font-style: italic;"># Serveur maitre</span>
<span style="color: #007800;">MYSQL_RHOST</span>=<span style="color: #ff0000;">&quot;adresse.du.serveur.maitre&quot;</span>
<span style="color: #666666; font-style: italic;"># User MySQL maitre avec droits root</span>
<span style="color: #007800;">MYSQL_RUSER</span>=<span style="color: #ff0000;">&quot;root&quot;</span>
<span style="color: #007800;">MYSQL_RPASSWD</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #666666; font-style: italic;"># Saisie interactive</span>
<span style="color: #666666; font-style: italic;"># User MySQL de réplication</span>
<span style="color: #007800;">MYSQL_REPL_USER</span>=<span style="color: #ff0000;">&quot;replicuser&quot;</span>
<span style="color: #007800;">MYSQL_REPL_PASSWD</span>=<span style="color: #ff0000;">&quot;mot_de_passe&quot;</span>
<span style="color: #666666; font-style: italic;"># Port SSH du serveur maitre</span>
<span style="color: #007800;">PSSH</span>=<span style="color: #000000;">22</span>
<span style="color: #666666; font-style: italic;"># Bases à synchroniser</span>
<span style="color: #007800;">dbl</span>=<span style="color: #ff0000;">&quot;base1 base2&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;+++<span style="color: #007800;">$(date)</span> Debut $0&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Saisie du mot de passe root local</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${#MYSQL_LPASSWD}</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;">do</span>
	<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-r</span> <span style="color: #660033;">-s</span> <span style="color: #660033;">-p</span> <span style="color: #ff0000;">&quot;Mot de passe <span style="color: #007800;">$MYSQL_LUSER</span> MySQL local : &quot;</span> MYSQL_LPASSWD
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Test de connexion à la base mysql locale</span>
<span style="color: #007800;">sql</span>=<span style="color: #ff0000;">&quot;USE mysql;&quot;</span>
<span style="color: #007800;">req</span>=<span style="color: #000000; font-weight: bold;">`</span>mysql <span style="color: #660033;">-u</span> <span style="color: #007800;">$MYSQL_LUSER</span> -p<span style="color: #007800;">$MYSQL_LPASSWD</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sql</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</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: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>(E) <span style="color: #007800;">$(date)</span> Impossible de se connecter à la base locale mysql avec l'utilisateur <span style="color: #007800;">$MYSQL_LUSER</span>. Abandon du traitement&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>(I) <span style="color: #007800;">$(date)</span> Connexion réussie à la base locale mysql.&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Saisie du mot de passe root distant</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${#MYSQL_RPASSWD}</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;">do</span>
	<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-r</span> <span style="color: #660033;">-s</span> <span style="color: #660033;">-p</span> <span style="color: #ff0000;">&quot;Mot de passe <span style="color: #007800;">$MYSQL_RUSER</span> MySQL <span style="color: #007800;">$MYSQL_RHOST</span> : &quot;</span> MYSQL_RPASSWD
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Test de connexion à la base mysql distante</span>
<span style="color: #007800;">sql</span>=<span style="color: #ff0000;">&quot;USE mysql;&quot;</span>
<span style="color: #007800;">req</span>=<span style="color: #000000; font-weight: bold;">`</span>mysql <span style="color: #660033;">--host</span> <span style="color: #007800;">$MYSQL_RHOST</span> <span style="color: #660033;">-u</span> <span style="color: #007800;">$MYSQL_RUSER</span> -p<span style="color: #007800;">$MYSQL_RPASSWD</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sql</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</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: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>(E) <span style="color: #007800;">$(date)</span> Impossible de se connecter à la base mysql de <span style="color: #007800;">$MYSQL_RHOST</span> avec l'utilisateur <span style="color: #007800;">$MYSQL_RUSER</span>. Abandon du traitement&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>(I) <span style="color: #007800;">$(date)</span> Connexion réussie à la base mysql de <span style="color: #007800;">$MYSQL_RHOST</span>.&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Verrouillage tables maitre</span>
<span style="color: #007800;">sql</span>=<span style="color: #ff0000;">&quot;FLUSH TABLES WITH READ LOCK;&quot;</span>
<span style="color: #007800;">req</span>=<span style="color: #000000; font-weight: bold;">`</span>mysql <span style="color: #660033;">--host</span> <span style="color: #007800;">$MYSQL_RHOST</span> <span style="color: #660033;">-u</span> <span style="color: #007800;">$MYSQL_RUSER</span> -p<span style="color: #007800;">$MYSQL_RPASSWD</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sql</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</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: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;(E) <span style="color: #007800;">$(date)</span> Impossible de verrouiller les tables du serveur maitre. Abandon du traitement&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: #666666; font-style: italic;"># Récupération de l'état du maitre</span>
<span style="color: #007800;">sql</span>=<span style="color: #ff0000;">&quot;SHOW MASTER STATUS;&quot;</span>
<span style="color: #007800;">req</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span>$<span style="color: #7a0874; font-weight: bold;">&#40;</span>mysql <span style="color: #660033;">--host</span> <span style="color: #007800;">$MYSQL_RHOST</span> <span style="color: #660033;">-u</span> <span style="color: #007800;">$MYSQL_RUSER</span> -p<span style="color: #007800;">$MYSQL_RPASSWD</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sql</span>&quot;</span> <span style="color: #660033;">-B</span> -s<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</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: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;(E) <span style="color: #007800;">$(date)</span> Echec de récupération de l'état du serveur maitre. Abandon du traitement&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>
<span style="color: #007800;">MYSQL_LOGFILE</span>=<span style="color: #800000;">${req[0]}</span>
<span style="color: #007800;">MYSQL_OFFSET</span>=<span style="color: #800000;">${req[1]}</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Fichier de log courant sur <span style="color: #007800;">$MYSQL_RHOST</span> : <span style="color: #007800;">$MYSQL_LOGFILE</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Offset courant sur <span style="color: #007800;">$MYSQL_RHOST</span> : <span style="color: #007800;">$MYSQL_OFFSET</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Dump individuel des bases</span>
<span style="color: #000000; font-weight: bold;">for</span> db <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$dbl</span>
<span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(date)</span> Dump base <span style="color: #007800;">$db</span> en cours...&quot;</span>
	mysqldump <span style="color: #660033;">--host</span> <span style="color: #007800;">$MYSQL_RHOST</span> <span style="color: #660033;">--user</span> <span style="color: #007800;">$MYSQL_RUSER</span> <span style="color: #660033;">--password</span>=<span style="color: #007800;">$MYSQL_RPASSWD</span> <span style="color: #007800;">$db</span> <span style="color: #000000; font-weight: bold;">|</span> mysql <span style="color: #660033;">--user</span> <span style="color: #007800;">$MYSQL_LUSER</span> <span style="color: #660033;">--password</span>=<span style="color: #007800;">$MYSQL_LPASSWD</span> <span style="color: #007800;">$db</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-gt</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: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(date)</span> Erreur Dump base <span style="color: #007800;">$db</span> sur <span style="color: #007800;">$MYSQL_RHOST</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(date)</span> Base <span style="color: #007800;">$db</span> synchronisée&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Déverrouillage tables maitre</span>
<span style="color: #007800;">sql</span>=<span style="color: #ff0000;">&quot;UNLOCK TABLES;&quot;</span>
<span style="color: #007800;">req</span>=<span style="color: #000000; font-weight: bold;">`</span>mysql <span style="color: #660033;">--host</span> <span style="color: #007800;">$MYSQL_RHOST</span> <span style="color: #660033;">-u</span> <span style="color: #007800;">$MYSQL_RUSER</span> -p<span style="color: #007800;">$MYSQL_RPASSWD</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sql</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</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: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;(E) <span style="color: #007800;">$(date)</span> Impossible de déverrouiller les tables du serveur maitre.&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Arret des threads esclaves</span>
<span style="color: #007800;">sql</span>=<span style="color: #ff0000;">&quot;STOP SLAVE;&quot;</span>
<span style="color: #007800;">req</span>=<span style="color: #000000; font-weight: bold;">`</span>mysql <span style="color: #660033;">-u</span> <span style="color: #007800;">$MYSQL_LUSER</span> -p<span style="color: #007800;">$MYSQL_LPASSWD</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sql</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</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: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;(E) <span style="color: #007800;">$(date)</span> Impossible de mettre fin à l'esclavage :-(&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: #666666; font-style: italic;"># Application des paramètres de réplication sur l'esclave</span>
<span style="color: #007800;">sql</span>=<span style="color: #ff0000;">&quot;CHANGE MASTER TO <span style="color: #000099; font-weight: bold;">\
</span>	MASTER_HOST='<span style="color: #007800;">$MYSQL_RHOST</span>', <span style="color: #000099; font-weight: bold;">\
</span>	MASTER_USER='<span style="color: #007800;">$MYSQL_REPL_USER</span>', <span style="color: #000099; font-weight: bold;">\
</span>	MASTER_PASSWORD='<span style="color: #007800;">$MYSQL_REPL_PASSWD</span>', <span style="color: #000099; font-weight: bold;">\
</span>	MASTER_LOG_FILE='<span style="color: #007800;">$MYSQL_LOGFILE</span>', <span style="color: #000099; font-weight: bold;">\
</span>	MASTER_LOG_POS=<span style="color: #007800;">$MYSQL_OFFSET</span>;&quot;</span>
<span style="color: #007800;">req</span>=<span style="color: #000000; font-weight: bold;">`</span>mysql <span style="color: #660033;">-u</span> <span style="color: #007800;">$MYSQL_LUSER</span> -p<span style="color: #007800;">$MYSQL_LPASSWD</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sql</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$req</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</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: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;(E) <span style="color: #007800;">$(date)</span> Impossible d'appliquer les paramètres de réplication.&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: #666666; font-style: italic;"># Démarrage de la réplication</span>
<span style="color: #007800;">sql</span>=<span style="color: #ff0000;">&quot;START SLAVE;&quot;</span>
<span style="color: #007800;">req</span>=<span style="color: #000000; font-weight: bold;">`</span>mysql <span style="color: #660033;">-u</span> <span style="color: #007800;">$MYSQL_LUSER</span> -p<span style="color: #007800;">$MYSQL_LPASSWD</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sql</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</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: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;(E) <span style="color: #007800;">$(date)</span> Impossible de démarrer la réplication.&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<h3>Lien</h3>
<p><a href="http://dev.mysql.com/doc/refman/5.0/fr/replication.html">La doc officielle</a></p>
<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></content:encoded>
			<wfw:commentRss>http://tavie.onsenfout.com/2012/03/06/mettre-en-oeuvre-la-replication-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Affichage des caractères accentués dans l&#8217;interface de Nagios</title>
		<link>http://tavie.onsenfout.com/2011/11/22/affichage-des-caracteres-accentues-dans-linterface-de-nagios/</link>
		<comments>http://tavie.onsenfout.com/2011/11/22/affichage-des-caracteres-accentues-dans-linterface-de-nagios/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 11:06:05 +0000</pubDate>
		<dc:creator>François</dc:creator>
				<category><![CDATA[Bits]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://tavie.onsenfout.com/?p=996</guid>
		<description><![CDATA[Testé sur Debian Wheezy &#8211; Nagios 3.2.3 (paquets Debian) Depuis le temps je m&#8217;étais fait une raison, je trouvais presque normal d&#8217;avoir ce genre de ligne dans mon interface web Nagios : SMTP OK - 0,012 sec. de temps de rÃ©ponse Je suis tombé au hasard du web sur LA solution simple et efficace pour [...]<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><em>Testé sur Debian Wheezy &#8211; Nagios 3.2.3 (paquets Debian)</em></p>
<p>Depuis le temps je m&#8217;étais fait une raison, je trouvais presque normal d&#8217;avoir ce genre de ligne dans mon interface web Nagios :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">SMTP OK - 0,012 sec. de temps de rÃ©ponse</pre></div></div>

<p><span id="more-996"></span>Je suis tombé au hasard du web sur <a href="http://www.silverlake.fr/index.php?post/2011/07/22/Interface-web-de-Nagios-et-caract%C3%A8res-accentu%C3%A9s" title="Interface web de Nagios et caractères accentués" target="_blank">LA solution</a> simple et efficace pour résoudre le problème, un grand merci à Silverlake:</p>
<ol>
<li>S&#8217;assurer que dans le fichier <strong>/etc/apache2/conf.d/charset</strong> la ligne &laquo;&nbsp;<strong>AddDefaultCharset UTF-8</strong>&nbsp;&raquo; soit bien décommentée.</li>
<li>Dans le fichier <strong>/etc/nagios3/cgi.cfg</strong> rechercher la ligne &laquo;&nbsp;<strong>escape_html_tags</strong>&nbsp;&raquo; et passer la valeur de <strong>1</strong> à <strong>0</strong>.</li>
</ol>
<p>Redémarrer apache et nagios</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">SMTP OK - 0,012 sec. de temps de réponse</pre></div></div>

<p>C&#8217;est plus joli comme ça, non?</p>
<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></content:encoded>
			<wfw:commentRss>http://tavie.onsenfout.com/2011/11/22/affichage-des-caracteres-accentues-dans-linterface-de-nagios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lapin au chou et aux pommes</title>
		<link>http://tavie.onsenfout.com/2011/11/08/lapin-au-chou-et-aux-pommes/</link>
		<comments>http://tavie.onsenfout.com/2011/11/08/lapin-au-chou-et-aux-pommes/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 18:41:05 +0000</pubDate>
		<dc:creator>François</dc:creator>
				<category><![CDATA[Miam]]></category>
		<category><![CDATA[chou]]></category>
		<category><![CDATA[cidre]]></category>
		<category><![CDATA[lapin]]></category>
		<category><![CDATA[pommes]]></category>
		<category><![CDATA[viandes]]></category>

		<guid isPermaLink="false">http://tavie.onsenfout.com/?p=986</guid>
		<description><![CDATA[C&#8217;est la saison du chou et des pommes, il ne reste qu&#8217;à attraper un lapin pour préparer cette recette facile, rapide et rassérénante. Pour 4 personnes 1 lapin coupé en morceaux 1 chou blanc 4 pommes 2 oignons moyen 200g de lardons fumés 2 feuilles de laurier 1 tablette de bouillon de volaille 40cl de [...]<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p>C&#8217;est la saison du chou et des pommes, il ne reste qu&#8217;à attraper un lapin pour préparer cette recette facile, rapide et rassérénante.</p>
<p><span id="more-986"></span><br />
<h3>Pour 4 personnes</h3>
<p></p>
<ul>
<li>1 lapin coupé en morceaux</li>
<li>1 chou blanc</li>
<li>4 pommes</li>
<li>2 oignons moyen</li>
<li>200g de lardons fumés</li>
<li>2 feuilles de laurier</li>
<li>1 tablette de bouillon de volaille</li>
<li>40cl de cidre brut</li>
<li>1 petit verre de Calvados (facultatif, mais tellement meilleur!)</li>
<li>un peu d&#8217;huile</li>
<li>Sel, poivre</li>
</ul>
<p></p>
<ol>
<li>Couper le chou en lanières et le blanchir 5mn à l&#8217;eau bouillante salée</li>
<li>Dans une cocotte en fonte faire revenir les lardons, réserver</li>
<li>Faire dorer les oignons dans la graisse des lardons, réserver</li>
<li>Ajouter si besoin un peu d&#8217;huile et faire revenir les morceaux de lapin, flamber au Calva si l&#8217;option a été retenue, saler, poivrer et réserver</li>
<li>Mettre le chou bien égouté dans la cocotte, ajouter les oignons, les lardons, le cidre, le laurier, la tablette de bouillon émiettée, sel poivre. Mélanger et laisser mijoter 15mn à couvert, on en profite pour éplucher les pommes et les couper en lamelles</li>
<li>Ajouter les pommes au chou, mélanger, et poser sur le lit de chou les morceaux de lapin. Continuer la cuisson 25-30 mn à couvert</li>
</ol>
<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></content:encoded>
			<wfw:commentRss>http://tavie.onsenfout.com/2011/11/08/lapin-au-chou-et-aux-pommes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VirtualBox : Erreur d&#8217;accès au sous-système USB</title>
		<link>http://tavie.onsenfout.com/2011/11/08/virtualbox-erreur-dacces-au-sous-systeme-usb/</link>
		<comments>http://tavie.onsenfout.com/2011/11/08/virtualbox-erreur-dacces-au-sous-systeme-usb/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 11:57:49 +0000</pubDate>
		<dc:creator>François</dc:creator>
				<category><![CDATA[Bits]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[virtualbox]]></category>
		<category><![CDATA[vm]]></category>

		<guid isPermaLink="false">http://tavie.onsenfout.com/?p=982</guid>
		<description><![CDATA[Host sous Debian Wheezy &#8211; VirtualBox 4.1.4 J&#8217;ai eu cette erreur dernièrement sur plusieurs machines en voulant accéder à la configuration de la VM, cela quelque soit l&#8217;OS de la VM. L&#8217;USB ne fonctionne alors pas sur la VM. Le code d&#8217;erreur est : NS_ERROR_FAILURE (0x00004005) Le remède : L&#8217;utilisateur actif doit faire partie du [...]<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><em>Host sous Debian Wheezy &#8211; VirtualBox 4.1.4</em></p>
<p>J&#8217;ai eu cette erreur dernièrement sur plusieurs machines en voulant accéder à la configuration de la VM, cela quelque soit l&#8217;OS de la VM. L&#8217;USB ne fonctionne alors pas sur la VM. </p>
<p>Le code d&#8217;erreur est :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">NS_ERROR_FAILURE (0x00004005)</pre></div></div>

<p><span id="more-982"></span><br />
<h3>Le remède :</h3>
<p>L&#8217;utilisateur actif doit faire partie du groupe <strong>vboxusers</strong>, et d&#8217;un groupe du même nom que l&#8217;utilisateur. Editer <strong>/etc/group</strong> et redémarrer la machine.</p>
<h3>Lien</h3>
<p><a href="https://forums.virtualbox.org/viewtopic.php?f=7&#038;t=40982" target="_blank">NS_ERROR_FAILURE (0&#215;00004005) on natty ubuntu</a></p>
<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></content:encoded>
			<wfw:commentRss>http://tavie.onsenfout.com/2011/11/08/virtualbox-erreur-dacces-au-sous-systeme-usb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Supprimer les mots de passe réseau enregistrés sous Windows</title>
		<link>http://tavie.onsenfout.com/2011/09/16/supprimer-les-mots-de-passe-reseau-enregistres-sous-windows/</link>
		<comments>http://tavie.onsenfout.com/2011/09/16/supprimer-les-mots-de-passe-reseau-enregistres-sous-windows/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 11:17:14 +0000</pubDate>
		<dc:creator>François</dc:creator>
				<category><![CDATA[Bits]]></category>
		<category><![CDATA[mots de passe]]></category>
		<category><![CDATA[réseau]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[windows XP]]></category>

		<guid isPermaLink="false">http://tavie.onsenfout.com/?p=957</guid>
		<description><![CDATA[Un petit mémo sur une commande que j&#8217;oublie toujours quand j&#8217;en ai besoin&#160;: Cliquer sur Démarrer / Exécuter, et taper control keymgr.dll Ça ouvre une interface graphique qui permet d&#8217;ajouter, modifier ou supprimer les identifiants d&#8217;accès aux ressources réseau. Bien pratique lorsque la case &#171;&#160;Mémoriser les informations&#160;&#187; a été cochée par erreur. La commande fonctionne [...]<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=2.5" /></div><div>Rating: 2.5/<strong>5</strong> (2 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p>Un petit mémo sur une commande que j&#8217;oublie toujours quand j&#8217;en ai besoin&nbsp;: Cliquer sur Démarrer / Exécuter, et taper</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">control keymgr.dll</pre></div></div>

<p>Ça ouvre une interface graphique qui permet d&#8217;ajouter, modifier ou supprimer les identifiants d&#8217;accès aux ressources réseau. Bien pratique lorsque la case &laquo;&nbsp;Mémoriser les informations&nbsp;&raquo; a été cochée par erreur.<br />
<span id="more-957"></span><br />
La commande fonctionne sous Windows XP, Vista et Windows 7, avec des interfaces légèrement différentes&nbsp;:<br />
<div id="attachment_963" class="wp-caption aligncenter" style="width: 406px"><a href="http://tavie.onsenfout.com/wp-content/uploads/2011/09/control_keymgr.dll_xp.jpg"><img src="http://tavie.onsenfout.com/wp-content/uploads/2011/09/control_keymgr.dll_xp.jpg" alt="" title="control_keymgr.dll_xp" width="396" height="326" class="size-full wp-image-963" /></a><p class="wp-caption-text">sous Windows XP</p></div><br />
<div id="attachment_965" class="wp-caption aligncenter" style="width: 310px"><a href="http://tavie.onsenfout.com/wp-content/uploads/2011/09/control_keymgr.dll_w7.jpg"><img src="http://tavie.onsenfout.com/wp-content/uploads/2011/09/control_keymgr.dll_w7-300x265.jpg" alt="" title="control_keymgr.dll_w7" width="300" height="265" class="size-medium wp-image-965" /></a><p class="wp-caption-text">sous Windows 7</p></div></p>
<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=2.5" /></div><div>Rating: 2.5/<strong>5</strong> (2 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></content:encoded>
			<wfw:commentRss>http://tavie.onsenfout.com/2011/09/16/supprimer-les-mots-de-passe-reseau-enregistres-sous-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Salade de Chou Pointu au Chorizo</title>
		<link>http://tavie.onsenfout.com/2011/07/06/salade-de-chou-pointu-au-chorizo/</link>
		<comments>http://tavie.onsenfout.com/2011/07/06/salade-de-chou-pointu-au-chorizo/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 15:40:08 +0000</pubDate>
		<dc:creator>François</dc:creator>
				<category><![CDATA[Miam]]></category>
		<category><![CDATA[chorizo]]></category>
		<category><![CDATA[chou]]></category>
		<category><![CDATA[légumes]]></category>
		<category><![CDATA[salade]]></category>

		<guid isPermaLink="false">http://tavie.onsenfout.com/?p=919</guid>
		<description><![CDATA[Dans le panier de l&#8217;AMAP Stanislas dépose depuis deux semaines un chou pointu. C&#8217;est un joli petit chou, très chou en somme, je trouve que le goût se rapproche de celui du chou blanc, avec une texture plus délicate. Celui de cette semaine nous a régalé avec cette salade toute simple. &#160;<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (1 vote cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><a href="http://tavie.onsenfout.com/wp-content/uploads/2011/07/chou-pointu.jpg"><img src="http://tavie.onsenfout.com/wp-content/uploads/2011/07/chou-pointu.jpg" alt="Chou pointu" title="Chou pointu" width="300" height="300" class="size-full wp-image-920" /></a><br />
Dans le panier de l&#8217;<a href="http://www.reseau-amap.org/" title="Réseau AMAP" target="_blank">AMAP</a> Stanislas dépose depuis deux semaines un chou pointu. C&#8217;est un joli petit chou, très chou en somme, je trouve que le goût se rapproche de celui du chou blanc, avec une texture plus délicate. Celui de cette semaine nous a régalé avec cette salade toute simple.<span id="more-919"></span>
<p>&nbsp;</p>
<p><a href="http://tavie.onsenfout.com/wp-content/uploads/2011/07/salade-de-chou-pointu-au-chorizo.jpg"><img src="http://tavie.onsenfout.com/wp-content/uploads/2011/07/salade-de-chou-pointu-au-chorizo-300x188.jpg" alt="Salade de chou pointu au chorizo" title="Salade de chou pointu au chorizo" width="300" height="188" size-medium wp-image-937" /></a></p>
<h3>Pour 4 personnes</h3>
</p>
<ul>
<li>1 chou pointu</li>
<li>1 chorizo</li>
<li>1 oignon moyen</li>
<li>3 gousses d&#8217;ail</li>
<li>1 botte de cives ou de ciboulette</li>
<li>2 càs de vinaigre de Xérès</li>
<li>4 càs de bonne huile d&#8217;olive</li>
<li>Sel, poivre, piment doux (facultatif)</li>
</ul>
<p>&nbsp;</p>
<ol>
<li>Couper le chou en 4, enlever le coeur et les feuilles abîmées, et le couper en lanières. Émincer l&#8217;oignon, hacher finement les gousses d&#8217;ail. Couper le chorizo en petits cubes.</li>
<li>Dans un Wok ou une sauteuse faire revenir le chorizo à feu moyen pour qu&#8217;il rende sa graisse. Égoutter et réserver.</li>
<li>Faire revenir l&#8217;oignon dans la graisse du chorizo jusqu&#8217;à ce qu&#8217;il soit transparent. Ajouter le chou, le chorizo, l&#8217;ail et faire revenir quelque minutes pour que le chou s&#8217;attendrisse tout en restant croquant. En fin de cuisson ajouter le vinaigre, sel, poivre et piment doux, faire cuire une minute de plus. Ajouter l&#8217;huile d&#8217;olive et laisser refroidir. </li>
<li>Avant de servir parsemer de cives hachées.</li>
</ol>
<br /><div><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (1 vote cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://tavie.onsenfout.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></content:encoded>
			<wfw:commentRss>http://tavie.onsenfout.com/2011/07/06/salade-de-chou-pointu-au-chorizo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

