gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-grid5k] 18/48: towards working replication


From: gnunet
Subject: [taler-grid5k] 18/48: towards working replication
Date: Sat, 28 May 2022 12:11:38 +0200

This is an automated email from the git hooks/post-receive script.

marco-boss pushed a commit to branch master
in repository grid5k.

commit cd2b71b3769fe3b5f65060f1b876ced6aeeeae91
Author: Boss Marco <bossm8@bfh.ch>
AuthorDate: Thu May 12 22:17:52 2022 +0200

    towards working replication
---
 experiment/scripts/auditor.sh   | 20 +++++++++++++-------
 experiment/scripts/benchmark.sh |  2 +-
 experiment/scripts/database.sh  | 38 ++++++++++++++++++++++++++++++++------
 experiment/scripts/setup.sh     |  3 ++-
 4 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/experiment/scripts/auditor.sh b/experiment/scripts/auditor.sh
index aa0af06..d602214 100644
--- a/experiment/scripts/auditor.sh
+++ b/experiment/scripts/auditor.sh
@@ -56,9 +56,10 @@ EOF
 psql -d exchange-ingress -U auditor-ingress -tAc 'GRANT ALL ON ALL TABLES IN 
SCHEMA public TO sync;'
 EOF
 
+  # Only needed if we want to repicate this database again
+  # 
   #createdb -O sync exchange-production
   #createdb -O auditor-wire libeufin
-
   #psql -d exchange-prodution -U sync -tAc 'GRANT SELECT ON ALL TABLE IN 
SCHEMA public TO auditor;'
   #psql -d libeufin -U auditor-wire -tAc 'GRANT SELECT ON ALL TABLE IN SCHEMA 
public TO auditor;'
 }
@@ -68,14 +69,19 @@ function setup_exchange_replication() {
   taler-config -s exchange -o DB -V "postgres"
   taler-config -s exchangedb-postgres -o CONFIG -V 
"postgres:///exchange-ingress"
 
-  su auditor-ingress << EOF
-  taler-exchange-dbinit
-EOF
+  sudo -u auditor-ingress taler-exchange-dbinit -r || true
+  sudo -u auditor-ingress taler-exchange-dbinit -s || true
+
+  if [ "${PARTITION_DB}" = "true" ]; then
+    sudo -u auditor-ingress taler-exchange-dbinit -P ${NUM_PARTITIONS}
+  else
+    sudo -u auditor-infress taler-exchange-dbinit
+  fi
+
+  DB_USER=egress wait_for_db   
 
   su postgres << EOF
-  createuser --replication egress
-  psql -tAc "ALTER ROLE egress WITH PASSWORD '${DB_PASSWORD}';" || true
-  psql -d exchange-ingress -tAc "CREATE PUBLICATION ${NODE_NAME} FOR ALL 
TABLES;"
+  psql -d exchange-ingress -tAc "CREATE SUBSCRIPTION IF NOT EXISTS 
${NODE_NAME} CONNECTION 
'postgresql://egress:${DB_PASSWORD}@${DB_HOSTS}/${DB_NAME}' PUBLICATION 
exchange;"
 EOF
 }
 
