User Tools

Site Tools


new_server_version

= Server installatie = (zie ook IPMI info) Booten met een sysrescue cd * execute een shell en dan de raid afbreken:

mdadm --manage /dev/md''RAIDNUMMER'' --stop

* de partitietabellen wissen:

for a in a b c d ... ; do dd if=/dev/zero of=/dev/sd$a count=5000 ; done

* dev updaten :

partprobe

*

fdisk

, nieuwe dos 'GEEN' GPT partitietabel maken met een primaire partitie van type 83 (linux) vanaf sector 2048 tot het einde, bootable maken (a) * dev opnieuw updaten:

partprobe

* Check namen en mac netwerkkaarten, hoogste mac is waarschijnlijk op internet aangesloten

Rebooten met ubuntu 18.04 server ('GEEN' 18.04.x) en uefi gebruiken (moet in de sommige gevallen nog gezet worden in de bios) * Install Ubuntu Server (gaat vrij lang wachten worden) * English → other → Europe → Belgium * en_US.UTF-8 * geen autodetectie keyboard, English (US) → English (US) — Vanuit IPMI blijft alles eigen layout * externe netkaart als primaire. Een link gaat gevonden worden maar autoconfig gaat falen. Manueel doen: * 143.169.247.X/24 (X is laatste nummer echt adres volgens een dig van astra-tesla-ATNUMMER , 'NIET HETGENE VAN IPMI' ! ) * 143.169.247.254 als gateway * 143.169.252.201 143.169.252.202 (spaties er tussen)als dns * astra-tesla-NUMMER * uantwerpen.be * Nikolas Garofil * garo * 2x wachtwoord * Europe/Brussels * Manual De gemaakte partite btrfs maken met label ROOTFS, bootable (als dit niet gaat zitten we nog met gpt en is fdisk in het begin niet gegaan), default opties (tenzij het een ssd is) en gemount op “/” Andere schijven momenteel leeg laten * geen proxy * Install security updates automatically * Enkel OpenSSH server * grub op mbr van de schijf waar alles op is geinstalleerd <!–ander netwerk wordt 10.0.0.0/8, 10.0.0.X (X is laatste nummer echt adres volgens een dig van astra-tesla-NUMMER) maar dit doen we nog niet–> * Image verwijderen, rebooten

Na basis installatie

Inloggen via ssh en: * zo snel mogelijk zsh om zo snel mogelijk de zsh history i.p.v. de bash history te krijgen, 4x exit zodat ik opnieuw moet inloggen en direct zsh heb sudo apt install zsh wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh REPO=ngaro/oh-my-zsh BRANCH=myversion sh install.sh sudo -i REPO=ngaro/oh-my-zsh BRANCH=myversion sh ~garo/install.sh exit exit rm install.sh exit exit * Zo snel mogelijk een snapshot nemen van de meest basis installatie. (Doe dit meerdere keren bij de verschillende dingen die we doen tijdens de installatie) sudo -i apt update && apt install btrbk && mkdir -p /mnt/rootfs/snapshots && cat > /etc/btrbk/btrbk.conf Hierin dit zetten: transaction_log /var/log/btrbk.log lockfile /var/lock/btrbk.lock timestamp_format long snapshot_create always snapshot_dir snapshots snapshot_preserve_min 2d snapshot_preserve 20d volume /mnt/rootfs subvolume @ subvolume @home En dan:

echo "LABEL=ROOTFS /mnt/rootfs btrfs noauto 0 2" >> /etc/fstab && mount /mnt/rootfs && btrbk -v run

* Snapshots elk uur doen:

cat > /etc/cron.hourly/btrbksnapshots

#!/bin/bash if mount | grep rootfs | grep subvol=\/ > /dev/null ; then

 btrbk -q run

else

 mount /mnt/rootfs && btrbk -q run && umount /mnt/rootfs

fi

chmod +x /etc/cron.hourly/btrbksnapshots

* package upgrades:

apt full-upgrade && apt autoclean

(update is bij btrbk al gebeurd) behoud keyboard layout wanneer het gevraagd wordt Restart services during package upgrades without asking? - Yes * Vlaams (

nl_BE.UTF-8

) als extra maar 'niet' als default locale zetten

dpkg-reconfigure locales

