Web-développeur et Administrateur système Freelance au Luxembourg, j'ai mis en place ce blog pour vous permettre de suivre l'évolution de ma société et partager avec vous quelques lignes de code.
Olivier
web 2.0

Une belle astuce pour décharger les serveurs MX secondaires

Trouvé ce matin chez Julien Wadin, fameux contributeur belge des mailing-lists OVH, cette astuce pour diminuer le nombre de spams envoyés à un serveur MX secondaire. Le piège est tout simple, il suffit d’ajouter une nouvelle entrée dans vos DNS avec un nouveau serveur MX de priorité très élevée, qui sera un alias vers votre serveur mail principal.

Les spammeurs ont en effet la fâcheuse habitude d’attaquer en premier les serveurs MX secondaires, souvent moins bien protégés. Ils se retrouveront alors en face de votre serveur mail principal.

Merci Julien.

De la virtualisation avec VirtualBox sous Gentoo

Disposant d’un vieux serveur P4 n’ayant pas les facultés de virtualisation, j’ai essayé VirtualBox de Sun pour déployer des machines virtuelles de test.

Il existe un très bon howto à cet endroit. Je n’ai pas de serveur X installé sur cette machine, et je ne veux pas en installer. L’avantage de Virtualbox, c’est qu’il permet de démarrer une machine virtuelle et de s’y connecter en Remote Desktop. Vous pouvez très bien mettre en place cette solution sur un serveur hébergé à Paris et faire tourner vous y connecter depuis chez vous (à voir niveau latence ce que ça vaut …)

xen ~ #  emerge -av virtualbox-bin

These are the packages that would be merged, in order:

Calculating dependencies… done!
[ebuild  N    ] x11-misc/util-macros-1.1.5  47 kB
[ebuild  N    ] media-libs/libmng-1.0.10  USE=“-lcms” 1,068 kB
[ebuild  N    ] media-libs/libsdl-1.2.13  USE=“-X -aalib -alsa -arts -custom-cflags -dga -directfb -esd -fbcon -ggi -libcaca -nas -noaudio -nojoystick -novideo -opengl -oss -pulseaudio -svga -xinerama -xv” 3,295 kB
[ebuild  N    ] virtual/libstdc++-3.3  0 kB
[ebuild  N    ] sys-apps/usermode-utilities-20040406-r1  59 kB
[ebuild  N    ] net-misc/bridge-utils-1.4  32 kB
[ebuild  N    ] app-emulation/virtualbox-modules-1.6.4  193 kB
[ebuild  N    ] x11-proto/xproto-7.0.10  140 kB
[ebuild  N    ] x11-proto/inputproto-1.4.2.1  47 kB
[ebuild  N    ] x11-libs/xtrans-1.0.3  USE=“-debug” 101 kB
[ebuild  N    ] x11-proto/kbproto-1.0.3  57 kB
[ebuild  N    ] x11-proto/renderproto-0.9.2  40 kB
[ebuild  N    ] x11-proto/xf86bigfontproto-1.1.2  37 kB
[ebuild  N    ] x11-proto/bigreqsproto-1.0.2  36 kB
[ebuild  N    ] x11-proto/xcmiscproto-1.1.2  36 kB
[ebuild  N    ] x11-proto/fixesproto-4.0  38 kB
[ebuild  N    ] x11-proto/xineramaproto-1.1.2  38 kB
[ebuild  N    ] x11-proto/randrproto-1.2.1  54 kB
[ebuild  N    ] x11-proto/xextproto-7.0.2  67 kB
[ebuild  N    ] x11-libs/libICE-1.0.4  USE=“-debug -ipv6″ 247 kB
[ebuild  N    ] x11-libs/libXau-1.0.3  USE=“-debug” 225 kB
[ebuild  N    ] x11-libs/libXdmcp-1.0.2  USE=“-debug” 216 kB
[ebuild  N    ] x11-libs/libX11-1.1.4  USE=“-debug -ipv6 -xcb” 1,540 kB
[ebuild  N    ] x11-libs/libSM-1.0.3  USE=“-debug -ipv6″ 219 kB
[ebuild  N    ] x11-libs/libXext-1.0.3  USE=“-debug” 256 kB
[ebuild  N    ] x11-libs/libXrender-0.9.2  USE=“-debug” 241 kB
[ebuild  N    ] x11-libs/libXfixes-4.0.3  USE=“-debug” 210 kB
[ebuild  N    ] x11-libs/libXt-1.0.5  USE=“-debug” 489 kB
[ebuild  N    ] x11-libs/libXft-2.1.12  USE=“-debug” 255 kB
[ebuild  N    ] x11-libs/libXcursor-1.1.9  USE=“-debug” 230 kB
[ebuild  N    ] x11-libs/libXrandr-1.2.1  USE=“-debug” 216 kB
[ebuild  N    ] x11-libs/libXi-1.1.3  USE=“-debug” 243 kB
[ebuild  N    ] x11-libs/libXinerama-1.0.2  USE=“-debug” 210 kB
[ebuild  N    ] virtual/xft-7.0  0 kB
[ebuild  N    ] x11-libs/qt-3.3.8-r4  USE=“mysql -cups -debug -doc -examples -firebird -gif -immqt -immqt-bc -ipv6 -nas -nis -odbc -opengl -postgres -sqlite -xinerama” 16,986 kB
[ebuild  N F  ] app-emulation/virtualbox-bin-1.6.4  USE=“additions vboxwebsrv headless -sdk” 21,029 kB

