Outils pour utilisateurs

Outils du site


tech:nouvelle_install_debian_configuration_optimisation

Ceci est une ancienne révision du document !


Nouvelle Install Debian configuration optimisation

Optimisation perf : https://access.redhat.com/documentation/en-US/Red_Hat_Directory_Server/8.2/html/Performance_Tuning_Guide/system-tuning.html

Lors d'une nouvelle install, il faut d'assurer de bien aligner les partions Voir : formater_une_carte_microsd_en_optimisant_les_performances_et_la_duree_de_vie

swap_sur_ramdisk

/etc/apt/apt.conf.d/00InstallRecommends
APT::Install-Recommends "false";
/etc/ssh/sshd_config
PermitRootLogin without-password
mount |grep -v noatime |grep ext4 | grep -v noatime

Voir debian_noatime

SystemD - Désactiver le redémarrage par défaut si ctrl+alt+del

unlink /lib/systemd/system/ctrl-alt-del.target
ln -s /dev/null /lib/systemd/system/ctrl-alt-del.target
systemctl daemon-reload
  1. Si x86 (32 bits)

Dans Debian, la configuration noyau 686 a été remplacée par la configuration 686-pae qui utilise PAE (« Physical Address Extension » − Extension d'adresse physique). Si le serveur utilise la configuration 686 mais n'a pas la PAE, il faut utiliser la configuration 486 à la place. On peut vérifier si le serveur a la PAE en lançant grep -q '^flags.*\bpae\b' /proc/cpuinfo && echo oui || echo non S'il ne l'a pas (c'est-à-dire que la commande précédente renvoie non), il faut installer linux-image-486 puis supprimer linux-image-686 et/ou linux-image-2.6-686 s'ils sont actuellement installés.

  1. Hardening

Table ARP en dur ? notes_arp

/etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
*          soft    nproc     1024
root       soft    nproc     unlimited
www-data   soft    nproc     unlimited

FIXME

apt-get install debian-security-support
check-support-status
service nfs-common stop
service portmap stop
service rpcbind stop
apt-get -y autoremove --purge portmap rpcbind

FIXME umask pam

FIXME https://www.maketecheasier.com/hardening-ubuntu-server/

apt-get install fail2ban rsyslog

pas de connexion avec utilisateur root (sauf par clef)

/etc/issue.net
-----------------------------------------------------------------------------
ATTENTION : Ne vous connectez pas a cette machine sans y etre autorise.
            Toute tentative de piratage sera suivie d'une plainte aupres
            des autorites. Le CERT sera egalement prevenu.

WARNING : Don't try to connect without permission. Every illegal access will
          be referred to the appropriate authorities and the CERT.
-----------------------------------------------------------------------------
/etc/ssh/sshd_config
PasswordAuthentication no
Port <PORT>
AllowUsers <USER>
Banner /etc/issue.net
PermitRootLogin without-password

Ne pas oublier de configurer fail2ban après le changement de port SSH et de redémarrer le service

  1. Crontab que pour root
echo root > /etc/cron.allow

Standart atop munin sysstat

Machine physique lm-sensors smartmontools

amd64-microcode intel-microcode

Microcode Intel Linux Processor Microcode Data File

Config :

/etc/default/smartmontools
start_smartd=yes
service smartmontools restart
sensors-detect --auto

VM

FIXME Redirection de la console

Si plusieurs CPUs

FIXME irqbalance Et numad ?

getconf _NPROCESSORS_ONLN
 
irqbalance

/etc/default/irqbalance

TODO comparer avec

mpstat -P ALL 60

Si Ordinateur de bureau

Pas décidé :

FIXME Activation dépôt multimédia http://www.deb-multimedia.org/

apt-get install libdvdcss2
/etc/default/grub
GRUB_CMDLINE_LINUX="vga=795"

ou vga=788

Puis

Déprécié, utiliser à la place :

gfxpayload=1024x768x16,1024x768
update-grub

Décidé

#apt-get install rtmpdump # Remplacé par curl ?
apt-get install mplayer2 vlc cclive
#update-alternatives --set x-terminal-emulator /usr/bin/lxterminal

Preload va examiner vos habitudes et pré-charger en mémoire les librairies les plus souvent sollicitées.

apt-get install preload

Prelink. Permet de charger en mémoire les bibliothèques partagées

apt-get install prelink
icedove bleachbit 
/etc/inputrc
set bell-style none
apt-get install libnotify-bin
apt-get install numlockx
numlockx on

FIXME a vérif

grep -q numlockx /etc/rc.local ||sed -i -e 's/^exit 0/numlockx on\n&/' /etc/rc.local

Conky FIXME voir ~/.conkyrc

/home/jibe/.config/autostart/conky.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=conky
Name=Conky

Faire le ménage dans /etc/xdg/autostart/*.desktop

Exemple

rm /etc/xdg/autostart/caribou-autostart.desktop 
rm /etc/xdg/autostart/evolution-alarm-notify.desktop 
rm /home/jibe/.config/autostart/vino-server.desktop 
rm /home/jibe/.config/autostart/gnome-user-share.desktop 
  1. Aleger

Accélérer Xfce4. Ne pas afficher les images dans les menus, texte seul. Cacher le contenu des fenêtres lors des déplacements, redimensionnements.

Remplacement de bash par dash dpkg-reconfigure dash

Installer slim comme gestionnaire de session graphique.

apt-get install slim
/etc/sysctl.d/swappiness.conf
vm.swappiness=10
vm.vfs_cache_pressure=50
/etc/fstab
tmpfs /media/virtuelram tmpfs defaults,noatime,nodiratime,size=2500M 0 0

Voir /etc/default/tmpfs

Nettoyer /tmp

/lib/systemd/system/systemd-tmpfiles-clean.timer
[Unit]
Description=Daily Cleanup of Temporary Directories
Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
 
[Timer]
OnBootSec=15min
OnUnitActiveSec=1d
/lib/systemd/system/systemd-tmpfiles-clean.service
[Unit]
Description=Cleanup of Temporary Directories
Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-readahead-collect.service
systemd-readahead-replay.service local-fs.target time-sync.target
Before=shutdown.target
 
[Service]
Type=oneshot
ExecStart=/usr/bin/systemd-tmpfiles --clean
IOSchedulingClass=idle
/etc/tmpfiles.d/tmp.conf
# Clear tmp directories separately, to make them easier to override
d /tmp 1777 root root 10d
d /var/tmp 1777 root root 30d

# Exclude namespace mountpoints created with PrivateTmp=yes
x /tmp/systemd-private-%b-*
X /tmp/systemd-private-%b-*/tmp
x /var/tmp/systemd-private-%b-*
X /var/tmp/systemd-private-%b-*/tmp

Diminuez le nombre de bureaux virtuels

Un “MTA” (Mail Transfert Agent) est installé par défaut et lancé au démarrage, exim est utile comme serveur de courriels, mais également pour recevoir les courriels du système. Si vous voulez simplement recevoir les courriels systèmes, mais sans avoir le démon exim lancé en permanence, changez l'option de configuration “QUEUERUNNER=” dans /etc/default/exim4 de la manière suivante :

/etc/default/exim4
QUEUERUNNER='nodaemon'
  1. Tous

Commande checkrestart (pour savoir les services / processus à redémarrer après mise à jour)

apt-get install debian-goodies

FIXME Tous !?

#echo "*.*    /dev/tty12" >> /etc/rsyslog.conf
echo "*.*     -/dev/tty12" >/etc/rsyslog.d/tty12.conf

Tous !?

/etc/default/grub
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
update-grub

apt-get install sed vim build-essential python-minimal # Pour Ansible

/etc/sysctl.d/swappiness.conf
vm.swappiness=5
sysctl -p /etc/sysctl.d/swappiness.conf
~/.bashrc
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
 
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
  1. # Juste après install
sed -i -e 's/^deb cdrom/#deb cdrom/' /etc/apt/sources.list
 
update-alternatives --set editor /usr/bin/vim.basic 
  1. Par encore décidé
/etc/default/exim4
#QUEUERUNNER='combined'
QUEUERUNNER='nodaemon'
/etc/vim/vimrc.local
syntax on

" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
if has("autocmd")
  filetype plugin indent on
endif

set showcmd            " Show (partial) command in status line.
set showmatch          " Show matching brackets.
set smartcase          " Do smart case matching
set incsearch          " Incremental search
set hidden             " Hide buffers when they are abandoned

Autre

FIXME Activer le cache disque avec gnome-disk-utility ou hdparm !?

Pas de login si /home/$USER absent

Cloud AWS

Source : https://wiki.debian.org/Cloud/SystemsComparison

vm.swappiness = 0
vm.dirty_ratio = 80
vm.dirty_background_ratio = 5
vm.dirty_expire_centisecs = 12000
net.core.somaxconn = 1000
net.core.netdev_max_backlog = 5000
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_wmem = 4096 12582912 16777216
net.ipv4.tcp_rmem = 4096 12582912 16777216
net.ipv4.tcp_max_syn_backlog = 8096
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 10240 65535
kernel.sysrq = 0 

net.core.somaxconn

net.core.somaxconn = 2000

Conf nginx backlog

server {
  listen 80 backlog=2000 reuseport;
  server_name example.com;
  root /var/www/example.com;
  index index.html;
}
tech/nouvelle_install_debian_configuration_optimisation.1742825205.txt.gz · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki