From 492130d84648355123ac11a5f7b16bd2c1678ae6 Mon Sep 17 00:00:00 2001 From: coltoneshaw Date: Fri, 29 Mar 2024 12:50:57 -0400 Subject: [PATCH] moved postgres primary setup --- docker-compose.yml | 57 +++------------------- files/postgres/primary/init.sh | 3 ++ files/postgres/primary/primary_config.conf | 25 ++++++++++ 3 files changed, 36 insertions(+), 49 deletions(-) create mode 100755 files/postgres/primary/init.sh create mode 100644 files/postgres/primary/primary_config.conf diff --git a/docker-compose.yml b/docker-compose.yml index 3bae22a..a6862c3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,11 +1,6 @@ services: postgres: container_name: cs-repro-postgres - environment: - - POSTGRES_USER=mmuser - - POSTGRES_PASSWORD=mmuser_password - - POSTGRES_DB=mattermost - - LISTEN_ADDRESS="*" image: postgres:14-alpine restart: unless-stopped ports: @@ -19,11 +14,18 @@ services: - /var/run/postgresql volumes: - ./volumes/db/var/lib/postgresql/data:/var/lib/postgresql/data + - ./files/postgres/primary/init.sh:/docker-entrypoint-initdb.d/init.sh + - ./files/postgres/primary/primary_config.conf:/files/postgres/primary/primary_config.conf healthcheck: test: pg_isready -U mmuser -d mattermost interval: 10s timeout: 3s retries: 3 + environment: + - POSTGRES_USER=mmuser + - POSTGRES_PASSWORD=mmuser_password + - POSTGRES_DB=mattermost + - LISTEN_ADDRESS="*" openldap: platform: linux/amd64 container_name: cs-repro-openldap @@ -160,47 +162,4 @@ services: # - "3306" # # Where our data will be persisted # volumes: - # - ./volumes/db/mysql:/var/lib/mysql - - # postgres-replica: - # container_name: cs-repro-postgres-replica - # environment: - # - POSTGRES_USER=mmuser - # - POSTGRES_PASSWORD=mmuser_password - # # - POSTGRES_DB=mattermost - # - LISTEN_ADDRESS="*" - # image: postgres:13-alpine - # restart: unless-stopped - # ports: - # - "5433:5432" - # security_opt: - # - no-new-privileges:true - # pids_limit: 100 - # read_only: false - # tmpfs: - # - /tmp - # - /var/run/postgresql - # volumes: - # # - ./volumes/db-replica/var/lib/postgresql/data:/var/lib/postgresql/data - # - ./volumes/db-replica/data2:/var/lib/postgresql/data - # postgres-replica2: - # container_name: cs-repro-postgres-replica2 - # environment: - # - POSTGRES_USER=mmuser - # - POSTGRES_PASSWORD=mmuser_password - # # - POSTGRES_DB=mattermost - # - LISTEN_ADDRESS="*" - # image: postgres:13-alpine - # restart: unless-stopped - # ports: - # - "5434:5432" - # security_opt: - # - no-new-privileges:true - # pids_limit: 100 - # read_only: false - # tmpfs: - # - /tmp - # - /var/run/postgresql - # volumes: - # # - ./volumes/db-replica2/var/lib/postgresql/data:/var/lib/postgresql/data - # - ./volumes/db-replica2/data2:/var/lib/postgresql/data \ No newline at end of file + # - ./volumes/db/mysql:/var/lib/mysql \ No newline at end of file diff --git a/files/postgres/primary/init.sh b/files/postgres/primary/init.sh new file mode 100755 index 0000000..e4906df --- /dev/null +++ b/files/postgres/primary/init.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "include '/files/postgres/primary/primary_config.conf'" >> /var/lib/postgresql/data/postgresql.conf \ No newline at end of file diff --git a/files/postgres/primary/primary_config.conf b/files/postgres/primary/primary_config.conf new file mode 100644 index 0000000..157ed14 --- /dev/null +++ b/files/postgres/primary/primary_config.conf @@ -0,0 +1,25 @@ +# This value should match the "SqlSettings.MaxConnections" value within your config.json for Mattermost +# This is a suggestion and can be set lower / higher based on the size of your server. +max_connections = 1020 +tcp_keepalives_idle = 5 +tcp_keepalives_interval = 1 +tcp_keepalives_count = 5 + +# Set both of the below settings to 65% of total memory. For a 32 GB instance, it should be 21 GB. +# If on a smaller server, set this to 20% or less total RAM. +# ex: 512MB would work for a 4GB RAM server +shared_buffers = 512MB +effective_cache_size = 512MB + +# Set it to 16 MB for readers and 32 MB for writers. If it's a single instance, 16 MB should be sufficient. If the instance is of a lower capacity than r5.xlarge, then set it to a lower number. +work_mem = 16MB + +# 1GB (reduce this to 512MB if your server has less than 32GB of RAM) +autovacuum_work_mem = 512MB +autovacuum_max_workers = 4 +autovacuum_vacuum_cost_limit = 500 + +#Set it to 1.1 unless the DB is using spinning disks. +random_page_cost = 1.1 + +restart_after_crash = on \ No newline at end of file