Archives pour la catégorie ‘Système’

Amazon EC2 : scripts de gestion des disques éphémères

Voici les scripts et unités systemd que j’utilise pour gérer les disques éphémères de mes instances Amazon EC2.

Docker : activer les restrictions RAM & swap

# vim /etc/default/grub 
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
# update-grub
# vim /etc/default/docker
DOCKER_OPTS="--exec-opt native.cgroupdriver=cgroupfs"
# shutdown -r now

Debian : fix startup Docker 1.7 & kernel 4.1

sept. 20 19:34:19 muse systemd[1]: Started Docker Application Container Engine.
sept. 20 19:34:19 muse docker[18643]: time="2015-09-20T19:34:19.773439875+02:00" level=error msg="[graphdriver] prior storage driver \"aufs\" failed: driver not supported"
sept. 20 19:34:19 muse docker[18643]: time="2015-09-20T19:34:19.773487551+02:00" level=fatal msg="Error starting daemon: error initializing graphdriver: driver not supported"
# rm -rf /var/lib/docker/aufs
# systemctl start docker

Debian : fix crash Netbeans 8

# vim /etc/java-8-openjdk/accessibility.properties
#assistive_technologies=org.GNOME.Accessibility.AtkWrapper

Linux : afficher la consommation swap par processus

# for file in /proc/*/status ; do awk '/^(VmSwap|Pid|Name)/{printf $2 " " $3}END{ print ""}' $file; done | sort

Linux : tester les performances I/O

# hdparm -t -T /dev/sda
# dd bs=1M count=512 if=/dev/zero of=test conv=fdatasync
# bonnie++ -d /mnt -r 8000 -u toto

Debian : migrer son système sous systemd

# apt-get update
# apt-get install systemd systemd-sysv
# reboot
# ls -al /sbin/init 
lrwxrwxrwx 1 root root 20 Apr 23 01:46 /sbin/init -> /lib/systemd/systemd
# apt-get --purge remove sysvinit

Pour activer les logs persistants de journald :

# mkdir /var/log/journal
# chgrp systemd-journal /var/log/journal
# chmod g+rwx /var/log/journal

Fleet : déploiement d’un service global avec une template

# vim zabbix@.service
[Unit]
Description=zabbix %i
Requires=docker.service
After=docker.service

[Service]
ExecStartPre=-/usr/bin/docker kill zabbix%i
ExecStartPre=-/usr/bin/docker rm zabbix%i
ExecStartPre=/usr/bin/docker pull bhuisgen/docker-zabbix-coreos
ExecStart=/usr/bin/docker run --name zabbix%i -p 1050%i:10050 -v /var/run/docker.sock:/coreos/var/run/docker.sock -v /proc:/coreos/proc:ro -v /sys:/coreos/sys:ro -v /dev:/coreos/dev:ro -v /dev/log:/dev/log --restart=always bhuisgen/docker-zabbix-coreos zabbix%i.my.domain 80.81.82.83
ExecStop=/usr/bin/docker stop zabbix%i
TimeoutStartSec=900

[X-Fleet]
Global=true
# export FLEETCTL_TUNNEL="cluster.my.domain"
# fleetctl submit zabbix@.service
# fleetctl load zabbix@.service
# fleetctl start zabbix@{0..4}

Unbound : mise en place d’un fake DNS

La mise en place d’une cache DNS peut être nécessaire pour bypasser le résultat de requêtes DNS.

# apt-get install unbound
# vim /etc/resolv.conf
# cat /etc/unbound/unbound.conf
 
server:
    local-zone: "my.domain." static
    local-data: "fake.my.domain. IN A 10.20.2.22"
    local-data-ptr: "10.20.2.22 fake.my.domain"

X.org : configuration multi-écrans avec le driver nouveau

# lspci -nn|grep VGA
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation G86 [Quadro NVS 290] [10de:042f] (rev a1)
02:00.0 VGA compatible controller [0300]: NVIDIA Corporation G86 [Quadro NVS 290] [10de:042f] (rev a1)
# ls -l /sys/class/drm/
total 0
lrwxrwxrwx 1 root root    0 Mar 11 09:57 card0 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0
lrwxrwxrwx 1 root root    0 Mar 11 09:57 card0-DVI-I-1 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0/card0-DVI-I-1
lrwxrwxrwx 1 root root    0 Mar 11 09:57 card0-DVI-I-2 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0/card0-DVI-I-2
lrwxrwxrwx 1 root root    0 Mar 11 09:57 card1 -> ../../devices/pci0000:00/0000:00:1c.0/0000:02:00.0/drm/card1
lrwxrwxrwx 1 root root    0 Mar 11 09:57 card1-DVI-I-3 -> ../../devices/pci0000:00/0000:00:1c.0/0000:02:00.0/drm/card1/card1-DVI-I-3
lrwxrwxrwx 1 root root    0 Mar 11 09:57 card1-DVI-I-4 -> ../../devices/pci0000:00/0000:00:1c.0/0000:02:00.0/drm/card1/card1-DVI-I-4
lrwxrwxrwx 1 root root    0 Mar 11 09:57 controlD64 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/controlD64
lrwxrwxrwx 1 root root    0 Mar 11 09:57 controlD65 -> ../../devices/pci0000:00/0000:00:1c.0/0000:02:00.0/drm/controlD65
lrwxrwxrwx 1 root root    0 Mar 11 09:57 ttm -> ../../devices/virtual/drm/ttm
-r--r--r-- 1 root root 4096 Mar 11 09:57 version
# vim /etc/X11/xorg.conf
Section "ServerLayout"
    Identifier  "Layout0"
    Option      "Xinerama" "on"
    Option      "Clone" "off"
    Screen   0  "Screen0"
    Screen   1  "Screen1" RightOf "Screen0"
    Screen   2  "Screen2" Below "Screen0"
    Screen   3  "Screen3" RightOf "Screen2"
EndSection

Section "Device"
    Identifier  "Device0"
    Driver      "nouveau"
    BusID       "PCI:1:0:0"
    Option      "ZaphodHeads" "DVI-I-1"
    Screen      0
EndSection

Section "Device"
    Identifier  "Device1"
    Driver      "nouveau"
    BusID       "PCI:1:0:0"
    Option      "ZaphodHeads" "DVI-I-2"
    Screen      1
EndSection

Section "Device"
    Identifier  "Device2"
    Driver      "nouveau"
    BusID       "PCI:2:0:0"
    Option      "ZaphodHeads" "DVI-I-3"
    Screen      0 
EndSection

Section "Device"
    Identifier  "Device3"
    Driver      "nouveau"
    BusID       "PCI:2:0:0"
    Option      "ZaphodHeads" "DVI-I-4"
    Screen      1
EndSection

Section "Screen"
    Identifier  "Screen0"
    Device      "Device0"
EndSection

Section "Screen"
    Identifier  "Screen1"
    Device      "Device1"
EndSection

Section "Screen"
    Identifier  "Screen2"
    Device      "Device2"
EndSection

Section "Screen"
    Identifier  "Screen3"
    Device      "Device3"
EndSection
Haut de page