在线安装
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo dnf install -y postgresql18-server
sudo /usr/pgsql-18/bin/postgresql-18-setup initdb
sudo systemctl enable postgresql-18
sudo systemctl start postgresql-18
sudo systemctl status postgresql-18
安装日志
root@rockylinux \~# sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Last metadata expiration check: 2:26:52 ago on Wed 17 Jun 2026 04:02:12 AM CST.
pgdg-redhat-repo-latest.noarch.rpm 28 kB/s | 13 kB 00:00
Dependencies resolved.
==========================================================================================================================================================================================
Package Architecture Version Repository Size
==========================================================================================================================================================================================
Installing:
pgdg-redhat-repo noarch 42.0-64.rhel9PGDG @commandline 13 k
Transaction Summary
==========================================================================================================================================================================================
Install 1 Package
Total size: 13 k
Installed size: 16 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : pgdg-redhat-repo-42.0-64.rhel9PGDG.noarch 1/1
Verifying : pgdg-redhat-repo-42.0-64.rhel9PGDG.noarch 1/1
Installed:
pgdg-redhat-repo-42.0-64.rhel9PGDG.noarch
Complete!
root@rockylinux \~# sudo dnf install -y postgresql18-server
PostgreSQL common RPMs for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 608 B/s | 659 B 00:01
PostgreSQL common RPMs for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 2.4 MB/s | 2.4 kB 00:00
Importing GPG key 0x08B40D20:
Userid : "PostgreSQL RPM Repository "
Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
PostgreSQL common RPMs for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 112 kB/s | 195 kB 00:01
PostgreSQL 18 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 822 B/s | 659 B 00:00
PostgreSQL 18 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 2.4 MB/s | 2.4 kB 00:00
Importing GPG key 0x08B40D20:
Userid : "PostgreSQL RPM Repository "
Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
PostgreSQL 18 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 97 kB/s | 161 kB 00:01
PostgreSQL 17 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 652 B/s | 659 B 00:01
PostgreSQL 17 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 2.4 MB/s | 2.4 kB 00:00
Importing GPG key 0x08B40D20:
Userid : "PostgreSQL RPM Repository "
Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
PostgreSQL 17 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 97 kB/s | 183 kB 00:01
PostgreSQL 16 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 633 B/s | 659 B 00:01
PostgreSQL 16 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 2.4 MB/s | 2.4 kB 00:00
Importing GPG key 0x08B40D20:
Userid : "PostgreSQL RPM Repository "
Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
PostgreSQL 16 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 101 kB/s | 182 kB 00:01
PostgreSQL 15 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 829 B/s | 659 B 00:00
PostgreSQL 15 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 2.4 MB/s | 2.4 kB 00:00
Importing GPG key 0x08B40D20:
Userid : "PostgreSQL RPM Repository "
Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
PostgreSQL 15 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 126 kB/s | 181 kB 00:01
PostgreSQL 14 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 682 B/s | 659 B 00:00
PostgreSQL 14 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 2.4 MB/s | 2.4 kB 00:00
Importing GPG key 0x08B40D20:
Userid : "PostgreSQL RPM Repository "
Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
PostgreSQL 14 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 94 kB/s | 176 kB 00:01
Dependencies resolved.
==========================================================================================================================================================================================
Package Architecture Version Repository Size
==========================================================================================================================================================================================
Installing:
postgresql18-server x86_64 18.4-2PGDG.rhel9.8 pgdg18 7.2 M
Installing dependencies:
postgresql18 x86_64 18.4-2PGDG.rhel9.8 pgdg18 2.0 M
postgresql18-libs x86_64 18.4-2PGDG.rhel9.8 pgdg18 301 k
Transaction Summary
==========================================================================================================================================================================================
Install 3 Packages
Total download size: 9.4 M
Installed size: 43 M
Downloading Packages:
(1/3): postgresql18-libs-18.4-2PGDG.rhel9.8.x86_64.rpm 389 kB/s | 301 kB 00:00
(2/3): postgresql18-18.4-2PGDG.rhel9.8.x86_64.rpm 129 kB/s | 2.0 MB 00:15
(3/3): postgresql18-server-18.4-2PGDG.rhel9.8.x86_64.rpm 78 kB/s | 7.2 MB 01:34
Total 102 kB/s | 9.4 MB 01:34
PostgreSQL 18 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 2.4 MB/s | 2.4 kB 00:00
Importing GPG key 0x08B40D20:
Userid : "PostgreSQL RPM Repository "
Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : postgresql18-libs-18.4-2PGDG.rhel9.8.x86_64 1/3
Running scriptlet: postgresql18-libs-18.4-2PGDG.rhel9.8.x86_64 1/3
Installing : postgresql18-18.4-2PGDG.rhel9.8.x86_64 2/3
Running scriptlet: postgresql18-18.4-2PGDG.rhel9.8.x86_64 2/3
Running scriptlet: postgresql18-server-18.4-2PGDG.rhel9.8.x86_64 3/3
Creating group 'postgres' with GID 26.
Creating user 'postgres' (PostgreSQL Server) with UID 26 and GID 26.
Installing : postgresql18-server-18.4-2PGDG.rhel9.8.x86_64 3/3
Running scriptlet: postgresql18-server-18.4-2PGDG.rhel9.8.x86_64 3/3
Verifying : postgresql18-18.4-2PGDG.rhel9.8.x86_64 1/3
Verifying : postgresql18-libs-18.4-2PGDG.rhel9.8.x86_64 2/3
Verifying : postgresql18-server-18.4-2PGDG.rhel9.8.x86_64 3/3
Installed:
postgresql18-18.4-2PGDG.rhel9.8.x86_64 postgresql18-libs-18.4-2PGDG.rhel9.8.x86_64 postgresql18-server-18.4-2PGDG.rhel9.8.x86_64
Complete!
root@rockylinux \~# sudo /usr/pgsql-18/bin/postgresql-18-setup initdb
Initializing database ... OK
root@rockylinux \~# sudo systemctl enable postgresql-18
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-18.service → /usr/lib/systemd/system/postgresql-18.service.
root@rockylinux \~# sudo systemctl start postgresql-18
root@rockylinux \~# sudo systemctl status postgresql-18
● postgresql-18.service - PostgreSQL 18 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-18.service; enabled; preset: disabled)
Active: active (running) since Wed 2026-06-17 06:31:59 CST; 7s ago
Docs: https://www.postgresql.org/docs/18/static/
Process: 1240487 ExecStartPre=/usr/pgsql-18/bin/postgresql-18-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 1240492 (postgres)
Tasks: 10 (limit: 23564)
Memory: 21.8M
CPU: 48ms
CGroup: /system.slice/postgresql-18.service
├─1240492 /usr/pgsql-18/bin/postgres -D /var/lib/pgsql/18/data/
├─1240493 "postgres: logger "
├─1240494 "postgres: io worker 0"
├─1240495 "postgres: io worker 1"
├─1240496 "postgres: io worker 2"
├─1240497 "postgres: checkpointer "
├─1240498 "postgres: background writer "
├─1240500 "postgres: walwriter "
├─1240501 "postgres: autovacuum launcher "
└─1240502 "postgres: logical replication launcher "
Jun 17 06:31:59 rockylinux systemd1: Starting PostgreSQL 18 database server...
Jun 17 06:31:59 rockylinux postgres1240492: 2026-06-17 06:31:59.797 CST 1240492 LOG: redirecting log output to logging collector process
Jun 17 06:31:59 rockylinux postgres1240492: 2026-06-17 06:31:59.797 CST 1240492 HINT: Future log output will appear in directory "log".
Jun 17 06:31:59 rockylinux systemd1: Started PostgreSQL 18 database server.
root@rockylinux \~# ps -ef | grep postgres
postgres 1240492 1 0 06:31 ? 00:00:00 /usr/pgsql-18/bin/postgres -D /var/lib/pgsql/18/data/
postgres 1240493 1240492 0 06:31 ? 00:00:00 postgres: logger
postgres 1240494 1240492 0 06:31 ? 00:00:00 postgres: io worker 0
postgres 1240495 1240492 0 06:31 ? 00:00:00 postgres: io worker 1
postgres 1240496 1240492 0 06:31 ? 00:00:00 postgres: io worker 2
postgres 1240497 1240492 0 06:31 ? 00:00:00 postgres: checkpointer
postgres 1240498 1240492 0 06:31 ? 00:00:00 postgres: background writer
postgres 1240500 1240492 0 06:31 ? 00:00:00 postgres: walwriter
postgres 1240501 1240492 0 06:31 ? 00:00:00 postgres: autovacuum launcher
postgres 1240502 1240492 0 06:31 ? 00:00:00 postgres: logical replication launcher
root 1240733 1239206 0 06:32 pts/0 00:00:00 grep --color=auto postgres
root@rockylinux \~#