Repository navigation
middleware_postgresql
Andrea Paolini edited this page Jan 2, 2021
·
1 revision
Parameters for using XA, in testing environment. In postgresql.conf:
listen_addresses = '*'
max_connections = 100
shared_buffers = 512MB
effective_cache_size = 1024MB
max_prepared_transactions = 100
Example: migrate from 9.2 to 9.3:
- Install new version of Postgres
- Init the new DB:
/etc/init.d/postgresql-9.3 initdb - Customize pg_hba.conf and postgresql.conf
- Stop old DB:
service postgresql-9.2 stop - Start new DB:
service postgresql-9.3 start - Run migration script:
/usr/pgsql-9.3/bin/pg_upgrade -v \
-b /usr/pgsql-9.2/bin/ -B /usr/pgsql-9.3/bin/ \
-d /var/lib/pgsql/9.2/data/ -D /var/lib/pgsql/9.3/data/
-
Runstat the new db:
./analyze_new_cluster.sh - Test and remove old data:
./delete_old_cluster.sh
REASSIGN OWNED BY old_role TO new_role
If all objects are in public:
DROP SCHEMA public CASCADE;
CREATE SCHEMA public AUTHORIZATION postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO public;
COMMENT ON SCHEMA public IS 'standard public schema'; export PGHOST=psql.example.com
export PGDATABASE=mydatabase
export PGUSER=myuser
export PGPASSWORD=itsasecret
SCRIPT=ilmioscript.sql
psql -v ON_ERROR_STOP=Yes -1 -w -a -f ${SCRIPT} $PGDATABASE > ${SCRIPT}.log 2>&1 && echo OK || echo ERROR- Put in
postgresql.conf:
shared_preload_libraries = 'pg_stat_statements'
- Restart postgres
- Enable the extension:
CREATE EXTENSION pg_stat_statements;
SELECT * FROM pg_stat_statements ORDER BY total_time DESC;See: https://www.cybertec-postgresql.com/en/detecting-performance-problems-easily-in-postgresql
Work in progress...