Skip to main content
Topic: Error during PostgreSQL installation (Read 1811 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

Error during PostgreSQL installation

Hi. I had some problems installing postgresql:

1. Also have mysql installed in my system and its uid is 980. When I tried to install postgresql for the first time,
I got the error message "useradd: UID 980 is not unique", so I had to change mysql uid to something like 979.

2. After that, another installing attemps resulted in the following error:

chattr: Operation not supported while setting flags on /var/lib/postgres/data
error: command failed to execute correctly

Here is the complete install command's output:

Code: [Select]
resolving dependencies...
looking for conflicting packages...

Package (3)             New Version  Net Change  Download Size

world/postgresql        12.1-2        50.45 MiB      15.65 MiB
world/postgresql-libs   12.1-2         6.24 MiB       1.16 MiB
world/postgresql-runit  20180605-1     0.03 MiB       0.00 MiB

Total Download Size:   16.81 MiB
Total Installed Size:  56.71 MiB

:: Proceed with installation? [Y/n]
:: Retrieving packages...
 postgresql-libs-12.1-2-x86_64           1183.6 KiB  1160 KiB/s 00:01 [---------------------------------------]   6%
 postgresql-12.1-2-x86_64                  16.8 MiB  4.06 MiB/s 00:04 [---------------------------------------]  99%
 postgresql-runit-20180605-1-any           16.8 MiB  3.76 MiB/s 00:04 [---------------------------------------] 100%
(3/3) checking keys in keyring                                        [---------------------------------------] 100%
(3/3) checking package integrity                                      [---------------------------------------] 100%
(3/3) loading package files                                           [---------------------------------------] 100%
(3/3) checking for file conflicts                                     [---------------------------------------] 100%
(3/3) checking available disk space                                   [---------------------------------------] 100%
:: Processing package changes...
(1/3) installing postgresql-libs                                      [---------------------------------------] 100%
(2/3) installing postgresql                                           [---------------------------------------] 100%
Optional dependencies for postgresql
    python2: for PL/Python 2 support [installed]
    python: for PL/Python 3 support [installed]
    perl: for PL/Perl support [installed]
    tcl: for PL/Tcl support
    postgresql-old-upgrade: upgrade from previous major version using pg_upgrade
(3/3) installing postgresql-runit                                     [---------------------------------------] 100%
:: Running post-transaction hooks...
(1/2) Creating system user accounts...
(2/2) Creating temporary files...
chattr: Operation not supported while setting flags on /var/lib/postgres/data
error: command failed to execute correctly

As I could not figure out whether it's a fatal installation error, I decided to keep the installation process (following ArchWiki). Unfortunately, I got the message "This account is currently not available" when I tried to change to postgres user and execute initdb. So I changed postgres user's default shell from /sbin/nologin to /bin/bash and sudo -iu postgres ran fine. But I couldn't start the service and after checking /var/log/daemon.log, it was because there were no directory postgresql under /run. So I created it and set its permissions to postgres user. Well, postgresql is working now, but I would like to report the errors I faced (don't even know if I faced it correctly). What caused chattr error during install?

I also noticed that I have two postgresql folders under /var/lib (postgres and postgresql). Is that ok?

Thanks

Re: Error during PostgreSQL installation

Reply #1
Chattr tries to set some attributes on directory/file, but these attributes are not available on your /var fs. I don't think this is critical
ARMtix

Re: Error during PostgreSQL installation

Reply #2
Hmm weird seems either MySQL or post needs to be edited to be unique ID and system user for it

Re: Error during PostgreSQL installation

Reply #3
I am using Artix with Runit. There seems to be a discrepancy between Arch and Artix assumptions about data locations for PostgreSQL.

1) If you follow the Arch Linux Wiki https://wiki.archlinux.org/index.php/PostgreSQL there is this command:

Code: [Select]
[postgres]$ initdb -D /var/lib/postgres/data

which assumes /var/lib/postgres/data as data location.

However Artix Linux postgresql-runit package assumes /var/lib/postgresql/data location.

2) /etc/runit/sv/postgresql/log/run uses logger:

Code: [Select]
#!/bin/sh
exec logger -p daemon.info -t postgres

which for some reason does not log anywhere on my system:

Code: [Select]
$ ls /var/log
btmp  dmesg.log  pacman.log  tallylog  wtmp

so in /var/log I created folder:

Code: [Select]
drwxr-x--- root wheel sv

and in /var/log/sv folder:

Code: [Select]
drwxr-x--- root wheel postgresql

and changed /etc/runit/sv/postgresql/log/run to

Code: [Select]
#!/bin/sh
exec svlogd /var/log/sv/postgresql

svlogd is a runit logger that is installed on Artix Linux by default, so why not use it?

3) From produced logs I uncovered another problem - PostgreSQL cannot create socket file in /run/postgresql/ because the folder does not exist.

As I understand /run is in memory, not on disk, so it makes no sense to create it manually adhoc - it has to be created on every boot. This highlights the reason why the following message appears after postgresql installation and then on every boot:

chattr: Operation not supported while setting flags on /var/lib/postgres/data

Specifically, /etc/rc/sysinit/75-tmpfiles-setup is failing.

It uses /usr/lib/tmpfiles.d/postgresql.conf to ensure needed folders are created.

Code: [Select]
$ pacman -Qo /usr/lib/tmpfiles.d/postgresql.conf
/usr/lib/tmpfiles.d/postgresql.conf is owned by postgresql 12.2-1

Code: [Select]
$ cat /usr/lib/tmpfiles.d/postgresql.conf
d /var/lib/postgres/data 700 postgres postgres
h /var/lib/postgres/data -   -        -        - +C

h ... +C disables copy-on-write on those file systems which support this feature (ex., btrfs).
This operation is not supported on ext4, so I removed the line, and hence the error message.

This file again assumes /var/lib/postgres/data data location, which is /var/lib/postgresql/data on Artix.

So the final version of /usr/lib/tmpfiles.d/postgresql.conf is:

Code: [Select]
d /var/lib/postgresql/data 700 postgres postgres

in addition I created /etc/tmpfiles.d/postgresql.conf:

Code: [Select]
d /run/postgresql 770 postgres postgres

4) Ensure your user account is in the postgres group:

Code: [Select]
$ groups
postgres wheel {username}

If not:

Code: [Select]
# usermod -a -G postgres {username}

After that reenter your login shell.

Also check the postgres user in the /etc/passwd file for correct path to its home folder: /var/lib/postgresql.

5) Uncomment in /var/lib/postgresql/data/postgresql.conf:
Code: [Select]
listen_addresses = 'localhost'

6) /etc/hosts should contain at least:

Code: [Select]
127.0.0.1 localhost
::1       localhost
127.0.1.1 myhostname.localdomain myhostname
https://wiki.archlinux.org/index.php/Installation_guide#Network_configuration

Now I have a working PostgreSQL installation.

Re: Error during PostgreSQL installation

Reply #4
Hmm, it might be worth changing the script's default directories to match Arch's guide. I agree it could be pretty confusing.

Re: Error during PostgreSQL installation

Reply #5
Hmm, it might be worth changing the script's default directories to match Arch's guide. I agree it could be pretty confusing.
Yup, the openrc script uses the "correct" directory:
Code: [Select]
% grep var/lib /etc/conf.d/postgresql 
PGDATA="/var/lib/postgres/data/"
DATA_DIR="/var/lib/postgres/data"

Re: Error during PostgreSQL installation

Reply #6
Code: [Select]
$ cat /usr/lib/tmpfiles.d/postgresql.conf
d /var/lib/postgres/data 700 postgres postgres
h /var/lib/postgres/data -   -        -        - +C

h ... +C disables copy-on-write on those file systems which support this feature (ex., btrfs).
This operation is not supported on ext4, so I removed the line, and hence the error message.

Hmm, Arch's package also sets this to +C. Surely they have the same chattr error? I'm not really sure what the correct value should be here though.

Re: Error during PostgreSQL installation

Reply #7
I'm not really sure what the correct value should be here though.
I think having an error message on ext4 is "unpleasant", but not critical (has no negative impact).
But not having copy-on-write disabled for a database folder on btrfs might be critical (has negative impact).
So I would rather have this h...+C line there by default, and just remove it once I found out its purpose and its irrelevance to my filesystem.