Total: 36 packages (36 new), Size of downloads: 48,180 kB
Fetch Restriction: 1 package (1 unsatisfied)

A la fin de la compilation, il nous est demandé de télécharger le binaire d’installation directement sur le site de VirtualBox:

* Please download the package from:
 *
 * http://download.virtualbox.org/virtualbox/1.6.4/VirtualBox-1.6.4-Linux_x86.run
 *
 * and then put it in /usr/portage/distfiles
 * Fetch failed for ‘app-emulation/virtualbox-bin-1.6.4′
 * GNU info directory index is up-to-date.
 * IMPORTANT: 4 config files in ‘/etc’ need updating.
 * See the CONFIGURATION FILES section of the emerge
 * man page to learn how to update config files.
xen ~ # cd /usr/local/src/
xen src # wget http://download.virtualbox.org/virtualbox/1.6.4/VirtualBox-1.6.4-Linux_x86.run
xen src # chmod +x VirtualBox-1.6.4-Linux_x86.run
xen src # ./VirtualBox-1.6.4-Linux_x86.run
Verifying archive integrity… All good.
Uncompressing VirtualBox for Linux installation……..
VirtualBox Version 1.6.4 (Tue Jul 29 20:45:09 CEST 2008) installation
Installing VirtualBox to /opt/VirtualBox-1.6.4
Building the VirtualBox kernel module

VirtualBox has been installed successfully.

You will find useful information about using VirtualBox in the user manual
  /opt/VirtualBox-1.6.4/UserManual.pdf
and in the user FAQ
  http://www.virtualbox.org/wiki/User_FAQ

We hope that you enjoy using VirtualBox.

Il suffit ensuite de suivre ce tutorial pour créer une Machine virtuelle à partir d’une ISO d’ubuntu server par exemple (256M de mémoire et 10G d’espace disque)

xen ~ # modprobe vboxdrv
xen ~ # VBoxManage createvm -name "Ubuntu 8.10 Server" -register
xen ~ # VBoxManage modifyvm "Ubuntu 8.10 Server" -memory "256MB" -acpi on -boot1 dvd -nic1 nat
xen ~ # VBoxManage createvdi -filename "Ubuntu_8_10_Server.vdi" -size 10000 -register
xen ~ # VBoxManage modifyvm "Ubuntu 8.10 Server" -hda "Ubuntu_8_10_Server.vdi"
xen ~ # VBoxManage registerimage dvd /home/ubuntu-8.10-server-i386.iso
xen ~ # VBoxManage modifyvm "Ubuntu 8.10 Server" -dvd /home/ubuntu-8.10-server-i386.iso
xen ~ # VBoxHeadless -startvm "Ubuntu 8.10 Server"
xen ~ # VirtualBox Headless Interface 1.6.4
(C) 2008 Sun Microsystems, Inc.
All rights reserved

Listening on port 3389

J’ai été confronté à un plantage de VBoxHeadless avec les sécurités PAX activées dans le kernel. Je les ai donc enlevées du noyau, il faut dans ce cas relancer le script d’installation de VirtualBox pour qu’il régénère un module pour le nouveau noyau.

Pour se connecter à la Machine Virtuelle, le RDC de Microsoft pour macosx ne semble pas fonctionner (les logs de connexions se trouvent dans /root/.VirtualBox/Machines/Ubuntu 8.10 Server/Logs si vous avez utilisé le compte root jusqu’à présent).

