diff --git a/lxc1/p0-infrastructure/mgdb.yml b/lxc1/p0-infrastructure/mgdb.yml index eda7ff3..7640c21 100644 --- a/lxc1/p0-infrastructure/mgdb.yml +++ b/lxc1/p0-infrastructure/mgdb.yml @@ -9,26 +9,31 @@ services: - MARIADB_USER=${DB_ADMIN_USER} - MARIADB_PASSWORD=${DB_ADMIN_PASSWORD} - MARIADB_DATABASE=initial_db - - SST_PASSWORD=${SST_PASSWORD} + # Pass these through for the init script + - APP_REGISTRY=${APP_REGISTRY} + - REPL_USER=${REPL_USER} + - REPL_PASSWORD=${REPL_PASSWORD} + # Dynamic password variables for your apps + - FORGEJO_DB_PASS=${FORGEJO_DB_PASS} + - GUACAMOLE_DB_PASS=${GUACAMOLE_DB_PASS} + - GRAFANA_DB_PASS=${GRAFANA_DB_PASS} volumes: - /docker/maria/data:/var/lib/mysql - /docker/maria/conf:/etc/mysql/conf.d - /docker/maria/init:/docker-entrypoint-initdb.d command: - mariadbd - - --${WS_NEW_CLUSTER} - - --wsrep-on=ON - - --wsrep-provider=/usr/lib/galera/libgalera_smm.so - - --wsrep-cluster-name=${CLUSTER_NAME} - - --wsrep-cluster-address=gcomm://${CLUSTER_LOCAL_IP},${CLUSTER_REMOTE_IP}?pc.wait_prim=no - - --wsrep-node-address=${CLUSTER_KEEPALIVED_IP} - - --wsrep-node-name=node${MGDB_NODE_NUMBER} - - --binlog-format=row - - --default-storage-engine=innodb - - --innodb-autoinc-lock-mode=2 + # NETWORK BINDING - --bind-address=0.0.0.0 - # Switch to MariaBackup (The production standard) - - --wsrep-sst-method=mariabackup - - --wsrep-sst-auth=sstuser:${SST_PASSWORD} - # Weight 2 on Node 1 forces it to be the leader during reboots/resets - - --wsrep-provider-options=pc.ignore_sb=true;pc.npvo=true;pc.weight=${MARIA_PC_WEIGHT};pc.bootstrap=true \ No newline at end of file + # ASYNC REPLICATION CONFIG + - --log-bin=mysql-bin + - --binlog-format=ROW + - --server-id=${MGDB_NODE_NUMBER} + - --log-slave-updates=ON + - --gtid-strict-mode=ON + # COLLISION PREVENTION (Odds vs Evens) + - --auto-increment-increment=2 + - --auto-increment-offset=${MGDB_NODE_NUMBER} + # PERFORMANCE + - --innodb-buffer-pool-size=1G # Adjust based on your RAM + - --innodb-flush-log-at-trx-commit=2 # 1=Safest, 2=Faster \ No newline at end of file diff --git a/lxc1/p0-infrastructure/mgdb/01_deploy_mgdb_dbs.sh b/lxc1/p0-infrastructure/mgdb/01_deploy_mgdb_dbs.sh index 1a0569f..a506d47 100644 --- a/lxc1/p0-infrastructure/mgdb/01_deploy_mgdb_dbs.sh +++ b/lxc1/p0-infrastructure/mgdb/01_deploy_mgdb_dbs.sh @@ -32,11 +32,10 @@ done echo "All slots provisioned. Flushing privileges..." mariadb -u root -p"${M_ROOT_PASS}" -e "FLUSH PRIVILEGES;" -# Add this inside your 01_deploy_mgdb_dbs.sh script -# (either in the loop or as a standalone block at the bottom) - -mariadb -u root -p"${M_ROOT_PASS}" <<-EOSQL - CREATE USER IF NOT EXISTS 'sstuser'@'localhost' IDENTIFIED BY '${SST_PASSWORD}'; - GRANT RELOAD, PROCESS, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost'; +echo "Creating Replication User..." +mariadb -u root -p"${MARIADB_ROOT_PASSWORD}" <<-EOSQL + -- Create the replicator user allowing access from anywhere (or specify IPs) + CREATE USER IF NOT EXISTS '${REPL_USER}'@'%' IDENTIFIED BY '${REPL_PASSWORD}'; + GRANT REPLICATION SLAVE ON *.* TO '${REPL_USER}'@'%'; FLUSH PRIVILEGES; EOSQL \ No newline at end of file