Postgresql
$ sudo apt install postgresql
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
docker-scan-plugin libfwupdplugin1 libxmlb1 shim
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libllvm10 libpq5 postgresql-12 postgresql-client-12 postgresql-client-common postgresql-common ssl-cert sysstat
Suggested packages:
postgresql-doc postgresql-doc-12 libjson-perl openssl-blacklist isag
The following NEW packages will be installed:
libllvm10 libpq5 postgresql postgresql-12 postgresql-client-12 postgresql-client-common postgresql-common ssl-cert sysstat
0 upgraded, 9 newly installed, 0 to remove and 1 not upgraded.
Need to get 30.7 MB of archives.
After this operation, 122 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
.
.
.
(ommitted)
.
.
.
Success. You can now start the database server using:
pg_ctlcluster 12 main start
Ver Cluster Port Status Owner Data directory Log file
12 main 5432 down postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
update-alternatives: using /usr/share/postgresql/12/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
Setting up sysstat (12.2.0-2ubuntu0.3) ...
Creating config file /etc/default/sysstat with new version
update-alternatives: using /usr/bin/sar.sysstat to provide /usr/bin/sar (sar) in auto mode
Created symlink /etc/systemd/system/multi-user.target.wants/sysstat.service → /lib/systemd/system/sysstat.service.
Setting up postgresql (12+214ubuntu0.1) ...
Processing triggers for systemd (245.4-4ubuntu3.24) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.16) ...
$ sudo netstat -tulnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 1402/nginx: master
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 1128/smbd
tcp 0 0 127.0.0.1:9121 0.0.0.0:* LISTEN 1399/redis_exporter
tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN 1389/prometheus
tcp 0 0 127.0.0.1:9187 0.0.0.0:* LISTEN 1393/postgres_expor
tcp 0 0 127.0.0.1:9093 0.0.0.0:* LISTEN 1405/alertmanager
tcp 0 0 0.0.0.0:8008 0.0.0.0:* LISTEN 1402/nginx: master
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 1128/smbd
tcp 0 0 127.0.0.1:9100 0.0.0.0:* LISTEN 1398/node_exporter
tcp 0 0 127.0.0.1:9229 0.0.0.0:* LISTEN 1390/gitlab-workhor
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 1406/puma 5.1.1 (un
tcp 0 0 127.0.0.1:9168 0.0.0.0:* LISTEN 1401/ruby
tcp 0 0 127.0.0.1:8082 0.0.0.0:* LISTEN 1492/sidekiq 5.2.9
tcp 0 0 127.0.0.1:9236 0.0.0.0:* LISTEN 1439/gitaly
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 763/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1117/sshd: /usr/sbi
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 12461/postgres
tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN 1400/grafana-server
tcp6 0 0 :::445 :::* LISTEN 1128/smbd
tcp6 0 0 :::9094 :::* LISTEN 1405/alertmanager
tcp6 0 0 :::139 :::* LISTEN 1128/smbd
tcp6 0 0 :::22 :::* LISTEN 1117/sshd: /usr/sbi
udp 0 0 127.0.0.53:53 0.0.0.0:* 763/systemd-resolve
udp 0 0 192.168.1.29:68 0.0.0.0:* 761/systemd-network
udp 0 0 192.168.1.255:137 0.0.0.0:* 1078/nmbd
udp 0 0 192.168.1.29:137 0.0.0.0:* 1078/nmbd
udp 0 0 172.17.255.255:137 0.0.0.0:* 1078/nmbd
udp 0 0 172.17.0.1:137 0.0.0.0:* 1078/nmbd
udp 0 0 192.168.1.255:137 0.0.0.0:* 1078/nmbd
udp 0 0 192.168.1.101:137 0.0.0.0:* 1078/nmbd
udp 0 0 0.0.0.0:137 0.0.0.0:* 1078/nmbd
udp 0 0 192.168.1.255:138 0.0.0.0:* 1078/nmbd
udp 0 0 192.168.1.29:138 0.0.0.0:* 1078/nmbd
udp 0 0 172.17.255.255:138 0.0.0.0:* 1078/nmbd
udp 0 0 172.17.0.1:138 0.0.0.0:* 1078/nmbd
udp 0 0 192.168.1.255:138 0.0.0.0:* 1078/nmbd
udp 0 0 192.168.1.101:138 0.0.0.0:* 1078/nmbd
udp 0 0 0.0.0.0:138 0.0.0.0:* 1078/nmbd
udp6 0 0 fe80::72e2:4cff:fe6:546 :::* 761/systemd-network
udp6 0 0 :::9094 :::* 1405/alertmanager
$ pg_ctlcluster 12 main start
Warning: the cluster will not be running as a systemd service. Consider using systemctl:
sudo systemctl start postgresql@12-main
Error: You must run this program as the cluster owner (postgres) or root
$ sudo pg_ctlcluster 12 main start
$ sudo service --status-all
[ + ] apparmor
[ + ] apport
[ + ] atd
[ - ] console-setup.sh
[ + ] cron
[ - ] cryptdisks
[ - ] cryptdisks-early
[ + ] dbus
[ + ] docker
[ - ] grub-common
[ - ] hwclock.sh
[ + ] irqbalance
[ - ] iscsid
[ - ] keyboard-setup.sh
[ + ] kmod
[ + ] lm-sensors
[ - ] lvm2
[ - ] lvm2-lvmpolld
[ + ] network-manager
[ + ] nmbd
[ - ] open-iscsi
[ - ] open-vm-tools
[ - ] plymouth
[ - ] plymouth-log
[ + ] postgresql
[ - ] pppd-dns
[ + ] procps
[ - ] rsync
[ + ] rsyslog
[ - ] samba-ad-dc
[ - ] screen-cleanup
[ + ] smbd
[ + ] ssh
[ - ] sysstat
[ + ] udev
[ + ] ufw
[ + ] unattended-upgrades
[ - ] uuidd
$ sudo service postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Sun 2025-02-02 10:21:38 JST; 2min 6s ago
Main PID: 12153 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 9312)
Memory: 0B
CGroup: /system.slice/postgresql.service
Feb 02 10:21:38 mozuku systemd[1]: Starting PostgreSQL RDBMS...
Feb 02 10:21:38 mozuku systemd[1]: Finished PostgreSQL RDBMS.
$ sudo netstat -tulnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 1402/nginx: master
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 1128/smbd
tcp 0 0 127.0.0.1:9121 0.0.0.0:* LISTEN 1399/redis_exporter
tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN 1389/prometheus
tcp 0 0 127.0.0.1:9187 0.0.0.0:* LISTEN 1393/postgres_expor
tcp 0 0 127.0.0.1:9093 0.0.0.0:* LISTEN 1405/alertmanager
tcp 0 0 0.0.0.0:8008 0.0.0.0:* LISTEN 1402/nginx: master
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 1128/smbd
tcp 0 0 127.0.0.1:9100 0.0.0.0:* LISTEN 1398/node_exporter
tcp 0 0 127.0.0.1:9229 0.0.0.0:* LISTEN 1390/gitlab-workhor
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 1406/puma 5.1.1 (un
tcp 0 0 127.0.0.1:9168 0.0.0.0:* LISTEN 1401/ruby
tcp 0 0 127.0.0.1:8082 0.0.0.0:* LISTEN 1492/sidekiq 5.2.9
tcp 0 0 127.0.0.1:9236 0.0.0.0:* LISTEN 1439/gitaly
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 763/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1117/sshd: /usr/sbi
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 12461/postgres
tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN 1400/grafana-server
tcp6 0 0 :::445 :::* LISTEN 1128/smbd
tcp6 0 0 :::9094 :::* LISTEN 1405/alertmanager
tcp6 0 0 :::139 :::* LISTEN 1128/smbd
tcp6 0 0 :::22 :::* LISTEN 1117/sshd: /usr/sbi
udp 0 0 127.0.0.53:53 0.0.0.0:* 763/systemd-resolve
udp 0 0 192.168.1.29:68 0.0.0.0:* 761/systemd-network
udp 0 0 192.168.1.255:137 0.0.0.0:* 1078/nmbd
udp 0 0 192.168.1.29:137 0.0.0.0:* 1078/nmbd
udp 0 0 172.17.255.255:137 0.0.0.0:* 1078/nmbd
udp 0 0 172.17.0.1:137 0.0.0.0:* 1078/nmbd
udp 0 0 192.168.1.255:137 0.0.0.0:* 1078/nmbd
udp 0 0 192.168.1.101:137 0.0.0.0:* 1078/nmbd
udp 0 0 0.0.0.0:137 0.0.0.0:* 1078/nmbd
udp 0 0 192.168.1.255:138 0.0.0.0:* 1078/nmbd
udp 0 0 192.168.1.29:138 0.0.0.0:* 1078/nmbd
udp 0 0 172.17.255.255:138 0.0.0.0:* 1078/nmbd
udp 0 0 172.17.0.1:138 0.0.0.0:* 1078/nmbd
udp 0 0 192.168.1.255:138 0.0.0.0:* 1078/nmbd
udp 0 0 192.168.1.101:138 0.0.0.0:* 1078/nmbd
udp 0 0 0.0.0.0:138 0.0.0.0:* 1078/nmbd
udp6 0 0 fe80::72e2:4cff:fe6:546 :::* 761/systemd-network
udp6 0 0 :::9094 :::* 1405/alertmanager