aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2021-03-09 01:13:47 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2021-03-09 01:13:47 +0100
commitef909e2435194af725f4338a13e4732328ef7361 (patch)
treeedea0c466a7ad3ef083cfa1e57cd4fdf79081ab8 /modules
parent85ad771e2635a544461f0a340f8b8c7126688678 (diff)
downloadNix-ef909e2435194af725f4338a13e4732328ef7361.tar.gz
Nix-ef909e2435194af725f4338a13e4732328ef7361.tar.zst
Nix-ef909e2435194af725f4338a13e4732328ef7361.zip
Adjust sql parameters
This commit makes several changes: - One of the mysql databases is not dumped anymore - Monitoring now checks that mysql is actually replicating - Databases are migrated to ssd
Diffstat (limited to 'modules')
-rw-r--r--modules/private/databases/mariadb_replication.nix1
-rw-r--r--modules/private/monitoring/objects_common.nix2
-rwxr-xr-xmodules/private/monitoring/plugins/check_mysql_replication8
-rw-r--r--modules/private/system/eldiron.nix26
4 files changed, 33 insertions, 4 deletions
diff --git a/modules/private/databases/mariadb_replication.nix b/modules/private/databases/mariadb_replication.nix
index ae54265..5a5a8b0 100644
--- a/modules/private/databases/mariadb_replication.nix
+++ b/modules/private/databases/mariadb_replication.nix
@@ -145,6 +145,7 @@ in
145 --gtid \ 145 --gtid \
146 --master-data \ 146 --master-data \
147 --flush-privileges \ 147 --flush-privileges \
148 --ignore-database=netdata \
148 --all-databases > $filename 149 --all-databases > $filename
149 ${pkgs.gzip}/bin/gzip $filename 150 ${pkgs.gzip}/bin/gzip $filename
150 ''; 151 '';
diff --git a/modules/private/monitoring/objects_common.nix b/modules/private/monitoring/objects_common.nix
index 4b44e56..ee158dc 100644
--- a/modules/private/monitoring/objects_common.nix
+++ b/modules/private/monitoring/objects_common.nix
@@ -145,7 +145,7 @@ in
145 check_smtp = "$USER1$/check_smtp -H $HOSTADDRESS$ -p 25 -S -D 21,15"; 145 check_smtp = "$USER1$/check_smtp -H $HOSTADDRESS$ -p 25 -S -D 21,15";
146 check_tcp = "$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ -e \"$ARG2$\" -Mcrit"; 146 check_tcp = "$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ -e \"$ARG2$\" -Mcrit";
147 check_tcp_ssl = "$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ -S -D 21,15"; 147 check_tcp_ssl = "$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ -S -D 21,15";
148 check_zfs = "$USER2$/check_zpool.sh -p ALL"; 148 check_zfs = "$USER2$/check_zpool.sh -p ALL -w 80 -c 90";
149 149
150 check_host_alive = "$USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5"; 150 check_host_alive = "$USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5";
151 check_last_file_date = "${sudo} -u \"$ARG3$\" $USER2$/check_last_file_date \"$ARG1$\" \"$ARG2$\""; 151 check_last_file_date = "${sudo} -u \"$ARG3$\" $USER2$/check_last_file_date \"$ARG1$\" \"$ARG2$\"";
diff --git a/modules/private/monitoring/plugins/check_mysql_replication b/modules/private/monitoring/plugins/check_mysql_replication
index 4027f63..1ee5de1 100755
--- a/modules/private/monitoring/plugins/check_mysql_replication
+++ b/modules/private/monitoring/plugins/check_mysql_replication
@@ -10,7 +10,10 @@ config_file=$2
10info=$(mysql --defaults-file=${config_file} -S $socket -e "show slave status" --vertical) 10info=$(mysql --defaults-file=${config_file} -S $socket -e "show slave status" --vertical)
11exit_code=$? 11exit_code=$?
12 12
13lag=$(echo "$info" | grep Seconds_Behind_Master | cut -d':' -f2 | sed -e "s/\s//g") 13lag=$(echo "$info" | grep "\bSeconds_Behind_Master\b" | cut -d':' -f2 | sed -e "s/\s//g")
14
15IO_running=$(echo "$info" | grep "\bSlave_IO_Running\b" | cut -d':' -f2 | sed -e "s/\s//g")
16SQL_running=$(echo "$info" | grep "\bSlave_SQL_Running\b" | cut -d':' -f2 | sed -e "s/\s//g")
14 17
15if [[ $exit_code -ne 0 ]]; then 18if [[ $exit_code -ne 0 ]]; then
16 echo "UNKNOWN - Impossible to run mysql command" 19 echo "UNKNOWN - Impossible to run mysql command"
@@ -18,6 +21,9 @@ if [[ $exit_code -ne 0 ]]; then
18elif [[ -z "$lag" ]]; then 21elif [[ -z "$lag" ]]; then
19 echo "UNKNOWN - No replication found for mysql" 22 echo "UNKNOWN - No replication found for mysql"
20 exit $STATE_UNKNOWN 23 exit $STATE_UNKNOWN
24elif [[ "$IO_running" != "Yes" || "$SQL_running" != "Yes" ]]; then
25 echo "UNKNOWN - Replication is not running"
26 exit $STATE_UNKNOWN
21else 27else
22 output="Replication lag for mysql is ${lag}s" 28 output="Replication lag for mysql is ${lag}s"
23 LC_ALL=C lag=$(printf "%.*f" 0 $lag) 29 LC_ALL=C lag=$(printf "%.*f" 0 $lag)
diff --git a/modules/private/system/eldiron.nix b/modules/private/system/eldiron.nix
index 102a517..2475710 100644
--- a/modules/private/system/eldiron.nix
+++ b/modules/private/system/eldiron.nix
@@ -31,12 +31,34 @@
31 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; }; 31 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
32 32
33 fileSystems = { 33 fileSystems = {
34 # pools:
35 # zpool: ashift=12
36 # zfast: ashift=12
37 # zfs:
38 # zpool/: acltype=posixacl ; xattr=sa ; atime=off ; mountpoint=legacy
39 # zpool/root: encryption=on ; keyformat=passphrase ; keylocation=file:///boot/pass.key
40 # zpool/root/var: atime=on
41 # zfast/: acltype=posixacl ; xattr=sa ; atime=off ; mountpoint=legacy
42 # zfast/root: encryption=on ; keyformat=passphrase ; keylocation=file:///boot/pass.key
43 # zfast/root/etc: ø
44 # zfast/root/nix: ø
45 # zfast/root/tmp: async=disabled
46 # zfast/root/var: atime=on
47 # zfast/root/var/lib: ø
48 # zfast/root/var/lib/mysql: logbias=throughput ; atime=off ; primarycache=metadata
49 # zfast/root/var/lib/postgresql: recordsize=8K ; atime=off ; logbias=throughput
50 # zfast/root/var/lib/postgresql/11.0: ø
51 # zfast/root/var/lib/postgresql/11.0/pg_wal: ø
34 "/" = { fsType = "zfs"; device = "zpool/root"; }; 52 "/" = { fsType = "zfs"; device = "zpool/root"; };
35 "/boot" = { fsType = "ext4"; device = "/dev/disk/by-uuid/e6bb18fb-ff56-4b5f-ae9f-e60d40dc0622"; }; 53 "/boot" = { fsType = "ext4"; device = "/dev/disk/by-uuid/e6bb18fb-ff56-4b5f-ae9f-e60d40dc0622"; };
36 "/etc" = { fsType = "zfs"; device = "zpool/root/etc"; }; 54 "/etc" = { fsType = "zfs"; device = "zpool/root/etc"; };
37 "/nix" = { fsType = "zfs"; device = "zpool/root/nix"; }; 55 "/nix" = { fsType = "zfs"; device = "zfast/root/nix"; };
38 "/tmp" = { fsType = "zfs"; device = "zpool/root/tmp"; }; 56 "/tmp" = { fsType = "zfs"; device = "zfast/root/tmp"; };
39 "/var" = { fsType = "zfs"; device = "zpool/root/var"; }; 57 "/var" = { fsType = "zfs"; device = "zpool/root/var"; };
58 "/var/lib/mysql" = { fsType = "zfs"; device = "zfast/root/var/lib/mysql"; };
59 "/var/lib/postgresql" = { fsType = "zfs"; device = "zfast/root/var/lib/postgresql"; };
60 "/var/lib/postgresql/11.0" = { fsType = "zfs"; device = "zfast/root/var/lib/postgresql/11.0"; };
61 "/var/lib/postgresql/11.0/pg_wal" = { fsType = "zfs"; device = "zfast/root/var/lib/postgresql/11.0/pg_wal"; };
40 }; 62 };
41 swapDevices = [ { label = "swap1"; } { label = "swap2"; } ]; 63 swapDevices = [ { label = "swap1"; } { label = "swap2"; } ];
42 hardware.enableRedistributableFirmware = true; 64 hardware.enableRedistributableFirmware = true;