From 5266b3761e00e4bb212ca442eeb064ad2ceeaa38 Mon Sep 17 00:00:00 2001 From: anoadragon453 Date: Mon, 11 Jul 2022 14:16:33 +0000 Subject: deploy: 5ef2f875699da76e7070593418b066f5c293a12a --- .../usage/configuration/config_documentation.html | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) (limited to 'develop/usage/configuration/config_documentation.html') diff --git a/develop/usage/configuration/config_documentation.html b/develop/usage/configuration/config_documentation.html index 560ce4ffcb..a2abcd329c 100644 --- a/develop/usage/configuration/config_documentation.html +++ b/develop/usage/configuration/config_documentation.html @@ -1173,6 +1173,101 @@ see here.

cp_max: 10
+

databases

+

The databases option allows specifying a mapping between certain database tables and +database host details, spreading the load of a single Synapse instance across multiple +database backends. This is often referred to as "database sharding". This option is only +supported for PostgreSQL database backends.

+

Important note: This is a supported option, but is not currently used in production by the +Matrix.org Foundation. Proceed with caution and always make backups.

+

databases is a dictionary of arbitrarily-named database entries. Each entry is equivalent +to the value of the database homeserver config option (see above), with the addition of +a data_stores key. data_stores is an array of strings that specifies the data store(s) +(a defined label for a set of tables) that should be stored on the associated database +backend entry.

+

The currently defined values for data_stores are:

+ +

All databases will end up with additional tables used for tracking database schema migrations +and any pending background updates. Synapse will create these automatically on startup when checking for +and/or performing database schema migrations.

+

To migrate an existing database configuration (e.g. all tables on a single database) to a different +configuration (e.g. the "main" data store on one database, and "state" on another), do the following:

+
    +
  1. +

    Take a backup of your existing database. Things can and do go wrong and database corruption is no joke!

    +
  2. +
  3. +

    Ensure all pending database migrations have been applied and background updates have run. The simplest +way to do this is to use the update_synapse_database script supplied with your Synapse installation.

    +
    update_synapse_database --database-config homeserver.yaml --run-background-updates
    +
    +
  4. +
  5. +

    Copy over the necessary tables and sequences from one database to the other. Tables relating to database +migrations, schemas, schema versions and background updates should not be copied.

    +

    As an example, say that you'd like to split out the "state" data store from an existing database which +currently contains all data stores.

    +

    Simply copy the tables and sequences defined above for the "state" datastore from the existing database +to the secondary database. As noted above, additional tables will be created in the secondary database +when Synapse is started.

    +
  6. +
  7. +

    Modify/create the databases option in your homeserver.yaml to match the desired database configuration.

    +
  8. +
  9. +

    Start Synapse. Check that it starts up successfully and that things generally seem to be working.

    +
  10. +
  11. +

    Drop the old tables that were copied in step 3.

    +
  12. +
+

Only one of the options database or databases may be specified in your config, but not both.

+

Example configuration:

+
databases:
+  basement_box:
+    name: psycopg2
+    txn_limit: 10000
+    data_stores: ["main"]
+    args:
+      user: synapse_user
+      password: secretpassword
+      database: synapse_main
+      host: localhost
+      port: 5432
+      cp_min: 5
+      cp_max: 10
+
+  my_other_database:
+    name: psycopg2
+    txn_limit: 10000
+    data_stores: ["state"]
+    args:
+      user: synapse_user
+      password: secretpassword
+      database: synapse_state
+      host: localhost
+      port: 5432
+      cp_min: 5
+      cp_max: 10
+
+

Logging

Config options related to logging.


-- cgit 1.5.1