]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Adjust sql parameters
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 9 Mar 2021 00:13:47 +0000 (01:13 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 9 Mar 2021 00:13:47 +0000 (01:13 +0100)
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

modules/private/databases/mariadb_replication.nix
modules/private/monitoring/objects_common.nix
modules/private/monitoring/plugins/check_mysql_replication
modules/private/system/eldiron.nix

index ae54265a7191fb320022ebe33f1a50f082d957a5..5a5a8b0ebcb669df0f7a84135cb3c8cb2156d35e 100644 (file)
@@ -145,6 +145,7 @@ in
                 --gtid \
                 --master-data \
                 --flush-privileges \
+                --ignore-database=netdata \
                 --all-databases > $filename
               ${pkgs.gzip}/bin/gzip $filename
             '';
index 4b44e56bfd9495e879cc2ab7d88c6e4af5e8e9d1..ee158dcca0ebf17448a44c73c1a86320fb811963 100644 (file)
@@ -145,7 +145,7 @@ in
     check_smtp = "$USER1$/check_smtp -H $HOSTADDRESS$ -p 25 -S -D 21,15";
     check_tcp = "$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ -e \"$ARG2$\" -Mcrit";
     check_tcp_ssl = "$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ -S -D 21,15";
-    check_zfs = "$USER2$/check_zpool.sh -p ALL";
+    check_zfs = "$USER2$/check_zpool.sh -p ALL -w 80 -c 90";
 
     check_host_alive = "$USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5";
     check_last_file_date = "${sudo} -u \"$ARG3$\" $USER2$/check_last_file_date \"$ARG1$\" \"$ARG2$\"";
index 4027f63f0ec57f45fd5df19caacf7b57b9496e74..1ee5de1470c71da3c2eaa3fc4054a5b776f05e07 100755 (executable)
@@ -10,7 +10,10 @@ config_file=$2
 info=$(mysql --defaults-file=${config_file} -S $socket -e "show slave status" --vertical)
 exit_code=$?
 
-lag=$(echo "$info" | grep Seconds_Behind_Master | cut -d':' -f2 | sed -e "s/\s//g")
+lag=$(echo "$info" | grep "\bSeconds_Behind_Master\b" | cut -d':' -f2 | sed -e "s/\s//g")
+
+IO_running=$(echo "$info" | grep "\bSlave_IO_Running\b" | cut -d':' -f2 | sed -e "s/\s//g")
+SQL_running=$(echo "$info" | grep "\bSlave_SQL_Running\b" | cut -d':' -f2 | sed -e "s/\s//g")
 
 if [[ $exit_code -ne 0 ]]; then
   echo "UNKNOWN - Impossible to run mysql command"
@@ -18,6 +21,9 @@ if [[ $exit_code -ne 0 ]]; then
 elif [[ -z "$lag" ]]; then
   echo "UNKNOWN - No replication found for mysql"
   exit $STATE_UNKNOWN
+elif [[ "$IO_running" != "Yes" || "$SQL_running" != "Yes" ]]; then
+  echo "UNKNOWN - Replication is not running"
+  exit $STATE_UNKNOWN
 else
   output="Replication lag for mysql is ${lag}s"
   LC_ALL=C lag=$(printf "%.*f" 0 $lag)
index 102a517007594be2177a9ee94f45522e300c17c4..2475710771ffd778246bfe98d06e3373cdb98c70 100644 (file)
   myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
 
   fileSystems = {
+    # pools:
+    #     zpool: ashift=12
+    #     zfast: ashift=12
+    # zfs:
+    #     zpool/: acltype=posixacl ; xattr=sa ; atime=off ; mountpoint=legacy
+    #     zpool/root: encryption=on ; keyformat=passphrase ; keylocation=file:///boot/pass.key
+    #     zpool/root/var: atime=on
+    #     zfast/: acltype=posixacl ; xattr=sa ; atime=off ; mountpoint=legacy
+    #     zfast/root: encryption=on ; keyformat=passphrase ; keylocation=file:///boot/pass.key
+    #     zfast/root/etc: ø
+    #     zfast/root/nix: ø
+    #     zfast/root/tmp: async=disabled
+    #     zfast/root/var: atime=on
+    #     zfast/root/var/lib: ø
+    #     zfast/root/var/lib/mysql: logbias=throughput ; atime=off ; primarycache=metadata
+    #     zfast/root/var/lib/postgresql: recordsize=8K ; atime=off ; logbias=throughput
+    #     zfast/root/var/lib/postgresql/11.0: ø
+    #     zfast/root/var/lib/postgresql/11.0/pg_wal: ø
     "/"     = { fsType = "zfs"; device = "zpool/root"; };
     "/boot" = { fsType = "ext4"; device = "/dev/disk/by-uuid/e6bb18fb-ff56-4b5f-ae9f-e60d40dc0622"; };
     "/etc"  = { fsType = "zfs"; device = "zpool/root/etc"; };
-    "/nix"  = { fsType = "zfs"; device = "zpool/root/nix"; };
-    "/tmp"  = { fsType = "zfs"; device = "zpool/root/tmp"; };
+    "/nix"  = { fsType = "zfs"; device = "zfast/root/nix"; };
+    "/tmp"  = { fsType = "zfs"; device = "zfast/root/tmp"; };
     "/var"  = { fsType = "zfs"; device = "zpool/root/var"; };
+    "/var/lib/mysql" = { fsType = "zfs"; device = "zfast/root/var/lib/mysql"; };
+    "/var/lib/postgresql"             = { fsType = "zfs"; device = "zfast/root/var/lib/postgresql"; };
+    "/var/lib/postgresql/11.0"        = { fsType = "zfs"; device = "zfast/root/var/lib/postgresql/11.0"; };
+    "/var/lib/postgresql/11.0/pg_wal" = { fsType = "zfs"; device = "zfast/root/var/lib/postgresql/11.0/pg_wal"; };
   };
   swapDevices = [ { label = "swap1"; } { label = "swap2"; } ];
   hardware.enableRedistributableFirmware = true;