PostgreSQL 10: pg_ctl-Status funktioniert unter Ubuntu 18.04 nicht

PostgreSQL 10: pg_ctl-Status funktioniert unter Ubuntu 18.04 nicht

Ich möchte pg_ctl zur Verwaltung meiner CrewDB-Datenbank verwenden können. Wenn ich jedoch pg_ctl status verwende, erhalte ich die folgende Fehlermeldung:

chh1@chh1:~$ pg_ctl status
pg_ctl: could not open PID file "/var/lib/postgresql/10/main/postmaster.pid": Permission denied

Ich bin nicht sicher, warum das so ist oder wie ich es beheben kann, denn wenn ich das tue:

chh1@chh1:~$ which pg_ctl
/usr/lib/postgresql/10/bin/pg_ctl

chh1@chh1:~$ which initdb
/usr/lib/postgresql/10/bin/initdb

chh1@chh1:~$ whoami
chh1

crewdb=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 chh1      | Superuser                                                  | {}
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}


chh1@chh1:~$ cat .profile
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

PATH=$PATH:/usr/lib/postgresql/10/bin
PGDATA=/var/lib/postgresql/10/main
PGDATABASE=crewdb
PGUSER=postgres

export PATH PGDATA PGDATABASE PGUSER

Ich habe PGUSER=chh1 statt PGUSER=postgres in .profile ausprobiert, bekomme aber immer noch dieselbe Fehlermeldung, wenn ich den Befehl pg_ctl status abgebe. Kann mir jemand dabei helfen? Ich habe den folgenden PostgreSQL-Cluster:

chh1@chh1:~$ ps -ef | grep postgres
postgres  2094     1  0 11:08 ?        00:00:01 /usr/lib/postgresql/10/bin/postgres -D /var/lib/postgresql/10/main -c config_file=/etc/postgresql/10/main/postgresql.conf
postgres  2114  2094  0 11:08 ?        00:00:00 postgres: 10/main: logger process
postgres  2123  2094  0 11:08 ?        00:00:00 postgres: 10/main: checkpointer process
postgres  2124  2094  0 11:08 ?        00:00:00 postgres: 10/main: writer process
postgres  2125  2094  0 11:08 ?        00:00:00 postgres: 10/main: wal writer process
postgres  2126  2094  0 11:08 ?        00:00:01 postgres: 10/main: autovacuum launcher process
postgres  2127  2094  0 11:08 ?        00:00:01 postgres: 10/main: stats collector process
postgres  2128  2094  0 11:08 ?        00:00:00 postgres: 10/main: bgworker: logical replication launcher
chh1      6401 17468  0 17:47 pts/1    00:00:00 grep --color=auto postgres

Ungewöhnlich erscheint auch, dass ich Root sein muss, um das Datenverzeichnis zu öffnen, beispielsweise in:

chh1@chh1:~$ cd /var/lib/postgresql/10/main
bash: cd: /var/lib/postgresql/10/main: Permission denied

root@chh1:/var/lib/postgresql/10/main# ls -l
total 100
drwx------ 20 postgres postgres 4096 Jan 13 11:08 ./
drwxr-xr-x  3 postgres postgres 4096 Jul 24 19:12 ../
drwx------  6 postgres postgres 4096 Aug 10 23:04 base/
-rw-------  1 postgres postgres   44 Jan 13 11:08 current_logfiles
drwx------  2 postgres postgres 4096 Jan 13 11:08 global/
drwx------  2 postgres postgres 4096 Jan 13 11:08 log/
drwx------  2 postgres postgres 4096 Jul 24 19:12 pg_commit_ts/
drwx------  2 postgres postgres 4096 Jul 24 19:12 pg_dynshmem/
drwx------  4 postgres postgres 4096 Jan 13 11:13 pg_logical/
drwx------  4 postgres postgres 4096 Jul 24 19:12 pg_multixact/
drwx------  2 postgres postgres 4096 Jan 13 11:08 pg_notify/
drwx------  2 postgres postgres 4096 Jul 24 19:12 pg_replslot/
drwx------  2 postgres postgres 4096 Jul 24 19:12 pg_serial/
drwx------  2 postgres postgres 4096 Jul 24 19:12 pg_snapshots/
drwx------  2 postgres postgres 4096 Jan 13 11:08 pg_stat/
drwx------  2 postgres postgres 4096 Jul 24 19:12 pg_stat_tmp/
drwx------  2 postgres postgres 4096 Jan  3 06:12 pg_subtrans/
drwx------  2 postgres postgres 4096 Jul 24 19:12 pg_tblspc/
drwx------  2 postgres postgres 4096 Jul 24 19:12 pg_twophase/
-rw-------  1 postgres postgres    3 Jul 24 19:12 PG_VERSION
drwx------  3 postgres postgres 4096 Jan  3 06:12 pg_wal/
drwx------  2 postgres postgres 4096 Jul 24 19:12 pg_xact/
-rw-------  1 postgres postgres   88 Jul 24 19:12 postgresql.auto.conf
-rw-------  1 postgres postgres  130 Jan 13 11:08 postmaster.opts
-rw-------  1 postgres postgres  108 Jan 13 11:08 postmaster.pid

Ich überlege, die Dateiberechtigungen in /var/lib/postgresql/10/main/chh1:chh1 zu ändern, bin mir aber nicht sicher, ob das sicher ist, ohne meine Daten zu gefährden. Bitte lassen Sie mich wissen, wenn Sie weitere Informationen benötigen.

verwandte Informationen