00:02:46.807 VRDP: Logoff: <NULL> (<NULL>) build 0. User: [<NULL>] Domain: [<NULL>] Reason 0xFFFFFFFF.
00:02:48.627 VRDP: New connection:
00:02:48.685 VRDP: Flags 0×0000001b
00:02:48.685 VRDP: Channel: [rdpdr] [1004]. Not supported.
00:02:48.685 VRDP: Channel: [rdpsnd] [1005]. Accepted.
00:02:48.685 VRDP: Channel: [cliprdr] [1006]. Accepted.
00:02:48.756 VRDP: Failed to process incoming RDP packet: VERR_VRDP_PROTOCOL_ERROR!!!
00:02:48.756 VRDP: The RDP packet content (read):

En utilisant le Remote Desktop de la version Windows, aucun problème. J’avoue ne pas avoir cherché beaucoup pour résoudre ce problème, peut-être ce message vous y aidera.

D’après mes premiers tests, je trouve cette solution très rapide à la fois à mettre en place, et également durant son fonctionnement. Lors de la mise à jour du système client, le cpu hôte n’est utilisé qu’à 1%, la mémoire à 20-30%. Pas mal du tout, reste à créer une Machine Virtuelle sous Gentoo pour voir.

Et vous, c’est lequel votre préféré ? Xen ? VMWare ? VirtualBox ?

PS: oui ma machine VirtualBox s’appelle Xen, et alors ? :)

Edit: pour que Ubuntu Server accepte de booter sous VirtualBox, il faut demander à ce dernier d’activer le support PAE:

xen ~ # VBoxManage modifyvm "Ubuntu 8.04 Server" -pae on
 

Edit 2 : aussitôt dit, aussitôt fait, pour installer Gentoo 2008 comme système client, il suffit d’utiliser les mêmes lignes que précédemment en modifiant juste celle-ci:

xen Logs # VBoxManage modifyvm "Gentoo 2008" -memory "256MB" -acpi on -boot1 dvd -nic1 nat -ioapic off
 

puis de démarrer une deuxième instance de VirtualBox sur un autre port:

xen Logs #  VBoxHeadless -startvm "Gentoo 2008" -p 3390
xen Logs # VirtualBox Headless Interface 1.6.4
(C) 2008 Sun Microsystems, Inc.
All rights reserved

Listening on port 3390

Il y a un très bon guide ici pour notamment les options du kernel à choisir.

Bloquer les tentatives de connexion SSH avec fail2ban

J’ai décidé d’installer ce matin sur tous mes serveurs et ceux de mes clients le script python fail2ban fourni par portage sur Gentoo (la dernière version stable du développeur est masquée il s’agit de la version net-analyzer/fail2ban-0.8.3)

Ce script analyse vos fichiers de logs et ajoute des règles dans votre firewall applicatif iptables pour bloquer les tentatives d’accès par ssh, apache, les requêtes DNS trop nombreuses, etc…

Voici un exemple de pollution récurrente:

Dec 9 10:03:28 server sshd[27836]: Invalid user ishihara from 121.134.8.168
Dec 9 10:03:30 server sshd[27842]: Invalid user hfujioka from 121.134.8.168
Dec 9 10:03:33 server sshd[27848]: Invalid user minami from 121.134.8.168
Dec 9 10:03:35 server sshd[27856]: Invalid user togashi from 121.134.8.168
Dec 9 10:03:37 server sshd[27865]: Invalid user nshino from 121.134.8.168
Dec 9 10:03:40 server sshd[27870]: Invalid user wataru from 121.134.8.168
Dec 9 10:03:42 server sshd[27875]: Invalid user yhashi from 121.134.8.168
Dec 9 10:03:44 server sshd[27883]: Invalid user gai from 121.134.8.168
Dec 9 10:03:46 server sshd[27888]: Invalid user sudomine from 121.134.8.168
Dec 9 10:03:49 server sshd[27893]: Invalid user tsutomu from 121.134.8.168
Dec 9 10:03:51 server sshd[27898]: Invalid user naoto from 121.134.8.168
Dec 9 10:03:53 server sshd[27903]: Invalid user shimizu from 121.134.8.168
Dec 9 10:03:56 server sshd[27908]: Invalid user yokoyama from 121.134.8.168
Dec 9 10:03:58 server sshd[27913]: Invalid user koki from 121.134.8.168
Dec 9 10:04:00 server sshd[27918]: Invalid user masashi from 121.134.8.168
Dec 9 10:04:02 server sshd[27923]: Invalid user tomonari from 121.134.8.168
Dec 9 10:04:05 server sshd[27933]: Invalid user higashi from 121.134.8.168
Dec 9 10:04:07 server sshd[27938]: Invalid user ryotaro from 121.134.8.168
Dec 9 10:04:09 server sshd[27943]: Invalid user mashima from 121.134.8.168
Dec 9 10:04:12 server sshd[27948]: Invalid user shuu from 121.134.8.168
Dec 9 10:04:14 server sshd[27953]: Invalid user oono from 121.134.8.168
Dec 9 10:04:16 server sshd[27958]: Invalid user oliver from 121.134.8.168
Dec 9 10:04:18 server sshd[27963]: Invalid user toyoc from 121.134.8.168

 