* Zorgen dat we aan het heel btrfs systeem kunnen indien nodig en gebruik labels:

mkdir /mnt/rootfs && echo "LABEL=ROOTFS /mnt/rootfs btrfs noauto 0 2" >> /etc/fstab && perl -i -pe 's/^UUID\S+/LABEL=ROOTFS/' /etc/fstab

* Al de rest in een byobu op screen doen:

perl -i -pe 's/="tmux"/="screen"/' /etc/byobu/backend && echo "bind r screen -t 'root' sudo -i" >> /usr/share/byobu/keybindings/common && byobu

* Een software raid bouwen van de overige schijven: astra-tesla-6 : <code>mdadm –create –verbose /dev/md/raid5_3x1TB –level=5 –raid-devices=3 /dev/sdb /dev/sdc /dev/sdd</code> Voor andere AT's nog checken wat de ideale setup is * Versioncontrol voor configuratiefiles:

apt install etckeeper && cd /etc && git config --global user.email "nikolas.garofil@uantwerpen.be" && git config --global user.name "Nikolas Garofil" && etckeeper init

* Keylogin vanuit mijn desktop:

ssh-copy-id -i astra-tesla-NUMMER

* Vim naar mijn goesting zetten:

perl -i -pe 's/"set background/set background/' /etc/vim/vimrc && echo "set number relativenumber" >> /etc/vim/vimrc

* Direct netwerk regelen door in

/etc/netplan/01-netcfg.yaml

(met de juiste spaties) dit te zetten: enp1s0f0:

 addresses: [ 10.0.0.''X''/8 ]

X is hier hetzelfde als bij het extern adres

Extra's

* Simpele packages:

apt install iotop

* Docker:

apt install apt-transport-https && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && apt-key fingerprint 0EBFCD88 && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" && apt update && apt install docker-ce && usermod -G docker -a garo && systemctl stop docker && cat >> /etc/docker/daemon.json

{

"storage-driver": "overlay2"

}

systemctl start docker

* historytijd installeren in uitvoerbare

/usr/local/bin/historytijd

: #!/usr/bin/perl use strict; use warnings; use Term::ANSIColor; use v5.26;

sub iedereenhistory {

       my $history;
       open(my $fh, "/etc/passwd") or die "kan /etc/passwd niet openen";
       while(<$fh>) {
               $history->{$1}="$2/.zsh_history" if(/^(.*?):.*?:\d+:\d+:.*?:(.*?):.*\/zsh$/);
       }
       close $fh;
       return $history;

}

unless($< eq 0) { system “sudo $0”; exit;}

my @maandnamen = qw(Jan Feb Maa Apr Mei Jun Jul Aug Sep Okt Nov Dec); my @dagnamen = qw(Zo Ma Di Wo Do Vr Za); my $kleur = {'root'⇒color('bold red'), 'andereuser'⇒ color('bold green')}; #my $history = { $ENV{USER} ⇒ “$ENV{HOME}/.zsh_history” }; my $history = iedereenhistory;

my $lijnen={}; foreach my $user (keys %$history) {

       my $histfile = $history->{$user};
       open(my $fh, $histfile) or die "kan '$histfile' niet openen";
       my $huidigelijn={};
       my $pijltje = color('bold cyan')." → ";
       while(<$fh>) {
               if(/^: (\d+):0;(.*?)\n$/) {
                       $huidigelijn->{tijd}=$1; $huidigelijn->{commando}=$2;
                       $huidigelijn->{commando}=~s/\s*\\*\s*$//;
                       my ($sec,$min,$uur,$mdag,$maand,$jaar,$wdag) = localtime $huidigelijn->{tijd}; $jaar+=1900;
                       $sec="0$sec" if $sec<10;
                       $min="0$min" if $min<10;
                       $uur="0$uur" if $uur<10;
                       $mdag="0$mdag" if $mdag<10;
                       if($user eq 'root' ) { $lijnen->{$huidigelijn->{tijd}} .= $kleur->{root} . $user; } else { $lijnen->{$huidigelijn->{tijd}} .= $kleur->{andereuser} . $user; }
                       $lijnen->{$huidigelijn->{tijd}} .= $pijltje;
                       $lijnen->{$huidigelijn->{tijd}} .= color("bold black") . "$dagnamen[$wdag] $mdag $maandnamen[$maand] $jaar $uur:$min:$sec";
                       $lijnen->{$huidigelijn->{tijd}} .= $pijltje;
                       if($user eq 'root' ) { $lijnen->{$huidigelijn->{tijd}} .= $kleur->{root} . $huidigelijn->{commando}; } else { $lijnen->{$huidigelijn->{tijd}} .= color('reset') . $huidigelijn->{commando}; }
                       $lijnen->{$huidigelijn->{tijd}} .= "\n";
               } else {
                       chomp $lijnen->{$huidigelijn->{tijd}};
                       s/^\s*\\*\s*//; s/^(.*?)\s*\\*\s*\n$/$1/;
                       $lijnen->{$huidigelijn->{tijd}} .= " $_\n";
               }
       }
       close $fh;

} foreach my $lijn (sort keys %$lijnen) {

       print $lijnen->{$lijn};

} print color('reset'); </code> TODO: later nog wat andere handige scriptjes er bij gooien, zeker een BU-script maar hiervoor eerst info in winnen over huidige manier van backups