diff --git a/experiment/scripts/benchmark.sh b/experiment/scripts/benchmark.sh
index e0b4478..41b7b3a 100755
--- a/experiment/scripts/benchmark.sh
+++ b/experiment/scripts/benchmark.sh
@@ -27,7 +27,7 @@ function start_wallet_bench() {
     LOG_LEVEL=INFO
   fi
 
-  NUM_DEPOSITS=$((RANDOM %100))
+  NUM_DEPOSITS=50
   if [[ ${WALLET_WITHDRAW_ONLY} == "true" ]]; then
     NUM_DEPOSITS=0
   fi
diff --git a/experiment/scripts/database.sh b/experiment/scripts/database.sh
index cc10e08..8a22bb7 100755
--- a/experiment/scripts/database.sh
+++ b/experiment/scripts/database.sh
@@ -13,6 +13,8 @@ source ~/scripts/helpers.sh
 # move to tmp to prevent change directory errors
 cd /tmp 
 
+PG_CONF=/etc/postgresql/${POSTGRES_VERSION}/main
+
 # Setup a disk if present to be used for WAL and move the WAL there
 # Don't use in combination with `setup_ram_storage`
 function setup_disks() {
@@ -224,14 +226,19 @@ function setup_config() {
 
   # set our database location to /tmp
   data_directory='/tmp/postgresql/${POSTGRES_VERSION}/main'
-  " > /etc/postgresql/${POSTGRES_VERSION}/main/exchange.conf
+  " > ${PG_CONF}/exchange.conf
+
+  # Must be done here otherwise pg does not start a second time
+  if [[ ${NUM_AUDITORS} -gt 0 ]]; then
+    echo "wal_level=logical" >> ${PG_CONF}/exchange.conf
+  fi
 
-  cp /etc/postgresql/${POSTGRES_VERSION}/main/exchange.conf 
${LOG_DIR}/postgresql.conf
+  cp ${PG_CONF}/exchange.conf ${LOG_DIR}/postgresql.conf
 
   if ! grep -q "include = 'exchange.conf'" \
-         /etc/postgresql/${POSTGRES_VERSION}/main/postgresql.conf; then
+         ${PG_CONF}/postgresql.conf; then
     echo "include = 'exchange.conf'" >> \
-          /etc/postgresql/${POSTGRES_VERSION}/main/postgresql.conf
+          ${PG_CONF}/postgresql.conf
   fi
 }
 
@@ -250,17 +257,35 @@ function setup_pgbouncer() {
   fi
 }
 
+# Enable replication to the auditor - is only done when an auditor node is 
present
+function setup_replication() {
+  if [[ "${NUM_AUDITORS}" -gt 0 ]]; then
+    su postgres << EOF
+      createuser --replication egress
+      psql -tAc "ALTER ROLE egress WITH PASSWORD '${DB_PASSWORD}';" || true
+      psql -d ${DB_NAME} -tAc "GRANT SELECT ON ALL TABLES IN SCHEMA public TO 
egress;"
+      psql -tAc "DROP PUBLICATION auditor;"
+      psql -d ${DB_NAME} -tAc "CREATE PUBLICATION exchange FOR ALL TABLES;"
+EOF
+    grep -q "host all egress 127.16.0.0/12 md5" \
+      ${PG_CONF}/pg_hba.conf \
+      || echo "host all egress 172.16.0.0/12 md5" \
+         >> ${PG_CONF}/pg_hba.conf
+    systemctl restart postgresql
+  fi
+}
+
 # Allow DB_USER from remote (Exchange will continue initialization only when 
 # this one was run)
 function enable_remote_access() {
   # Enable password for taler since this is the case in real world deployments
   # For the postgres user do not enable authentication (used in metrics)
   if ! grep -q "host all ${DB_USER} 127.16.0.0/12 md5" \
-    /etc/postgresql/${POSTGRES_VERSION}/main/pg_hba.conf; then
+    ${PG_CONF}/pg_hba.conf; then
     echo "
     host all ${DB_USER} 172.16.0.0/12 md5
     host all postgres 172.16.0.0/12 trust
-    " >> /etc/postgresql/${POSTGRES_VERSION}/main/pg_hba.conf
+    " >> ${PG_CONF}/pg_hba.conf
   fi
 }
 
@@ -344,6 +369,7 @@ case ${1} in
       setup_disks
     fi
     init_db
+    setup_replication
     setup_pgbouncer
     restart_rsyslog
     ;;
diff --git a/experiment/scripts/setup.sh b/experiment/scripts/setup.sh
index 14ad4d4..65d2a2f 100644
--- a/experiment/scripts/setup.sh
+++ b/experiment/scripts/setup.sh
@@ -197,7 +197,8 @@ function clean_previous_setup() {
   # (not all are present on every node - || true - to ignore errors)
   systemctl stop taler-exchange-* \
                 taler-wallet* \
-                prometheus* \
+                prometheus \
+                prometheus-*-exporter \
                  postgresql* \
                 promtail \
                 loki \

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]