Il faut bien sur avoir au préalable installé iptables et le module dans le kernel qui va bien.

Après la traditionnelle phase de compilation du soft, il suffit de modifier les fichiers de configuration fournis qui par défaut ne font rien, ou du moins pas grand chose.

Commencez par whitelister votre(vos) ip(s) dans le fichier /etc/fail2ban/jail.conf histoire de ne passe retrouver bêtement coincé suite à une mauvaise configuration:

ignoreip = 127.0.0.1 xxx.xxx.xxx.xxx yyy.yyy.yyy.yyy

Réglez ensuite les 3 paramètres qui permettent de définir qu’une tentative de connexion doit être détectée comme malveillante:

# “bantime” is the number of seconds that a host is banned.
bantime = 6000
# A host is banned if it has generated “maxretry” during the last “findtime”
# seconds.
findtime = 600
# “maxretry” is the number of failures before a host get banned.
maxretry = 3

Puis vous pourrez utiliser les modules de détection déjà fournis, les modifier ou créer les vôtres. Par défaut sous Gentoo, les tentatives d’accès SSH sont loggés dans /var/log/messages, j’ai donc modifile le logpath correspondant:

[ssh-iptables]
enabled = true
filter = sshd
action = iptables[name=SSH, port=ssh, protocol=tcp]
sendmail-whois[name=SSH, dest=olivier@oxeron.com, sender=fail2ban-server@oxeron.com]
logpath = /var/log/messages
maxretry = 3

Et voilà, en 2 heures, environ 50 ips bloquées sur l’ensemble de mes machines.

Réparer un raid hardware DEGRADED avec tw_cli

Un ptit memo pour réutilisation future éventuelle :)

server bin # ./tw_cli info c0 u0

Unit     UnitType  Status         %RCmpl  %V/I/M  Port  Stripe  Size(GB)
————————————————————————
u0       RAID-1    DEGRADED       -       -       -     -       232.885   
u0-0     DISK      DEGRADED       -       -       p0    -       232.885   
u0-1     DISK      OK             -       -       p1    -       232.885 

server bin # ./tw_cli maint remove c0 p0
Removing port /c0/p0 … Done.

server bin # ./tw_cli maint rescan
Rescanning controller /c0 for units and drives …Done.
Found the following unit(s): [none].
Found the following drive(s): [/c0/p0].

server bin # ./tw_cli info c0

Unit  UnitType  Status         %RCmpl  %V/I/M  Stripe  Size(GB)  Cache  AVrfy
——————————————————————————
u0    RAID-1    DEGRADED       -       -       -       232.885   ON     -     

Port   Status           Unit   Size        Blocks        Serial
—————————————————————
p0     OK               -      232.88 GB   488397168     GEL231RB07BB9B     
p1     OK               u0     232.88 GB   488397168     GEL231RB05N20B   

server bin # ./tw_cli info c0 u0

Unit     UnitType  Status         %RCmpl  %V/I/M  Port  Stripe  Size(GB)
————————————————————————
u0       RAID-1    DEGRADED       -       -       -     -       232.885   
u0-0     DISK      DEGRADED       -       -       -     -       232.885   
u0-1     DISK      OK             -       -       p1    -       232.885

server bin # ./tw_cli maint rebuild c0 u0 p0
Sending rebuild start request to /c0/u0 on 1 disk(s) [0] … Done.

server bin # ./tw_cli info c0

