Projet

Général

Profil

SrvSTG » Historique » Version 6

Ludovic Pouzenc, 07/12/2014 14:29

1 1 Ludovic Pouzenc
h1. Serveur stg.tetaneutral.net
2 1 Ludovic Pouzenc
3 1 Ludovic Pouzenc
h2. Caractéristiques
4 1 Ludovic Pouzenc
5 2 Ludovic Pouzenc
* Gigabyte Brix (CPU Celeron)
6 2 Ludovic Pouzenc
* Samsung SSD 840 EVO 120GB
7 1 Ludovic Pouzenc
* Debian 7 amd64
8 1 Ludovic Pouzenc
9 1 Ludovic Pouzenc
h2. Traces Install
10 1 Ludovic Pouzenc
11 1 Ludovic Pouzenc
A partir d'une clé USB bootable Debian 7 amd64
12 1 Ludovic Pouzenc
13 2 Ludovic Pouzenc
h3. Options d'installation
14 1 Ludovic Pouzenc
15 2 Ludovic Pouzenc
* hostname initial : stg2 (changé en stg par la suite)
16 1 Ludovic Pouzenc
* partman : partition par defaut sur tout le disque sda
17 1 Ludovic Pouzenc
* grub : par défaut, sur sda
18 1 Ludovic Pouzenc
* tasksel : decocher interface graphique et cocher serveur ssh
19 1 Ludovic Pouzenc
* popcon : non
20 1 Ludovic Pouzenc
21 1 Ludovic Pouzenc
h3. Premières configs
22 2 Ludovic Pouzenc
23 1 Ludovic Pouzenc
<pre>
24 2 Ludovic Pouzenc
# Dépendances requises
25 2 Ludovic Pouzenc
apt-get install sudo vlan conntrack ntp fail2ban
26 2 Ludovic Pouzenc
# Utilitaires
27 2 Ludovic Pouzenc
apt-get install rsync vim emacs23-nox iftop htop screen ntpdate powertop molly-guard sysstat strace tcpdump
28 2 Ludovic Pouzenc
29 2 Ludovic Pouzenc
update-alternatives --config editor
30 2 Ludovic Pouzenc
#-> choisir vim.basic
31 2 Ludovic Pouzenc
32 2 Ludovic Pouzenc
# Création de tous les users
33 2 Ludovic Pouzenc
adduser nicolas sudo
34 2 Ludovic Pouzenc
adduser ludovic
35 2 Ludovic Pouzenc
adduser ludovic sudo
36 2 Ludovic Pouzenc
# [...]
37 2 Ludovic Pouzenc
</pre>
38 2 Ludovic Pouzenc
39 2 Ludovic Pouzenc
* Modification du /root/.bashrc pour dé-commenter les alias et les couleurs
40 2 Ludovic Pouzenc
41 2 Ludovic Pouzenc
h3. Modification du partitionnement
42 2 Ludovic Pouzenc
43 2 Ludovic Pouzenc
* Une meilleure option était de faire directement le bon paramétrage avec l'assistant partman de l'installeur Debian
44 4 Ludovic Pouzenc
45 2 Ludovic Pouzenc
<pre>
46 2 Ludovic Pouzenc
root@stg2:~# smartctl -a /dev/sda
47 2 Ludovic Pouzenc
Device Model:     Samsung SSD 840 EVO 120GB
48 2 Ludovic Pouzenc
[...]
49 2 Ludovic Pouzenc
50 2 Ludovic Pouzenc
root@stg2:~# fdisk -l /dev/sda
51 2 Ludovic Pouzenc
52 2 Ludovic Pouzenc
Disque /dev/sda : 120.0 Go, 120034123776 octets
53 2 Ludovic Pouzenc
255 têtes, 63 secteurs/piste, 14593 cylindres, total 234441648 secteurs
54 2 Ludovic Pouzenc
Unités = secteurs de 1 * 512 = 512 octets
55 2 Ludovic Pouzenc
Taille de secteur (logique / physique) : 512 octets / 512 octets
56 2 Ludovic Pouzenc
taille d'E/S (minimale / optimale) : 512 octets / 512 octets
57 2 Ludovic Pouzenc
Identifiant de disque : 0x000b8647
58 2 Ludovic Pouzenc
59 2 Ludovic Pouzenc
Périphérique Amorce  Début        Fin      Blocs     Id  Système
60 2 Ludovic Pouzenc
/dev/sda1   *        2048    19531775     9764864   83  Linux
61 2 Ludovic Pouzenc
/dev/sda2        19533822   234440703   107453441    5  Étendue
62 2 Ludovic Pouzenc
/dev/sda5        19533824    28186623     4326400   82  partition d'échange Linux / Solaris
63 2 Ludovic Pouzenc
/dev/sda6        28188672   234440703   103126016   83  Linux
64 2 Ludovic Pouzenc
</pre>
65 2 Ludovic Pouzenc
66 2 Ludovic Pouzenc
* Sauver le contenu de /home
67 2 Ludovic Pouzenc
* Démonter /home (ne pas avoir son shell dedans...)
68 5 Ludovic Pouzenc
* Restaurer le contenu de la sauvegarde dans /home (donc dans la partition racine)
69 2 Ludovic Pouzenc
* Détruire la partition correspondante. Idem pour le swap.
70 2 Ludovic Pouzenc
* Créer une partition primaire de la taille de l'espace restant pour /var
71 4 Ludovic Pouzenc
72 2 Ludovic Pouzenc
<pre>
73 2 Ludovic Pouzenc
root@stg2:~# fdisk -l /dev/sda
74 2 Ludovic Pouzenc
75 2 Ludovic Pouzenc
Disque /dev/sda : 120.0 Go, 120034123776 octets
76 2 Ludovic Pouzenc
255 têtes, 63 secteurs/piste, 14593 cylindres, total 234441648 secteurs
77 2 Ludovic Pouzenc
Unités = secteurs de 1 * 512 = 512 octets
78 2 Ludovic Pouzenc
Taille de secteur (logique / physique) : 512 octets / 512 octets
79 2 Ludovic Pouzenc
taille d'E/S (minimale / optimale) : 512 octets / 512 octets
80 2 Ludovic Pouzenc
Identifiant de disque : 0x000b8647
81 2 Ludovic Pouzenc
82 2 Ludovic Pouzenc
Périphérique Amorce  Début        Fin      Blocs     Id  Système
83 2 Ludovic Pouzenc
/dev/sda1   *        2048    19531775     9764864   83  Linux
84 2 Ludovic Pouzenc
/dev/sda2        19531776   234441647   107454936   83  Linux
85 2 Ludovic Pouzenc
</pre>
86 2 Ludovic Pouzenc
87 2 Ludovic Pouzenc
* Virer /home et swap dans le fstab
88 2 Ludovic Pouzenc
* Rebooter (pour prise en compte des partitions)
89 2 Ludovic Pouzenc
* Formatter /dev/sda2 en ext4
90 2 Ludovic Pouzenc
* Copier /var dedans
91 2 Ludovic Pouzenc
* Mettre à jour le fstab (sda2 -> var)
92 2 Ludovic Pouzenc
* Reboot
93 2 Ludovic Pouzenc
94 2 Ludovic Pouzenc
h3. Tuning SSD
95 2 Ludovic Pouzenc
96 2 Ludovic Pouzenc
* Options de montage ext4 dans fstab : errors=remount-ro,noatime,discard,commit=300
97 2 Ludovic Pouzenc
* Scheduler deadline de manière persistante
98 2 Ludovic Pouzenc
(confère le fichier /etc/udev/rules.d/60-ssd-scheduler.rules)
99 2 Ludovic Pouzenc
* Swapiness minimal (le OOM killer sera + sensible mais pas d'IO dans tous les sens)
100 2 Ludovic Pouzenc
(confère le fichier /etc/sysctl.d/ssd.conf)
101 2 Ludovic Pouzenc
102 2 Ludovic Pouzenc
h3. Autres paramètres kernel
103 2 Ludovic Pouzenc
104 2 Ludovic Pouzenc
* Éviter de logguer les messages "UDP bad checksum..." pendant les flood UDP
105 2 Ludovic Pouzenc
* Désactiver les ICMP source route
106 2 Ludovic Pouzenc
* Activer l'IP forward au boot (si des choses partent en vrac après le démarrage... on a au moins déjà ça d'actif)
107 2 Ludovic Pouzenc
(confère le fichier /etc/sysctl.d/router.conf)
108 2 Ludovic Pouzenc
(Laurent Guerby recommande plutôt de rassembler tout ce qui est réseau dans /root/tetaneutral.sh)
109 2 Ludovic Pouzenc
110 2 Ludovic Pouzenc
h3. Config réseau
111 2 Ludovic Pouzenc
112 2 Ludovic Pouzenc
* Le NUC n'a qu'une interface réseau, donc tout part sur la base de VLANs
113 2 Ludovic Pouzenc
(confère /etc/network/interfaces)
114 2 Ludovic Pouzenc
* Changer le /etc/hostname : stg
115 2 Ludovic Pouzenc
* Utiliser /etc/debian_chroot pour éviter les confusions des machines
116 3 Ludovic Pouzenc
117 3 Ludovic Pouzenc
<pre>
118 3 Ludovic Pouzenc
echo NUC > /etc/debian_chroot
119 3 Ludovic Pouzenc
source ~/.bashrc
120 3 Ludovic Pouzenc
</pre>
121 3 Ludovic Pouzenc
122 2 Ludovic Pouzenc
* Mettre l'IP publique dans /etc/hosts (car sinon résolution de stg pourrie chez les adhérents)
123 3 Ludovic Pouzenc
124 2 Ludovic Pouzenc
<pre>
125 2 Ludovic Pouzenc
91.224.148.7    stg.tetaneutral.net     stg
126 2 Ludovic Pouzenc
</pre>
127 3 Ludovic Pouzenc
128 3 Ludovic Pouzenc
* Le fichier /etc/hosts est généré par /root/tetneutral.sh, conserver les entrées système dans une copie
129 3 Ludovic Pouzenc
130 2 Ludovic Pouzenc
<pre>
131 2 Ludovic Pouzenc
(NUC)root@stg2:~# cp /etc/hosts /etc/hosts_system
132 3 Ludovic Pouzenc
</pre>
133 3 Ludovic Pouzenc
134 2 Ludovic Pouzenc
* Vérifier que le FQDN fonctionne
135 3 Ludovic Pouzenc
136 3 Ludovic Pouzenc
<pre>
137 2 Ludovic Pouzenc
(NUC)root@stg2:~# hostname
138 2 Ludovic Pouzenc
stg
139 2 Ludovic Pouzenc
(NUC)root@stg:~# hostname --fqdn
140 2 Ludovic Pouzenc
stg.tetaneutral.net
141 3 Ludovic Pouzenc
</pre>
142 3 Ludovic Pouzenc
143 3 Ludovic Pouzenc
h3. Service DHCP
144 3 Ludovic Pouzenc
145 3 Ludovic Pouzenc
<pre>
146 3 Ludovic Pouzenc
apt-get install isc-dhcp-server  
147 3 Ludovic Pouzenc
</pre>
148 3 Ludovic Pouzenc
149 3 Ludovic Pouzenc
* Génération d'un fichier de conf DHCP dhcp-list.conf via /root/tetaneutral.sh
150 3 Ludovic Pouzenc
* Ajout dans /etc/dhcp/dhcpd.conf de
151 3 Ludovic Pouzenc
152 3 Ludovic Pouzenc
<pre>
153 3 Ludovic Pouzenc
include "/etc/dhcp/dhcp-list.conf";
154 3 Ludovic Pouzenc
</pre> 
155 3 Ludovic Pouzenc
156 3 Ludovic Pouzenc
157 3 Ludovic Pouzenc
h3. DNS
158 3 Ludovic Pouzenc
159 3 Ludovic Pouzenc
<pre>
160 3 Ludovic Pouzenc
apt-get install pdns-recursor
161 3 Ludovic Pouzenc
</pre>
162 3 Ludovic Pouzenc
163 3 Ludovic Pouzenc
* Toute la config est dans /etc/powerdns/recursor.conf
164 3 Ludovic Pouzenc
165 3 Ludovic Pouzenc
h3. Munin-node
166 3 Ludovic Pouzenc
167 3 Ludovic Pouzenc
<pre>
168 3 Ludovic Pouzenc
apt-get install munin-node
169 3 Ludovic Pouzenc
</pre>
170 3 Ludovic Pouzenc
171 3 Ludovic Pouzenc
* Fichiers de configs dans /etc/munin/ : munin-node.conf, plugin-conf.d/custom, plugins_custom/traffic_all
172 3 Ludovic Pouzenc
* Liste des plugins activés : cpu, diskstats, entropy, fail2ban, forks, fw_conntrack, fw_forwarded_local, fw_packets, if_err_eth0, interrupts, irqstats, load, memory, open_files, open_inodes, processes, proc_pri, swap, threads, traffic_all, uptime, users, vmstat
173 3 Ludovic Pouzenc
* Test de l'ensemble des plug-ins :
174 3 Ludovic Pouzenc
175 3 Ludovic Pouzenc
<pre>
176 3 Ludovic Pouzenc
(NUC)root@stg:~# cd /etc/munin/plugins
177 3 Ludovic Pouzenc
(NUC)root@stg:/etc/munin/plugins# for p in $(ls); do munin-run $p; done
178 1 Ludovic Pouzenc
</pre>
179 6 Ludovic Pouzenc
180 6 Ludovic Pouzenc
h3. Backup
181 6 Ludovic Pouzenc
182 6 Ludovic Pouzenc
<pre>
183 6 Ludovic Pouzenc
apt-get install rdiff-backup
184 6 Ludovic Pouzenc
visudo
185 6 Ludovic Pouzenc
</pre>
186 6 Ludovic Pouzenc
187 6 Ludovic Pouzenc
<pre>
188 6 Ludovic Pouzenc
# Cmnd alias specification
189 6 Ludovic Pouzenc
Cmnd_Alias      BACKUP = /usr/bin/rdiff-backup
190 6 Ludovic Pouzenc
# User privilege specification
191 6 Ludovic Pouzenc
backup  ALL = (root) NOPASSWD:BACKUP
192 6 Ludovic Pouzenc
</pre>
193 6 Ludovic Pouzenc
194 6 Ludovic Pouzenc
* Ajouter clé SSH autorisée (.ssh/authorized_keys) + script pour limiter les commandes (.ssh/check) dans /var/backup/
195 6 Ludovic Pouzenc
196 6 Ludovic Pouzenc
h3. Tuning
197 6 Ludovic Pouzenc
* Utiliser 'powertop' pour voir ce qui interrompt le processeur fréquemment
198 6 Ludovic Pouzenc
* Checker avec pstree ce qui tourne...
199 6 Ludovic Pouzenc
* Appliquer quelques modifs
200 6 Ludovic Pouzenc
201 6 Ludovic Pouzenc
<pre>
202 6 Ludovic Pouzenc
dpkg-reconfigure exim4-config
203 6 Ludovic Pouzenc
# -> mettre du format mbox, vérifier /etc/aliases
204 6 Ludovic Pouzenc
205 6 Ludovic Pouzenc
apt-get remove --purge nfs-common rpcbind
206 6 Ludovic Pouzenc
apt-get autoremove --purge 
207 6 Ludovic Pouzenc
208 6 Ludovic Pouzenc
for mod in btusb bluetooth rfkill snd_hwdep snd_hda_codec snd_hda_intel nfs nfs_acl nfsd sunrpc
209 6 Ludovic Pouzenc
do
210 6 Ludovic Pouzenc
	echo "blacklist $mod" >> /etc/modprobe.d/$mod.conf
211 6 Ludovic Pouzenc
done
212 6 Ludovic Pouzenc
</pre>
213 6 Ludovic Pouzenc
214 6 Ludovic Pouzenc
* Restauration de /root/.iftoprc
215 6 Ludovic Pouzenc
* Restauration de /root/tetaneutral.sh et /root/config.sh
216 6 Ludovic Pouzenc
* Vérification de l'heure
217 6 Ludovic Pouzenc
218 6 Ludovic Pouzenc
<pre>
219 6 Ludovic Pouzenc
date
220 6 Ludovic Pouzenc
ntpdate pool.ntp.org
221 6 Ludovic Pouzenc
date
222 6 Ludovic Pouzenc
service ntp status
223 6 Ludovic Pouzenc
</pre>