Skip to content
Download all

On suta-linux-lab-1, as student:

suta-linux-lab-1 - as student
# 1a. Is the service running now?
systemctl is-active postgresql-18

Expected output:

active
suta-linux-lab-1 - as student
# 1b. Will it start at boot?
systemctl is-enabled postgresql-18

Expected output:

enabled
  • is-active and is-enabled print one word each, so they are quicker to read than status.
suta-linux-lab-1 - as student
# 2. Is the server accepting connections?
/usr/pgsql-18/bin/pg_isready
  • pg_isready asks the server "can you accept a connection?" without logging in.

Expected output:

/run/postgresql:5432 - accepting connections
suta-linux-lab-1 - as student
# Switch to the postgres user (type exit to come back)
sudo su - postgres

The next two checks are SQL, run with psql -c as in 5.2. Now as postgres on suta-linux-lab-1:

suta-linux-lab-1 - as postgres
# 3. Which exact version is running?
psql -c 'SELECT version();'

Expected output:

version
-----------------------------------------------------------------------------------------------------------
PostgreSQL 18.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-17), 64-bit
(1 row)
suta-linux-lab-1 - as postgres
# 4. Are data checksums on? (new default in 18)
psql -c 'SHOW data_checksums;'

Expected output:

data_checksums
----------------
on
(1 row)
suta-linux-lab-1 - as postgres
# Return to the student user
exit

Every message below was produced on a real CentOS Stream 9 server with PostgreSQL 18.7.

# You see Cause Fix
1 Failed to download metadata for repo 'pgdg-common' CentOS Stream has no minor version for the PGDG repo address Do the CentOS Stream step in 4.1
2 initdb: error: cannot be run as root You ran initdb as root Use the setup script, or run initdb as postgres
3 initdb: error: directory "/var/lib/pgsql/18/data" exists but is not empty The cluster already exists Nothing to do. Never empty this folder on a real server
4 Job for postgresql-18.service failed A typo in postgresql.conf Run sudo journalctl -u postgresql-18 --no-pager -n 20 (-n 20 shows the last 20 lines), read the LOG: line, fix that setting
5 FATAL: role "student" does not exist psql used your Linux name as the role sudo su - postgres first, or psql -U with a real role
6 Connection refused, No route to host, timed out or no pg_hba.conf entry One of the remote gates is closed Use the diagram in 7.2: refused = service or listen_addresses, no route = firewalld, timed out = AWS security group, no entry = pg_hba.conf

Error 4 in real life. A setting was typed with the letter O instead of zero (1OO):

LOG: invalid value for parameter "max_connections": "1OO"
FATAL: configuration file "/var/lib/pgsql/18/data/postgresql.conf" contains errors

The LOG: line names the exact setting. Read it before changing anything else.

Was this page helpful?

Thanks. Glad it helped.

Thanks for telling us. Email the instructor what was missing, or ask in class.