Unit  UnitType  Status         %RCmpl  %V/I/M  Stripe  Size(GB)  Cache  AVrfy
——————————————————————————
u0    RAID-1    REBUILDING     0       -       -       232.885   ON     -     

Port   Status           Unit   Size        Blocks        Serial
—————————————————————
p0     DEGRADED         u0     232.88 GB   488397168     GEL231RB07BB9B     
p1     OK               u0     232.88 GB   488397168     GEL231RB05N20B

server bin #  ./tw_cli info c0 u0

Unit     UnitType  Status         %RCmpl  %V/I/M  Port  Stripe  Size(GB)
————————————————————————
u0       RAID-1    REBUILDING     0       -       -     -       232.885   
u0-0     DISK      DEGRADED       -       -       p0    -       232.885   
u0-1     DISK      OK             -       -       p1    -       232.885

server bin # ./tw_cli info c0 u0

Unit     UnitType  Status         %RCmpl  %V/I/M  Port  Stripe  Size(GB)
————————————————————————
u0       RAID-1    REBUILDING     6       -       -     -       232.885   
u0-0     DISK      DEGRADED       -       -       p0    -       232.885   
u0-1     DISK      OK             -       -       p1    -       232.885

OVH lance le serveur SSD

OVH a annoncé hier soir la mise en location de serveurs à disques SSD, s’appuyant sur la gamme X25-M d’Intel, reconnue comme étant très performante (voir ce test de débit de tom’s hardware en lecture et écriture et cet article de MatBe)

Les disques sont pour le moment limités à 80Go mais ce n’est qu’un début.

Voici les deux premières offres de cette nouvelle gamme:

EG SSD

——
- 1 Intel Xeon X3360, 4×2.83GHz, 12Mo L2, FSB 1333MHz, 45nm
- 8Go de RAM
- disques SSD 2×80Go en RAID-1 Hard X25-M
- le réseau de 1Gbps
- avec 24 IP fail-over
à 199Euro HT/mois
En savoir plus: http://www.ovh.com/fr/particulier/produits/eg_ssd.xml

MG SSD
——
- 2 Intel Xeon E5405, 2x 4×2.00GHz, 12Mo L2 FSB 1333MHz, 45nm
- 8Go de RAM
- disques SSD 2×80Go en RAID-1 Hard X25-M
- le réseau de 1Gbps
- avec 40 IP fail-over
à 249Euro HT/mois
En savoir plus: http://www.ovh.com/fr/particulier/produits/mg_ssd.xml

Y-aurait-il un généreux donateur dans la salle pour faire des tests de ces machines ? :)

ADSL2MUE et NAT

Le modem ADSL2MUE de Linksys ne permet pas via son interface de faire du NAT. J’en ai eu besoin pour router certains ports entrants vers un serveur. Il faut se connecter en ssh sur l’ip interne du modem avec le login root et le mot de passe de votre compte administrateur. Une fois connecté, on a accès à une interface en commandline:

cli>
advanced Modify settings in the advanced menu
apply Apply the current changes to the running system. Does not save the settings to flash
discard Discards any pending changes to the system
enable Change privilege level
exit Quit the CLI
help CLI usage help
lan Modify settings in the Lan menu
logoff Quit the CLI
product-info Product information
quit Quit the CLI
shell Go to the system shell
show Show current information
stats List modem stats
system Modify settings in the system menu
wan Modify settings in the Wan menu

en utilisant la commande shell, on obtient un shell busybox

cli> shell

Starting /bin/sh
Type exit to return to the CLI

BusyBox v0.61.pre (2004.10.19-18:15+0000) Built-in shell (ash)
Enter ‘help’ for a list of built-in commands.

#

Il suffit alors d’utiliser iptables pour router tous les ports entrant

# iptables -D FORWARD -i ppp0 -j DROP
# iptables -t nat -I PREROUTING -i ppp0 -j DNAT –to-destination 192.168.3.2
# iptables -L -t nat

Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT all — anywhere anywhere to:192.168.3.2

apache-2.2.4 apache-tools-2.2.9

En voulant mettre à jour apache sur un serveur aujourd’hui, je me suis retrouvé confronté à ceci:

 

emerge -av apache-tools

These are the packages that would be merged, in order:

