Skip to content

Commit

Permalink
Modifying documentation to add information about cockroachDB.
Browse files Browse the repository at this point in the history
  • Loading branch information
JanuszJakubiec committed Oct 10, 2024
1 parent b69fa3f commit 2871110
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 22 deletions.
31 changes: 30 additions & 1 deletion doc/configuration/database-backends-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Persistent Data:
* RDBMS - MongooseIM has a strong backend support for relational databases.
Reliable and battle proven, they are a great choice for regular MongooseIM use cases and features like `privacy lists`, `vcards`, `roster`, `private storage`, `last activity` and `message archive`.
Never loose your data.
Use MySQL, MariaDB, PostgreSQL, or MS SQL Server.
Use MySQL, MariaDB, PostgreSQL, CockroachDB, or MS SQL Server.

* Cassandra - Only for MAM (Message Archive Management).

Expand Down Expand Up @@ -125,6 +125,35 @@ Please refer to the [RDBMS options](outgoing-connections.md#rdbms-options)
and [general database options](general.md#database-settings)
for more information.

### CockroachDB

**Can be used for:**

* users (credentials)
* vcards
* roster
* private storage
* privacy/block lists
* last activity
* mam (message archive management)
* muc_light rooms

**Setup**

The schema files can be found in the `priv` directory.
The default schema is defined in the `cockroachdb.sql` file.

You can use the following command to apply it on localhost:

```bash
psql -h localhost -U user -p 26257 -c "CREATE DATABASE mongooseim;"
psql -h localhost -U user -p 26257 -q -d mongooseim -f cockroachdb.sql
```
You should also configure the CockroachDB database in the `mongooseim.toml` file.
Please refer to the [RDBMS options](outgoing-connections.md#rdbms-options)
and [general database options](general.md#database-settings)
for more information.

### Microsoft SQL Server

Microsoft SQL Server, sometimes called MSSQL, or Azure SQL Database.
Expand Down
16 changes: 8 additions & 8 deletions doc/configuration/outgoing-connections.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ For example:
### RDBMS options

#### `outgoing_pools.rdbms.*.connection.driver`
* **Syntax:** string, one of `"pgsql"`, `"mysql"` or `"odbc"` (a supported driver)
* **Syntax:** string, one of `"pgsql"`, `"mysql"`, `"cockroachdb"` or `"odbc"` (a supported driver)
* **Default:** none - this option is mandatory
* **Example:** `driver = "psgql"`

Expand All @@ -101,34 +101,34 @@ How long MongooseIM will wait for the database to answer for a query.

When MongooseIM fails to connect to the DB, it retries with an exponential backoff. This option limits the backoff time for faster reconnection when the DB becomes reachable again.

### Options for `pgsql` and `mysql`
### Options for `pgsql`, `cockroachdb` and `mysql`

#### `outgoing_pools.rdbms.*.connection.host`
* **Syntax:** string
* **Default:** no default; required for `pgsql` and `mysql`
* **Default:** no default; required for `pgsql`, `cockroachdb` and `mysql`
* **Example:** `host = "localhost"`

#### `outgoing_pools.rdbms.*.connection.port`
* **Syntax:** integer, between 0 and 65535
* **Default:** `5432` for `pgsql`; `3306` for `mysql`
* **Default:** `5432` for `pgsql`; `26257` for `cockroachdb`; `3306` for `mysql`
* **Example:** `port = 5343`

#### `outgoing_pools.rdbms.*.connection.database`
* **Syntax:** string
* **Default:** no default; required for `pgsql` and `mysql`
* **Default:** no default; required for `pgsql`, `cockroachdb` and `mysql`
* **Example:** `database = "mim-db"`

#### `outgoing_pools.rdbms.*.connection.username`
* **Syntax:** string
* **Default:** no default; required for `pgsql` and `mysql`
* **Default:** no default; required for `pgsql`, `cockroachdb` and `mysql`
* **Example:** `username = "mim-user"`

#### `outgoing_pools.rdbms.*.connection.password`
* **Syntax:** string
* **Default:** no default; required for `pgsql` and `mysql`
* **Default:** no default; required for `pgsql`, `cockroachdb` and `mysql`
* **Example:** `password = "mim-password"`

To enable TLS, you need to include the [TLS section](#tls-options) in the connection options. There is one additonal option for PostgreSQL:
To enable TLS, you need to include the [TLS section](#tls-options) in the connection options. There is one additonal option for PostgreSQL and CockroachDB:

#### `outgoing_pools.rdbms.*.connection.tls.required`
* **Syntax:** boolean
Expand Down
21 changes: 20 additions & 1 deletion doc/migrations/6.2.1_x.x.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,23 @@ Stop the cluster, or individual nodes, if performing a rolling upgrade, and exec
3. Add Prometheus to the [instrumentation section](../configuration/instrumentation.md).
4. Configure a [listener](../listeners/listen-http.md#handler-types-prometheus-mongoose_prometheus_handler) for Prometheus.

Restart the node or cluster.
Restart the node or cluster.

## Support for the new RDBMS database - CockroachDB

We've introduced support for a new RDBMS database, CockroachDB. To ensure compatibility and proper functionality, we've also added a new test preset: `cockroachdb_cets`.

To configure CockroachDB, update the connection settings in your configuration file as follows:
```toml
[outgoing_pools.rdbms.default.connection]
driver = "cockroachdb"
host = "localhost"
port = 26257
database = "mongooseim"
username = "mongooseim"
password = "mongooseim_secret"
```

Refer to the [Outgoing connections configuration doc](../configuration/outgoing-connections.md) for more information.

The migration script for CockroachDB , `cockroachdb.sql` is located in the [`priv/migrations`](https://github.com/esl/MongooseIM/tree/master/priv/migrations) directory.
2 changes: 1 addition & 1 deletion doc/modules/mod_mam.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MongooseIM is compatible with MAM 0.4-1.1.0.

Configure MAM with different storage backends:

* RDBMS (databases like MySQL, PostgreSQL, MS SQL Server)
* RDBMS (databases like MySQL, PostgreSQL, CockroachDB, MS SQL Server)
* Cassandra (NoSQL)
* ElasticSearch (NoSQL)

Expand Down
22 changes: 11 additions & 11 deletions src/vcard/mod_vcard_rdbms.erl
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,17 @@ column_to_id(<<"lorgunit">>) -> "U".

search_columns() ->
[<<"username">>,
<<"fn">>, <<"lfn">>,
<<"family">>, <<"lfamily">>,
<<"given">>, <<"lgiven">>,
<<"middle">>, <<"lmiddle">>,
<<"nickname">>, <<"lnickname">>,
<<"bday">>, <<"lbday">>,
<<"ctry">>, <<"lctry">>,
<<"locality">>, <<"llocality">>,
<<"email">>, <<"lemail">>,
<<"orgname">>, <<"lorgname">>,
<<"orgunit">>, <<"lorgunit">>].
<<"fn">>, <<"lfn">>,
<<"family">>, <<"lfamily">>,
<<"given">>, <<"lgiven">>,
<<"middle">>, <<"lmiddle">>,
<<"nickname">>, <<"lnickname">>,
<<"bday">>, <<"lbday">>,
<<"ctry">>, <<"lctry">>,
<<"locality">>, <<"llocality">>,
<<"email">>, <<"lemail">>,
<<"orgname">>, <<"lorgname">>,
<<"orgunit">>, <<"lorgunit">>].

search_args(User, Search) ->
[User,
Expand Down
1 change: 1 addition & 0 deletions tools/setup-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Environment variable DB is used by this script.
# If DB is undefined, than this script does nothing.

# Docker for Mac should be used on Mac (not docker-machine!)
# https://store.docker.com/editions/community/docker-ce-desktop-mac

Expand Down

0 comments on commit 2871110

Please sign in to comment.