How to add extension pg_stat extension to postgres bitnami helm chart? - postgresql

I have following Chart.yaml
dependencies:
- name: postgresql
version: 11.6.7
repository: "#bitnami"
condition: postgresql.enabled
values.yaml:
postgresql:
auth:
database: ...
password: ...
postgresPassword: ...
metrics:
...
enabled: true
serviceMonitor:
enabled: true
...
primary:
initdb:
scriptsConfigMap: "postgres-init-scripts-config"
And inside the config I have following:
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
I start my appplication and then I try to run following query:
I hasn't found answer here also: https://github.com/bitnami/charts/issues/2067
select * from pg_stat_statements;
and restart is:
ERROR: pg_stat_statements must be loaded via shared_preload_libraries
SQL state: 55000
I have read this topic: pghero on PostgresApp pg_stat_statements must be loaded via shared_preload_libraries
And based on other topics from SO looks ike I need to restart postgres. But I don't know how can I acheve it.
Also this topic hasn't given me the answer how to enable extension properly in helm chart.
P.S. In my case I create database inside postgres-init-scripts-config and I need to have extension pg_stat_statements enabled for that database

I was able to fix after I've added:
postgresql
metrics
primary:
extendedConfiguration: |
shared_preload_libraries = 'pg_stat_statements' # (change requires restart)
pg_stat_statements.max = 10000
pg_stat_statements.track = all

Related

What is correct dbt profiles for postgresql?

I have a dbt_project like below.
name: 'DataTransformer'
version: '1.0.0'
config-version: 2
profile: 'DataTransformer'
Using Postgres, hence I have a profile at .dbt/profiles.yml
DataTransformer:
target: dev
outputs:
dev:
type: postgres
host: localhost
port: 55000
user: postgres
pass: postgrespw
dbname: postgres
schema: public
threads: 4
But when I run dbt debug, I got Credentials in profile "DataTransformer", target "dev" invalid: ['dbname'] is not of type 'string'
I have searched, there are several people has encountered the same error but in different databases. Still not sure why happens in my case

Error creating a connection to Postgresql while preparing konga database

After installing Konga, we are trying to prepare Konga database on the already running Postgresql database. by using suggested command i.e.
node ./bin/konga.js prepare --adapter postgres --uri postgresql://localhost:5432/konga
But we are facing the error as below:
Error creating a connection to Postgresql using the following settings:
postgresql://localhost:5432/konga?host=localhost&port=5432&schema=true&ssl=false&adapter=sails-postgresql&user=postgres&password=XXXX&database=konga_database&identity=postgres
* * *
Complete error details:
error: password authentication failed for user "root"
error: A hook (`orm`) failed to load!
error: Failed to prepare database: error: password authentication failed for user "root"
We even created the schema konga_database manually and have tried several variations for prepare command but no fate
node ./bin/konga.js prepare --adapter postgres --uri postgresql://kong:XXXX#localhost:5432/konga_database
node ./bin/konga.js prepare --adapter postgres --uri postgresql://kong#localhost:5432/konga
node ./bin/konga.js prepare --adapter postgres --uri postgresql://kong#localhost:5432/konga_database
Below is config/connections.js
postgres: {
adapter: 'sails-postgresql',
url: process.env.DB_URI,
host: process.env.DB_HOST || 'localhost',
user: process.env.DB_USER || 'postgres',
password: process.env.DB_PASSWORD || 'XXXX',
port: process.env.DB_PORT || 5432,
database: process.env.DB_DATABASE ||'konga_database',
// schema: process.env.DB_PG_SCHEMA ||'public',
// poolSize: process.env.DB_POOLSIZE || 10,
ssl: process.env.DB_SSL ? true : false // If set, assume it's true
},
Below is .env file configuration
PORT=1337
NODE_ENV=production
KONGA_HOOK_TIMEOUT=120000
DB_ADAPTER=postgres
DB_URI=postgresql://localhost:5432/konga
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=XXXX
KONGA_LOG_LEVEL=info
TOKEN_SECRET=
kong and postgresql are already running on the AWS linux AMI 2 server on there respective ports i.e. 8443 & 5432
Please help us to prepare DB and start konga service. Also. let us know in case you need more info.
Node v: v12.19.0
NPM v: 6.14.8
Regards
Nitin G
Maybe I overlooked it, but what version of PostreSQL are you using?
Konga is not able to support postgresql 12:
https://github.com/pantsel/konga/issues/487
Have you tried like this?
.env
DB_URI=postgresql://userdb:passworddb#localhost:5432/kongadb
I tried on Postgresql 9.6
https://www.rosehosting.com/blog/how-to-install-postgresql-9-6-on-ubuntu-20-04/