Calculating dependencies… done!
[blocks B ] <www-servers/apache-2.2.4 (is blocking app-admin/apache-tools-2.2.9)
[ebuild U ] sys-devel/autoconf-wrapper-4-r3 [3.2] 0 kB
[ebuild N ] app-arch/lzma-utils-4.32.6 USE=”-nocxx” 467 kB
[ebuild U ] sys-devel/m4-1.4.11 [1.4.4] USE=”nls -examples%” 683 kB
[ebuild U ] sys-devel/autoconf-2.61-r2 [2.59-r7] USE=”-emacs” 1,364 kB
[ebuild U ] sys-devel/automake-wrapper-3-r1 [1-r1] 0 kB
[ebuild NS ] sys-devel/automake-1.10.1 896 kB
[ebuild NS ] dev-libs/apr-1.2.11 USE=”-debug -doc -ipv6 -urandom” 1,087 kB
[ebuild N ] dev-libs/libpcre-7.4 USE=”unicode -doc” 764 kB
[ebuild N ] virtual/mysql-5.0 0 kB
[ebuild NS ] dev-libs/apr-util-1.2.10 USE=”berkdb gdbm mysql -doc -ldap -postgres -sqlite -sqlite3″ 686 kB
[ebuild N ] app-admin/apache-tools-2.2.9 USE=”ssl” 4,827 kB

Une situation improbable où apache-2.2.4 bloque l’installation de apache-tools-2.2.9 alors que la version installé est une 2.0 qui va êtr emise à jour en 2.2.9

Bref, portage a un petit coup dans l’aile que je vais rectifier de ce pas doigt

emerge -av portage

These are the packages that would be merged, in order:

Calculating dependencies… done!
[blocks B ] <sys-apps/portage-2.1.4_rc1 (is blocking app-shells/bash-3.2_p33)

[blocks B ] <sys-apps/util-linux-2.13 (is blocking sys-apps/coreutils-6.10-r2)
[ebuild U ] sys-apps/sandbox-1.2.18.1-r2 [1.2.17] 231 kB
[ebuild U ] app-shells/bash-3.2_p33 [3.1_p16] USE=”nls -afs -bashlogger -plugins% -vanilla% (-build%)” 2,563 kB
[ebuild U ] sys-apps/portage-2.1.4.4 [2.1.1] USE=”-build -doc -epydoc% (-selinux)” LINGUAS=”-pl” 367 kB
*** Portage will stop merging at this point and reload itself,
then resume the merge.
[ebuild U ] sys-devel/automake-wrapper-3-r1 [1-r1] 0 kB
[ebuild U ] sys-devel/m4-1.4.11 [1.4.4] USE=”nls -examples%” 0 kB
[ebuild U ] sys-devel/autoconf-2.61-r2 [2.59-r7] USE=”-emacs” 1,364 kB
[ebuild NS ] sys-devel/automake-1.10.1 896 kB
[ebuild U ] sys-apps/coreutils-6.10-r2 [5.94-r1] USE=”acl nls (-selinux) -static -vanilla% -xattr% (-build%)” 3,691 kB
[ebuild U ] dev-python/pycrypto-2.0.1-r6 [2.0.1-r5] USE=”-bindist -gmp -test” 0 kB

Total size of downloads: 9,114 kB

!!! Error: The above package list contains packages which cannot be installed
!!! at the same time on the same system.

Un ptit coup de

emerge -pv “=sys-apps/util-linux-2.13.1.1″

pour résoudre le premier blocage, puis un

emerge =app-shells/bash-3.2_p17-r1

pour résoudre le deuxième, et portage se met à jour gentiment sans protester en 2.1.4.4

Il n’y a plus qu’à relancer l’installation d’apache et plus aucun blocage n’apparaît.
 

sa-update n’aime pas localhost

Si votre sa-update -D se plaint de ne pas trouver de nameserver, il suffit de remplacer nameserver localhost par nameserver 127.0.0.1 dans votre fichier /etc/resolv.conf

Le fautif: le module Perl Net::DNS

Ca peut toujours servir… ou pas.

tcprules

Comme je n’arrive jamais à retenir cette ligne pourtant fort simple, hop hop je la note dans un coin de mon blog, ca peut toujours (me) servir. Ceux qui en ont besoin sauront à quoi ca sert :)

tcprules tcp.qmail-smtp.cdb tcp.qmail-smtp.tmp < tcp.qmail-smtp

Optimiser un serveur MySQL

Voici quelques informations et scripts bien utiles pour optimiser un serveur MySQL:

- http://rackerhacker.com/mysqltuner/

