You are not logged in.

#1 2022-09-09 13:23:29

crisdean
Member
Registered: 2020-05-14
Posts: 5

PostgreSQL installation per Wiki page not working to 100%

Hi all,

I also searched the forums but the posts are years old and none describes the issue I'm currently facing, hence my post.

So I want to learn PostgreSQL and decided to follow Wiki article https://wiki.archlinux.org/title/Postgr … stallation

However, when I try to run the initdb command: "initdb -D /var/lib/postgres/data" I get the following:

[postgres@arch ~]$ initdb -D /var/lib/postgres/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default database encoding has accordingly been set to "SQL_ASCII".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /var/lib/postgres/data ... initdb: error: could not create directory "/var/lib/postgres/data": Permission denied

------> nothing further shown as per Wiki page


A few comments from my side.
1) I installed the postgresql package with Pacman which created the user.
2) I added user postgres into the /etc/sudoers file

The Wiki article doesn't specify any other previous steps. I would assume that when a user postgres is created it should have a home directory and files shouldn't be written into my user folder.

I searched for other issues here but this problem hasn't been discussed it seems in the forum.
Any help/pointers would be greatly appreciated.

Last edited by crisdean (2022-09-09 13:28:46)

Offline

#2 2022-09-09 13:32:36

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,694

Re: PostgreSQL installation per Wiki page not working to 100%

That dir is created by systemd.tmpfiles. See https://github.com/archlinux/svntogit-p … l.tmpfiles

Yet you don't seem to have it. What happened during installation?

Offline

#3 2022-09-09 13:51:53

crisdean
Member
Registered: 2020-05-14
Posts: 5

Re: PostgreSQL installation per Wiki page not working to 100%

Scimmia wrote:

That dir is created by systemd.tmpfiles. See https://github.com/archlinux/svntogit-p … l.tmpfiles

Yet you don't seem to have it. What happened during installation?


I don't know if my machine taking the mick. So I just removed postgresql again and installed again with sudo pacman -S postgresql

Result:




initdb -D /var/lib/postgres/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default database encoding has accordingly been set to "SQL_ASCII".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgres/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Europe/London
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgres/data -l logfile start

I also used the sudo -iu postgres before, so not sure why it worked now. 5th time the charm I guess? But how could I do a root cause analysis now? It should've worked first time.

Offline

#4 2022-09-09 15:42:23

twelveeighty
Member
Registered: 2011-09-04
Posts: 1,446

Re: PostgreSQL installation per Wiki page not working to 100%

crisdean wrote:

I would assume that when a user postgres is created it should have a home directory

While true for postgres specifically, in general that is a wrong assumption. Many system users have no $HOME - see https://wiki.archlinux.org/title/Users_ … ystem_user. postgres is more of an exception and does have a $HOME, you can check which one it is by examining /etc/passwd.

As to your problem with the 1st install, I am actually surprised that the packaging of postgresql is using systemd.tmpfiles to create a directory that is not supposed to be 'volatile': /var/lib/postgres/data is where your databases live. I would expect to see DB cache, logs, etc. there such as /var/run/postgresql and /var/log/postgresql, not /var/lib/postgresql. Maybe it's just an easy way to create and set permissions on that directory during installation, or I am not understanding something, of course. It is possible that systemd.tmpfiles had not (yet?) acted on the postgresql.tmpfiles config that was created during installation. Check your journal for messages related to tmpfiles.

Last edited by twelveeighty (2022-09-09 15:44:29)

Offline

Board footer

Powered by FluxBB