Zowat klaar

* Vanaf

/proc/mdstat

zegt dat de raid klaar is de configuratie updaten:

mdadm --detail --scan >> /etc/mdadm/mdadm.conf && update-initramfs -u

* Als eerste partitie een kleine 100MB ext4 voor backup van configfiles systeem (met fdisk vanaf 2048 tot 200703, type 83) en als 2de de rest van de schijf ook type 83 voor alle data mkfs.ext4 -L CFGBUFS /dev/md/raid5_3x1TB1 && mkdir /mnt/cfgbufs && echo “LABEL=CFGBUFS /mnt/cfgbufs ext4 defaults 0 0” » /etc/fstab mkfs.ext4 -L DATAFS /dev/md/raid5_3x1TB2 && mkdir /mnt/datafs && echo “LABEL=DATAFS /mnt/datafs ext4 defaults 0 0” » /etc/fstab echo “tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777 0 0” » /etc/fstab * Reboot en neem hierna nog een snapshot:

btrbk -v run
Al het visielab specifiek gedoe

* Zie de instructies op ''mijninfo'' voor matlab, dit gaat ongeveer hetzelfde * nfs:

mkdir -p /data/home && apt install nfs && modprobe nfs && echo "10.0.0.10:/data/home /data/home nfs4 proto=tcp,port=2049 0 0" >> /etc/fstab && mount /data/home

* ldap: <code>apt install ldap-utils libnss-ldap libpam-ldap</code> <!– misschien ook apt install nscd–> Config opties: * uri → uri ldap://sto3.visielab.uantwerpen.be * locatie → dc=visielab,dc=be * ldap version → 3 * Make local root Database admin → Yes * Does the LDAP database require login? → No * LDAP account for root → cn=admin,dc=visielab,dc=be * LDAP root account password → zie <code>/etc/ldap.secret</code> op sto3 perl -i -pe 's/^host uri/uri/' /etc/ldap.conf && echo “#### CONFIGURATIE VAN /etc/ldap.conf OVERGENOMEN ###” » /etc/ldap/ldap.conf && cat /etc/ldap.conf » /etc/ldap/ldap.conf perl -i -pe 's/systemd$/systemd ldap/' /etc/nsswitch.conf perl -i -pe 's/.*try_first_pass\n$' /etc/pam.d/common-password && echo “session optional pam_mkhomedir.so skel=/etc/skel umask=077” » /etc/pam.d/common-session <!– KLOPT NIET, VEEG HET WEG NA HET TE CHECKEN: <code>ldap://sto3.visielab.uantwerpen.be</code> als server <code>dc=visielab,dc=be</code> als Distinguished name of the search base ldap versie 3 local root mag database admin zijn geen login nodig voor ldap db <code>cn=admin,dc=visielab,dc=be</code> ** geen pass ldapsearch -x ou=People perl -i -pe 's/compat.*/compat ldap/' /etc/nsswitch.conf –> * <code>apt install python-pip python3-pip</code> * <code>add-apt-resository ppa:graphics-drivers/ppa && apt update && apt install libcuda1-384 nvidia-cuda-toolkit nvidia-driver-390 g++-6-multilib</code>

new_server_version.txt · Last modified: 2019/08/07 12:39 by 143.169.217.228