Ce script produit des recommandations après avoir analysé la configuration du serveur

ovh ~ # ./mysqltuner.pl

>> MySQLTuner 0.9.1 - Major Hayden
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with ‘–help’ for additional options and output filtering
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password:

——– General Statistics ————————————————–
[OK] You have the latest version of MySQLTuner
[OK] Currently running supported MySQL version 5.0.44-log
[OK] Operating on 32-bit architecture with less than 2GB RAM

——– Storage Engine Statistics ——————————————-
[--] Status: -Archive +BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 428K (Tables: 79)
[!!] InnoDB is enabled but isn’t being used
[!!] BDB is enabled but isn’t being used
[!!] Total fragmented tables: 9

——– Performance Metrics ————————————————-
[--] Up for: 5d 20h 44m 17s (282K q [0.557 qps], 67K conn, TX: 102M, RX: 38M)
[--] Reads / Writes: 66% / 34%
[--] Total buffers: 1.6M per thread and 58.0M global
[OK] Maximum possible memory usage: 213.5M (21% of installed RAM)
[OK] Slow queries: 0% (0/282K)
[OK] Highest usage of available connections: 10% (10/100)
[OK] Key buffer size / total MyISAM indexes: 16.0M/315.0K
[OK] Key buffer hit rate: 99.9%
[!!] Query cache is disabled
[OK] Sorts requiring temporary tables: 0%
[OK] Temporary tables created on disk: 4%
[!!] Thread cache is disabled
[!!] Table cache hit rate: 12%
[OK] Open file limit used: 12%
[OK] Table locks acquired immediately: 99%

——– Recommendations —————————————————–
General recommendations:
Add skip-innodb to MySQL configuration to disable InnoDB
Add skip-bdb to MySQL configuration to disable BDB
Run OPTIMIZE TABLE to defragment tables for better performance
Enable the slow query log to troubleshoot bad queries
Set thread_cache_size to 4 as a starting value
Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
query_cache_size (>= 8M)
thread_cache_size (start at 4)
table_cache (> 64)

- http://www.day32.com/MySQL/

Cette page regroupe plusieurs scripts dont certains surveillent une réplication MySQL. Voici un exemple de résultat sur le même serveur que précédemment

– MYSQL PERFORMANCE TUNING PRIMER –
- By: Matthew Montgomery -

MySQL Version 5.0.44-log i686

Uptime = 5 days 20 hrs 49 min 18 sec
Avg. qps = 0
Total Questions = 282259
Threads Connected = 6

Server has been running for over 48hrs.
It should be safe to follow these recommendations

To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL’s Enterprise Monitoring and Advisory Service

SLOW QUERIES
The slow query log is NOT enabled.
Current long_query_time = 10 sec.
You have 0 out of 282280 that take longer than 10 sec. to complete
Your long_query_time may be too high, I typically set this under 5 sec.

BINARY UPDATE LOG
The binary update log is enabled
The expire_logs_days is not set.
The mysqld will retain the entire binary log until RESET MASTER or PURGE MASTER LOGS commands are run manually
Setting expire_logs_days will allow you to remove old binary logs automatically
See http://dev.mysql.com/doc/refman/5.0/en/purge-master-logs.html

WORKER THREADS
Current thread_cache_size = 0
Current threads_cached = 0
Current threads_per_sec = 1
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 100
Current threads_connected = 6
Historic max_used_connections = 10
The number of used connections is 10% of the configured maximum.
You are using less than 10% of your configured max_connections.
Lowering max_connections could help to avoid an over-allocation of memory
See “MEMORY USAGE” section to make sure you are not over-allocating

MEMORY USAGE
Max Memory Ever Allocated : 57 M
Configured Max Per-thread Buffers : 158 M
Configured Max Global Buffers : 42 M
Configured Max Memory Limit : 200 M
Physical Memory : 997.33 M
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 448 K
Current key_buffer_size = 16 M
Key cache miss rate is 1 : 712
Key buffer fill ratio = 1.00 %
Your key_buffer_size seems to be too high.
Perhaps you can use these resources elsewhere

QUERY CACHE
Query cache is supported but not enabled
Perhaps you should set the query_cache_size

SORT OPERATIONS
Current sort_buffer_size = 512 K
Current read_rnd_buffer_size = 508 K
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 132.00 K
You have had 0 queries where a join could not use an index properly
Your joins seem to be using indexes properly

