Nainštalujte databázu PostgreSQL na Ubuntu 22.04 s optimalizáciou pre produkčné prostredie.
Set up PostgreSQL database server on Ubuntu 22.04 with optimal configuration for production use.
sudo apt update
sudo apt install postgresql postgresql-contrib -y
Configure PostgreSQL by editing /etc/postgresql/14/main/postgresql.conf:
max_connections = 200
shared_buffers = 256MB
effective_cache_size = 1GB
work_mem = 4MB
sudo -u postgres psql
CREATE DATABASE myapp;
CREATE USER myuser WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE myapp TO myuser;
Tune shared_buffers to 25% of RAM. Use connection pooling (pgBouncer) for high-traffic applications.
Use pg_dump for logical backups or pg_basebackup for physical backups. Consider setting up streaming replication.