Run mysql on the primary storage machine.

This commit is contained in:
2025-10-22 13:20:13 +01:00
parent 967ff34a51
commit 65835e1ed0
2 changed files with 15 additions and 7 deletions

View File

@@ -3,11 +3,17 @@ job "mysql-backup" {
type = "batch" type = "batch"
periodic { periodic {
cron = "23 23 * * * *" crons = ["23 23 * * * *"]
prohibit_overlap = true prohibit_overlap = true
} }
group "db" { group "db" {
# Run on primary storage node for fast local disk access
constraint {
attribute = "${meta.storage_role}"
value = "primary"
}
task "backup" { task "backup" {
driver = "raw_exec" driver = "raw_exec"
@@ -21,7 +27,7 @@ job "mysql-backup" {
data = <<EOH data = <<EOH
set -e set -e
/run/current-system/sw/bin/nomad alloc exec -job -task=mysqld mysql \ /run/current-system/sw/bin/nomad alloc exec -job -task=mysqld mysql \
mysqldump -u root --password="$MYSQL_ROOT_PASS" --all-databases > /data/compute/appdata/db-backups/mysql/backup.sql && \ mysqldump -u root --password="$MYSQL_ROOT_PASS" --all-databases > /data/services/db-backups/mysql/backup.sql && \
echo "last_success $(date +%s)" | \ echo "last_success $(date +%s)" | \
/run/current-system/sw/bin/curl --data-binary @- http://pushgateway.service.consul:9091/metrics/job/mysql_backup /run/current-system/sw/bin/curl --data-binary @- http://pushgateway.service.consul:9091/metrics/job/mysql_backup
EOH EOH

View File

@@ -6,6 +6,12 @@ job "mysql" {
} }
group "db" { group "db" {
# Run on primary storage node (zippy) for local disk performance
constraint {
attribute = "${meta.storage_role}"
value = "primary"
}
network { network {
port "db" { port "db" {
static = 3306 static = 3306
@@ -19,13 +25,9 @@ job "mysql" {
config { config {
image = "mysql:9.4" image = "mysql:9.4"
args = [
# 300M, up from default of 100M
"--innodb-redo-log-capacity=314572800",
]
ports = ["db"] ports = ["db"]
volumes = [ volumes = [
"/data/compute/appdata/mysql:/var/lib/mysql", "/data/services/mysql:/var/lib/mysql",
] ]
} }