How to store mongo db backups to google drive using Symfony 3.4

I am trying to upload mongo db backup to google drive
I am installing following bundles dizda/cloud-backup-bundle and Happyr
/
GoogleSiteAuthenticatorBundle for adapters I am using cache/adapter-bundle
configuration:
dizda_cloud_backup:
output_file_prefix: '%dizda_hostname%'
timeout: 300
processor:
type: zip # Required: tar|zip|7z
options:
compression_ratio: 6
password: '%dizda_compressed_password%'
cloud_storages:
google_drive:
token_name: 'AIzaSyA4AE21Y-YqneV5f9POG7MPx4TF1LGmuO8' # Required
remote_path: ~ # Not required, default "/", but you can use path like "/Accounts/backups/"
databases:
mongodb:
all_databases: false # Only required when no database is set
database: '%database_name%'
db_host: '%mongodb_backup_host%'
db_port: '%mongodb_port%'
db_user: '%mongodb_user%'
db_password: '%mongodb_password%'
cache_adapter:
providers:
my_redis:
factory: 'cache.factory.redis'
happyr_google_site_authenticator:
cache_service: 'cache.provider.my_redis'
tokens:
google_drive:
client_id: '85418079755-28ncgsoo91p69bum6ulpt0mipfdocb07.apps.googleusercontent.com'
client_secret: 'qj0ipdwryCNpfbJQbd-mU2Mu'
redirect_url: 'http://localhost:8000/googledrive/'
scopes: ['https://www.googleapis.com/auth/drive']
when I use factory: 'cache.factory.mongodb' getting
You have requested a non-existent service "cache.factory.mongodb" this while running server and while running backup command getting
Something went terribly wrong. We could not create a backup. Read your log files to see what caused this error
I verified logs getting Command "--env=prod dizda:backup:start" exited with code "1" {"command":"--env=prod dizda:backup:start","code":1} []
I am not sure which adapter needs to use and what's going on here.
Can someone help me? Thanks in advance

ERROR could not access file "$libdir/repmgr_funcs" No such file or directory

I follow this link to create master slave replication on Ubuntu postgresql server.
My Configuration of repmgr and postgresql are:
Postgresql 9.5-: /opt/PostgreSQL/9.5/
repmgr-: /usr/lib/postgresql/9.5/bin/repmgr
repmgr.conf -: /etc/rep.conf
pg_config --pkglibdir => /usr/lib/postgresql/9.5/lib
ls /usr/lib/postgresql/9.5/lib | grep repmgr_funcs => repmgr_funcs.so
I am getting ERROR-: unable to create the function
repmgr_update_last_updated: ERROR: could not access file "$libdir/repmgr_funcs": No such file or directory
ERROR: Unable to create repmgr schema - see preceding error message(s); aborting
If you are using repmgr ver. 4 and above then you need to change in postgresql.conf
From shared_preload_libraries = 'repmgr_funcs'
To shared_preload_libraries = 'repmgr'
Below are their upgrade notes
The repmgr shared library has been renamed from repmgr_funcs to
repmgr, meaning shared_preload_libraries in postgresql.conf needs to
be updated to the new name: shared_preload_libraries = 'repmgr'

Connecting grails to postgresql

I am using Grails with IntelliJ studio. How can I set my application.yml file in order to connect to my postgres version 9.5.3 ?
First to create the database, use something similar to this sql:
CREATE USER my_user WITH PASSWORD 'my_secret_password';
CREATE DATABASE my_db;
GRANT ALL ON DATABASE my_db TO my_user;
Test the db connection with:
psql -h localhost -p 5432 -U my_user my_db -W
Then use something like this in your application.yml file:
environments:
production:
dataSource:
driverClassName: org.postgresql.Driver
dbCreate: update
username: my_user
password: my_secret_password
dialect: org.hibernate.dialect.PostgreSQLDialect
url: jdbc:postgresql://db:5432/my_db
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
Assuming your Postgres is running on localhost and standard port 5432.
Since the strategy is update, this will create all tables in the database for you. After that, you might wish to change update to validate, and use database migrations for your changes to the domain classes.
You probably wish to update the username, password and database name
Finally in the build.gradle file, you need to include the driver as a runtime dependency:
dependencies {
...
runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
...
}