You have just provisioned an Oracle Linux 8.10 server and need to install PostgreSQL 16. The process differs significantly from MySQL, and a single misconfiguration can negatively impact performance, security, or data integrity.
PostgreSQL 16 introduces substantial improvements, including enhanced query performance, better JSON support, improved parallel processing, and stronger security features. Oracle Linux 8.10 provides the stable, enterprise-grade foundation that PostgreSQL requires. Together, they form a powerful combination for mission-critical applications.
This guide walks you through installing PostgreSQL 16 on Oracle Linux 8.10 step by step, starting with repository configuration and package installation, then moving through initial setup, user management, performance optimization, and verification. Whether you are building a development environment, a data warehouse, or a production application server, this approach removes guesswork and helps you complete the installation in under thirty minutes.
By the end of this guide, you will have a fully functional and secure PostgreSQL 16 installation ready for your applications, with proper permissions, optimized configuration, and persistent settings.
Table of Contents
- Pre-requisites and System Requirements
- Understanding PostgreSQL 16 vs Earlier Versions
- Install PostgreSQL Repository
- Install PostgreSQL 16 Server
- Initial Configuration and Security
- Create Databases and Users
- Performance Tuning Essentials
- Verification and Testing
- Common Installation Issues
- Next Steps
Pre-requisites and System Requirements
Before you begin, ensure that your Oracle Linux 8.10 server meets the following requirements.
System Requirements
- Oracle Linux 8.10 (fully updated)
- Minimum of 2 CPU cores and 4 gigabytes of memory (8 gigabytes or more recommended for production)
- At least 20 gigabytes of free disk space (100 gigabytes or more for production data)
- Root or sudo access
- Internet connectivity for package downloads
Software Requirements
- curl or wget (usually pre-installed)
- A text editor such as nano, vim, or vi
- Basic knowledge of Linux commands
- Understanding of PostgreSQL fundamentals (optional but helpful)
Pre-installation Steps
# Update your system
sudo dnf update -y
# Verify Oracle Linux version
cat /etc/os-release
# Verify internet connectivity
ping -c 4 8.8.8.8
The expected output for the version check should display Oracle Linux Server 8.10.
For foundational Oracle Linux 8.10 setup instructions, see our Complete Guide to Installing and Configuring Oracle Linux 8.10.
Understanding PostgreSQL 16 vs Earlier Versions
PostgreSQL 16 introduces significant improvements compared to PostgreSQL 15 and earlier releases. Understanding these differences helps you appreciate the upgrade and configure the database appropriately for your workload.
Key improvements in PostgreSQL 16 include:
- Performance: More than forty percent faster query execution in certain workloads
- JSON Enhancements: Improved JSON path support and additional operators
- Parallel Processing: Better parallel query execution and more efficient execution plans
- Logical Replication: Enhancements that improve replication reliability and failover handling
- Security: Stronger authentication mechanisms and improved role management
- Developer Experience: Clearer error messages and improved command-line interface tools
On Oracle Linux 8.10 specifically, PostgreSQL 16 offers full compatibility with the operating system kernel and system libraries. This ensures stability and optimal performance for production workloads.
Install PostgreSQL Repository
PostgreSQL 16 is distributed through the official PostgreSQL community repository. Installing this repository ensures access to the latest stable releases, bug fixes, and security updates.
Step 1: Install the PostgreSQL Repository Package
# PostgreSQL provides a repository configuration package
# For Oracle Linux 8, use the following command:
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Verify repository installation
sudo dnf repolist | grep postgres
The expected output should display the pgdg16 repository.
Step 2: Verify Repository Configuration
# Display all PostgreSQL-related repositories
sudo dnf repolist all | grep postgres
You should see the pgdg16 repository listed as available.
Step 3: Enable the PostgreSQL 16 Repository (If Required)
# Check whether the PostgreSQL 16 repository is enabled
sudo dnf repolist enabled | grep pgdg16
# If it is not enabled, enable it manually
sudo dnf config-manager --enable pgdg16-updates
# Verify that the repository is now enabled
sudo dnf repolist enabled | grep pgdg16
The PostgreSQL repository is now fully configured and ready for server installation.
Install PostgreSQL 16 Server
With the repository configured, installing PostgreSQL 16 is a straightforward process.
Step 1: Install the PostgreSQL Server Package
# Install PostgreSQL 16 server and contributed extension packages
sudo dnf install -y postgresql16-server postgresql16-contrib
# Verify the installation
psql --version
The expected output should display:
psql (PostgreSQL) 16.x
Step 2: Initialize the PostgreSQL Database Cluster
Unlike MySQL, PostgreSQL requires explicit initialization of the database data directory before the service can be started.
# Initialize the PostgreSQL database cluster
sudo /usr/pgsql-16/bin/postgresql-16-setup initdb
# Expected output examples:
# Initializing database ... initdb: directory "/var/lib/pgsql/16/data" already exists but is not empty
# or
# Initializing database ... ok
Step 3: Start the PostgreSQL Service
# Enable PostgreSQL to start automatically at system boot
sudo systemctl enable postgresql-16
# Start the PostgreSQL service
sudo systemctl start postgresql-16
# Verify that the service is running
sudo systemctl status postgresql-16
The service status should show active (running).
Initial Configuration and Security
PostgreSQL 16 ships with secure default settings. However, initial configuration is necessary to ensure the database is correctly tuned and secured for your environment.
Step 1: Verify That PostgreSQL Is Running
# Connect to PostgreSQL using the postgres system user
sudo -u postgres psql
Inside the PostgreSQL prompt, run the following commands:
-- Display PostgreSQL version information
SELECT version();
-- Display the current connected user
SELECT current_user;
-- List all available databases
\l
-- Exit the PostgreSQL prompt
\q
The output should confirm that PostgreSQL version 16.x is running.
Step 2: Set the PostgreSQL Superuser Password
# Reconnect to PostgreSQL as the postgres user
sudo -u postgres psql
Inside the PostgreSQL prompt:
-- Set a password for the postgres superuser account
ALTER USER postgres WITH PASSWORD 'StrongPasswordHere123!@#';
-- Verify user roles and privileges
\du
-- Exit the PostgreSQL prompt
\q
Step 3: Configure Connection and Performance Settings
# Edit the PostgreSQL main configuration file
sudo nano /var/lib/pgsql/16/data/postgresql.conf
Locate and modify the following configuration parameters:
# Network configuration
listen_addresses = 'localhost' # Change to '*' only when remote access is required
port = 5432
# Connection limits
max_connections = 200
# Memory configuration
shared_buffers = 256MB # Approximately twenty-five percent of system memory for dedicated servers
work_mem = 4MB # Memory allocated per operation
# Logging configuration
logging_collector = on
log_directory = 'log'
log_filename = 'postgresql-%a.log'
log_rotation_age = 1d
Step 4: Restart PostgreSQL to Apply Configuration Changes
# Restart PostgreSQL to apply the new configuration
sudo systemctl restart postgresql-16
# Verify that the service is running correctly
sudo systemctl status postgresql-16
# Review recent log entries for errors
sudo tail -20 /var/lib/pgsql/16/data/log/postgresql-*.log
Create Databases and Users
For security best practices, applications should never run using the PostgreSQL superuser account (postgres). Instead, create dedicated database roles with only the permissions required by the application.
Step 1: Create a New Database
# Connect to PostgreSQL as the postgres system user
sudo -u postgres psql
Inside the PostgreSQL prompt:
-- Create a new database with defined encoding and locale
CREATE DATABASE myapp_db
WITH OWNER postgres
ENCODING 'UTF8'
LC_COLLATE 'en_US.UTF-8'
LC_CTYPE 'en_US.UTF-8';
-- Verify database creation
\l
-- Exit the PostgreSQL prompt
\q
Step 2: Create a Database Role (User)
# Connect to PostgreSQL as the postgres system user
sudo -u postgres psql
Inside the PostgreSQL prompt:
-- Create a new role with login privileges
CREATE ROLE appuser WITH
LOGIN
ENCRYPTED PASSWORD 'StrongPasswordHere123!@#'
VALID UNTIL 'infinity';
-- Grant permission to connect to the database
GRANT CONNECT ON DATABASE myapp_db TO appuser;
-- Grant usage rights on the public schema
GRANT USAGE ON SCHEMA public TO appuser;
-- Allow the role to create objects in the schema
GRANT CREATE ON SCHEMA public TO appuser;
-- Verify role creation and privileges
\du
-- Exit the PostgreSQL prompt
\q
Step 3: Grant Database Object Permissions
# Connect directly to the target database
sudo -u postgres psql myapp_db
Inside the PostgreSQL prompt while connected to myapp_db:
-- Grant full privileges on all existing tables
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO appuser;
-- Grant full privileges on all existing sequences
-- Required for auto-incrementing columns
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO appuser;
-- Grant full privileges on all existing functions
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public TO appuser;
-- Set default privileges for future objects created in the schema
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT ALL ON TABLES TO appuser;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT ALL ON SEQUENCES TO appuser;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT ALL ON FUNCTIONS TO appuser;
-- Verify granted privileges
\dp
-- Exit the PostgreSQL prompt
\q
Step 4: Test the New Application User
# Connect to PostgreSQL using the new role
psql -U appuser -d myapp_db -h localhost
# Enter the password when prompted
Inside the PostgreSQL prompt:
-- Verify the connected user and database
SELECT current_user, current_database();
-- Expected result:
-- appuser | myapp_db
-- Exit the PostgreSQL prompt
\q
Performance Tuning Essentials
The default PostgreSQL configuration is suitable for development environments, but production workloads require tuning. The following essential parameters significantly improve performance, stability, and observability.
Step 1: Edit the PostgreSQL Configuration File
# Open the main PostgreSQL configuration file
sudo nano /var/lib/pgsql/16/data/postgresql.conf
Step 2: Add Performance Tuning Parameters
Locate or add the following parameters. The values below assume an eight gigabyte system with PostgreSQL running as a dedicated service.
# Memory settings (based on system Random Access Memory)
# For an 8 GB system: allocate 2 GB for shared_buffers (25 percent of total memory)
shared_buffers = 2GB
# Work memory per operation
# Calculation: 8 GB ÷ 200 max connections ÷ 2 ≈ 20 MB per operation
work_mem = 20MB
# Memory for maintenance operations such as CREATE INDEX and VACUUM
maintenance_work_mem = 512MB
# Connection limits
max_connections = 200
max_prepared_transactions = 100
# Query planning and caching
effective_cache_size = 6GB # Approximately 75 percent of available memory
random_page_cost = 1.1 # Lower value recommended for solid-state drives
# Write-Ahead Logging configuration (used for replication and backups)
wal_level = replica
max_wal_senders = 10
max_replication_slots = 10
wal_keep_size = 1GB
# Logging for slow query analysis
log_min_duration_statement = 1000 # Log queries slower than one second
log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
# Automatic vacuum settings
autovacuum = on
autovacuum_naptime = 10s
Step 3: Restart PostgreSQL to Apply Changes
# Restart the PostgreSQL service
sudo systemctl restart postgresql-16
# Verify the service status
sudo systemctl status postgresql-16
# Review the error log for configuration issues
sudo tail -30 /var/lib/pgsql/16/data/log/postgresql-*.log
Step 4: Verify the Configuration Inside PostgreSQL
# Connect to PostgreSQL as the postgres system user
sudo -u postgres psql
Inside the PostgreSQL prompt:
-- Verify applied configuration values
SHOW shared_buffers;
SHOW work_mem;
SHOW max_connections;
SHOW effective_cache_size;
-- Exit the PostgreSQL prompt
\q
Verification and Testing
Before declaring the installation complete, verify service availability, performance configuration, and basic database functionality.
Step 1: Check PostgreSQL Service Status
# Verify PostgreSQL service status
sudo systemctl status postgresql-16
# Check if PostgreSQL is listening on port 5432
sudo netstat -tlnp | grep 5432
# Alternative modern command
sudo ss -tlnp | grep 5432
Expected output confirms PostgreSQL is listening on 127.0.0.1:5432 or [::]:5432.
Step 2: Run Performance Diagnostics
# Connect to PostgreSQL
sudo -u postgres psql
Inside the PostgreSQL prompt:
-- Review memory and connection configuration
SHOW shared_buffers;
SHOW work_mem;
SHOW max_connections;
-- Check active connections
SELECT count(*) AS connection_count
FROM pg_stat_activity;
-- Display database sizes
SELECT
datname,
pg_size_pretty(pg_database_size(datname)) AS size
FROM pg_database
ORDER BY pg_database_size(datname) DESC;
-- Display largest tables
SELECT
schemaname,
tablename,
pg_size_pretty(
pg_total_relation_size(schemaname || || tablename)
) AS size
FROM pg_tables
WHERE schemaname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_total_relation_size(schemaname || || tablename) DESC;
-- Exit the PostgreSQL prompt
\q
Step 3: Create and Test Sample Data
# Connect using the application role
psql -U appuser -d myapp_db -h localhost
Inside the PostgreSQL prompt:
-- Create a test table
-- SERIAL is an auto-incrementing integer column
CREATE TABLE test_table (
id SERIAL PRIMARY KEY,
name VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Insert sample rows
INSERT INTO test_table (name) VALUES ('Test Entry 1');
INSERT INTO test_table (name) VALUES ('Test Entry 2');
-- Query inserted data
SELECT * FROM test_table;
-- Check table size
SELECT pg_size_pretty(pg_total_relation_size('test_table'));
-- Remove the test table
DROP TABLE test_table;
-- Exit the PostgreSQL prompt
\q
Common Installation Issues
Even when following instructions carefully, issues can arise. The following are the most common problems with PostgreSQL 16 installations on Oracle Linux 8.10 and recommended solutions.
Issue 1: PostgreSQL Service Does Not Start
# Check the PostgreSQL error log
sudo tail -50 /var/lib/pgsql/16/data/log/postgresql-*.log
# Common cause: permission issues
sudo chown -R postgres:postgres /var/lib/pgsql/16/data
sudo chmod -R 700 /var/lib/pgsql/16/data
# Restart the PostgreSQL service
sudo systemctl restart postgresql-16
Issue 2: Cannot Connect to PostgreSQL
# Verify PostgreSQL is listening on port 5432
sudo netstat -tlnp | grep 5432
# Review connection permissions
sudo nano /var/lib/pgsql/16/data/pg_hba.conf
# Ensure the following lines exist for local connections:
# TYPE DATABASE USER ADDRESS METHOD
# local all all trust
# host all all 127.0.0.1/32 md5
# Restart PostgreSQL after changes
sudo systemctl restart postgresql-16
Issue 3: Password Authentication Fails
# Reset the postgres superuser password
sudo -u postgres psql
# Inside PostgreSQL:
ALTER USER postgres WITH PASSWORD 'NewPassword123!@#';
# Verify authentication method in pg_hba.conf
sudo nano /var/lib/pgsql/16/data/pg_hba.conf
# Use 'md5' or 'scram-sha-256' for password authentication
# Restart service
sudo systemctl restart postgresql-16
Issue 4: Out of Memory or Slow Queries
# Check current memory allocation
sudo -u postgres psql -c "SHOW shared_buffers;"
# Verify available system memory
free -h
# Adjust shared_buffers (recommended: 25 percent of system RAM)
sudo nano /var/lib/pgsql/16/data/postgresql.conf
# Restart PostgreSQL to apply changes
sudo systemctl restart postgresql-16
Issue 5: High Disk Usage
# Check database sizes
sudo -u postgres psql -c "SELECT datname, pg_size_pretty(pg_database_size(datname)) FROM pg_database ORDER BY pg_database_size(datname) DESC;"
# Reclaim space with VACUUM
sudo -u postgres psql -d myapp_db -c "VACUUM ANALYZE;"
# Check for large temporary files
sudo du -sh /var/lib/pgsql/16/data/base/*/
# Enable autovacuum if disabled
# Edit postgresql.conf: autovacuum = on
Issue 6: initdb Fails
# Ensure the data directory is empty
sudo rm -rf /var/lib/pgsql/16/data/*
# Retry initialization
sudo /usr/pgsql-16/bin/postgresql-16-setup initdb
# Correct permissions if needed
sudo chown -R postgres:postgres /var/lib/pgsql/16/data
sudo chmod -R 700 /var/lib/pgsql/16/data
When Not to Use This Approach
This guide covers standard single-server installations. For advanced scenarios, consult dedicated documentation:
- PostgreSQL Replication: Master-slave or streaming replication for high availability. See PostgreSQL Replication Setup on Oracle Linux 8.10
- PostgreSQL Clustering: Multiple nodes with automatic failover. See PostgreSQL High Availability Cluster with Patroni on Oracle Linux
- Containerized Deployment: Docker or Kubernetes deployments require different configuration. See PostgreSQL on Docker
- Cloud Deployment: Amazon Web Services RDS, Microsoft Azure Database, or Google Cloud SQL require provider-specific instructions
Next Steps
Your PostgreSQL 16 installation is now complete and secure. Recommended immediate actions:
- Backup Configuration: Keep copies of
/var/lib/pgsql/16/data/postgresql.confandpg_hba.conf - Enable Automatic Backups: Use
pg_dumpor Write-Ahead Log (WAL) based backups - Monitor Performance: Check slow query logs regularly and adjust
work_memaccording to workload
Related topics for further learning:
- Complete Guide to Upgrade Oracle Linux 7.9 to 8.10 Using LEAPP - Foundational system setup
- Install MySQL 8.4 on Oracle Linux 8.10 - Compare database options
- PostgreSQL Replication Setup on Oracle Linux 8.10 - Scale your database
- Disk Formatting, Partitioning, and Mounting on Oracle Linux 8.10 - Prepare storage for PostgreSQL data
External resources:
- Official PostgreSQL 16 Documentation - Comprehensive reference
- PostgreSQL Wiki - Community knowledge base
- PostgreSQL Performance Tuning Guide - Advanced optimization
- Oracle Linux 8 Documentation - System administration
Conclusion
You have successfully installed PostgreSQL 16 on Oracle Linux 8.10, creating a powerful foundation for data-intensive applications. By following this guide, you have:
- Installed PostgreSQL 16 from the official repository
- Initialized the database cluster correctly
- Configured secure initial settings
- Created dedicated database roles with appropriate permissions
- Applied performance tuning parameters for production workloads
- Verified that the installation works as expected
PostgreSQL 16 on Oracle Linux 8.10 provides excellent reliability, advanced features, and performance for production environments. Your configuration establishes a stable foundation capable of supporting complex applications and future scaling.
Next critical step: Implement automated backups and monitoring. A working database is only valuable when data is protected.
Monitor your slow query logs, adjust work_mem according to actual workload requirements, and keep the system updated. Your PostgreSQL installation is now ready for your applications—deploy with confidence.
Call-to-Action
Need assistance with your PostgreSQL 16 installation or advanced database configurations? Reach out to our professional database services team via our contact page. We provide expert support for Oracle Linux and PostgreSQL environments to ensure optimal performance and security.