Skip to main content
Topic: Failure to install postgresql (Read 4134 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Failure to install postgresql

Hi everyone!

I was installing the postgresql package and received the following error
Code: [Select]
(1/2) Creating system user accounts...
(2/2) Creating temporary files...
chown: invalid user: ‘postgres’
chgrp: invalid group: ‘postgres’
chattr: Operation not supported while setting flags on /var/lib/postgres/data
error: command failed to execute correctly

Looking into it I think the sysusers hook failed to correctly create a postgres user. I tried to use the sysusers utility on the created file /usr/lib/sysusers.d/postgresql.conf but this didn't create the user either. I was wondering if there was a known but in opensysusers.

Here is what that file (postgresql.conf) looks like
Code: [Select]
u postgres - "PostgreSQL user" /var/lib/postgres /bin/bash

Thanks!!

Re: Failure to install postgresql

Reply #1
Something is strange here. I double checked on my machine and the user/group was created normally with no issues. Make sure the "postgres" user/group doesn't already exist on your system. If it does, try deleting it (userdel postgres) and then reinstalling postgresql. The chattr error is normal and expected. IIRC, it sets flags for certain filesystems (like btrfs) and will fail on ext4 but is a harmless error.

Re: Failure to install postgresql

Reply #2
Something is strange here. I double checked on my machine and the user/group was created normally with no issues. Make sure the "postgres" user/group doesn't already exist on your system. If it does, try deleting it (userdel postgres) and then reinstalling postgresql. The chattr error is normal and expected. IIRC, it sets flags for certain filesystems (like btrfs) and will fail on ext4 but is a harmless error.
I checked and reran the userdel just to make sure it was cleared. It still fails with the same messages. Is there any extra information that I could provide that would help?

Re: Failure to install postgresql

Reply #3
that
Hi everyone!

I was installing the postgresql package and received the following error
Code: [Select]
(1/2) Creating system user accounts...
(2/2) Creating temporary files...
chown: invalid user: ‘postgres’
chgrp: invalid group: ‘postgres’
chattr: Operation not supported while setting flags on /var/lib/postgres/data
error: command failed to execute correctly

Looking into it I think the sysusers hook failed to correctly create a postgres user. I tried to use the sysusers utility on the created file /usr/lib/sysusers.d/postgresql.conf but this didn't create the user either. I was wondering if there was a known but in opensysusers.

Here is what that file (postgresql.conf) looks like
Code: [Select]
u postgres - "PostgreSQL user" /var/lib/postgres /bin/bash

Thanks!!

please read https://wiki.archlinux.org/index.php/PostgreSQL you need initialize db and configuration .

1 . sudo -iu postgres
2. initdb -D /var/lib/postgres/data
3.  sudo rc-service postgresql start

fresh installed, tested, works

EDIT: in case if you can not use "sudo -iu postgres" (me happens this error: 'this account is not avaible' ) run "sudo chsh -s /bin/bash postgres" instead

Re: Failure to install postgresql

Reply #4
chown: invalid user: ‘postgres’ and  chgrp: invalid group: ‘postgres’  can happens, if you  has installed another postgresql database  before in /var/lib/postgres/data.

/var/lib/postgres/data must be empty

it's your fresh installation of postgresql?

Re: Failure to install postgresql

Reply #5
that
please read https://wiki.archlinux.org/index.php/PostgreSQL you need initialize db and configuration .

1 . sudo -iu postgres
2. initdb -D /var/lib/postgres/data
3.  sudo rc-service postgresql start

fresh installed, tested, works

EDIT: in case if you can not use "sudo -iu postgres" (me happens this error: 'this account is not avaible' ) run "sudo chsh -s /bin/bash postgres" instead
I tried this. I get the error


sudo: unknown user: postgres
sudo: unable to initialize policy plugin

With the first command (with -iu), and with the second command I get

chsh: user "postgres" does not exist.

chown: invalid user: ‘postgres’ and  chgrp: invalid group: ‘postgres’  can happens, if you  has installed another postgresql database  before in /var/lib/postgres/data.

/var/lib/postgres/data must be empty

it's your fresh installation of postgresql?

I checked that this was empty and it was. I have not installed postgresql before

Re: Failure to install postgresql

Reply #6
very strange error, because i installed today a fresh installation and all works :-\
try "sudo -u myusername psql postgres"

Code: [Select]
[picasso etc]# cat gshadow | grep postgr
postgres:!::

Code: [Select]
[picasso etc]# cat shadow | grep postgr
postgres:!:18242::::::

Code: [Select]
[picasso etc]# cat group | grep postgr
postgres:x:987:alois


you can uninstall postgresql postgresql-libs postgresql-openrc, delete /var/lib/postgresql, and try install it again.


Re: Failure to install postgresql

Reply #7
very strange error, because i installed today a fresh installation and all works :-\
try "sudo -u myusername psql postgres"

Code: [Select]
[picasso etc]# cat gshadow | grep postgr
postgres:!::

Code: [Select]
[picasso etc]# cat shadow | grep postgr
postgres:!:18242::::::

Code: [Select]
[picasso etc]# cat group | grep postgr
postgres:x:987:alois


you can uninstall postgresql postgresql-libs postgresql-openrc, delete /var/lib/postgresql, and try install it again.


The first command fails because a server is not running (I believe to start the server you need the postgres user)

The three commands following return nothing (meaning of course that there is no such user). And an uninstall + delete /var/lib/postgresql does not work upon reinstall.

Also I'm using runit if that helps at all

 

Re: Failure to install postgresql

Reply #8
can you copy the output of terminal at reinstallation? and after if you try initialization?

I use openrc, but installation and initialization should be same

Re: Failure to install postgresql

Reply #9
can you copy the output of terminal at reinstallation? and after if you try initialization?

I use openrc, but installation and initialization should be same
Here's the output
Code: [Select]
[I] [faye@acerpred ~] yay -S postgresql postgresql-runit                         17:33:29
resolving dependencies...
looking for conflicting packages...

Packages (3) postgresql-libs-12.2-3  postgresql-12.2-3  postgresql-runit-20180605-1

Total Installed Size:  57.59 MiB

:: Proceed with installation? [Y/n] y
(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...
chown: invalid user: ‘postgres’
chgrp: invalid group: ‘postgres’
chattr: Operation not supported while setting flags on /var/lib/postgres/data
error: command failed to execute correctly
[I] [faye@acerpred ~] su -l postgres                                             17:33:36
su: user postgres does not exist or the user entry does not contain all the required fields
[I] [faye@acerpred ~] initdb -D /var/lib/postgres/data                           17:34:33
The files belonging to this database system will be owned by user "faye".
This user must also own the server process.

The database cluster will be initialized with locales
  COLLATE:  C
  CTYPE:    en_US.UTF-8
  MESSAGES: en_US.UTF-8
  MONETARY: en_US.UTF-8
  NUMERIC:  en_US.UTF-8
  TIME:     en_US.UTF-8
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

initdb: error: could not access directory "/var/lib/postgres/data": Permission denied
I tried to use su -l to login as the postgres user, but no such user was found

Re: Failure to install postgresql

Reply #10
try create user and group manually:
Code: [Select]
groupadd -g 987 -o -r postgres (note: 987 is my number, your free number you found in /etc/group)

Code: [Select]
useradd -M  -g postgres -o -r -d /var/lib/postgres -s /bin/bash -c "PostgreSQL user" -u 987 postgres

Re: Failure to install postgresql

Reply #11
try create user and group manually:
Code: [Select]
groupadd -g 987 -o -r postgres (note: 987 is my number, your free number you found in /etc/group)

Code: [Select]
useradd -M  -g postgres -o -r -d /var/lib/postgres -s /bin/bash -c "PostgreSQL user" -u 987 postgres
This works but it's definitely not what should happen. does anyone know a fix as to why opensysusers would not create a user when it should?

Re: Failure to install postgresql

Reply #12
We don't know why you happens this errors, it's relatively rare. On another two computer where we tested it, run all without problems.
Also we think, you has some  wrong set in your computer. But no idea what exactly...

I can confirm, that on my computer works opensysuser and installation of postgresql without problems.