OPEN FILES LIMIT
Current open_files_limit = 1024 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine

TABLE CACHE
Current table_cache value = 64 tables
You have a total of 96 tables
You have 64 open tables.
Current table_cache hit rate is 8%, while 100% of your table cache is in use
You should probably increase your table_cache

TEMP TABLES
Current max_heap_table_size = 16 M
Current tmp_table_size = 32 M
Of 2541 temp tables, 4% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
Created disk tmp tables ratio seems fine

TABLE SCANS
Current read_buffer_size = 252 K
Current table scan ratio = 1 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 5629
Your table locking seems to be fine

- http://hackmysql.com/mysqlreport

Ce script dispose d’un guide comple disponible ici http://hackmysql.com/mysqlreportguide qui permet d’approfondir les résultats obtenus.

MySQL 5.0.44-log uptime 5 20:52:50 Wed Jun 25 14:51:12 2008

__ Key _________________________________________________________________
Buffer used 150.00k of 16.00M %Used: 0.92
Current 1.87M %Usage: 11.67
Write hit 24.14%
Read hit 99.85%

__ Questions ___________________________________________________________
Total 282.76k 0.6/s
Com_ 184.34k 0.4/s %Total: 65.19
DMS 144.44k 0.3/s 51.08
-Unknown 113.28k 0.2/s 40.06
COM_QUIT 67.25k 0.1/s 23.79
Slow 10 s 0 0/s 0.00 %DMS: 0.00 Log: OFF
DMS 144.44k 0.3/s 51.08
SELECT 96.55k 0.2/s 34.14 66.84
REPLACE 40.42k 0.1/s 14.30 27.98
INSERT 6.53k 0.0/s 2.31 4.52
UPDATE 681 0.0/s 0.24 0.47
DELETE 267 0.0/s 0.09 0.18
Com_ 184.34k 0.4/s 65.19
admin_comma 113.73k 0.2/s 40.22
change_db 67.88k 0.1/s 24.00
show_variab 760 0.0/s 0.27

__ SELECT and Sort _____________________________________________________
Scan 6.44k 0.0/s %SELECT: 6.67
Range 0 0/s 0.00
Full join 0 0/s 0.00
Range check 0 0/s 0.00
Full rng join 0 0/s 0.00
Sort scan 1.51k 0.0/s
Sort range 993 0.0/s
Sort mrg pass 0 0/s

__ Table Locks _________________________________________________________
Waited 26 0.0/s %Total: 0.02
Immediate 146.48k 0.3/s

__ Tables ______________________________________________________________
Open 64 of 64 %Cache: 100.00
Opened 860 0.0/s

__ Connections _________________________________________________________
Max used 10 of 100 %Max: 10.00
Total 67.27k 0.1/s

__ Created Temp ________________________________________________________
Disk table 112 0.0/s
Table 2.55k 0.0/s Size: 32.0M
File 5 0.0/s

__ Threads _____________________________________________________________
Running 1 of 6
Cached 0 of 0 %Hit: 0
Created 67.27k 0.1/s
Slow 0 0/s

__ Aborted _____________________________________________________________
Clients 34 0.0/s
Connects 11 0.0/s

__ Bytes _______________________________________________________________
Sent 103.02M 203.1/s
Received 38.68M 76.3/s

__ InnoDB Buffer Pool __________________________________________________
Usage 2.80M of 16.00M %Used: 17.48
Read hit 100.00%
Pages
Free 845 %Total: 82.52
Data 178 17.38 %Drty: 0.00
Misc 1 0.10
Latched 0 0.00
Reads 1.40k 0.0/s
From file 0 0/s 0.00
Ahead Rnd 0 0/s
Ahead Sql 0 0/s
Writes 1.17k 0.0/s
Flushes 189 0.0/s
Wait Free 0 0/s

__ InnoDB Lock _________________________________________________________
Waits 0 0/s
Current 0
Time acquiring
Total 0 ms
Average 0 ms
Max 0 ms

__ InnoDB Data, Pages, Rows ____________________________________________
Data
Reads 0 0/s
Writes 38 0.0/s
fsync 16 0.0/s
Pending
Reads 0
Writes 0
fsync 0

Pages
Created 178 0.0/s
Read 0 0/s
Written 189 0.0/s

Rows
Deleted 0 0/s
Inserted 0 0/s
Read 0 0/s
Updated 0 0/s

« Messages précédents