[SOLVED] cannot set postgresql socket dir

This forum is dedicated to basic help and support :

Ask here your questions about basic installation and usage of Mageia. For example you may post here all your questions about getting Mageia isos and installing it, configuring your printer, using your word processor etc.

Try to ask your questions in the right sub-forum with as much details as you can gather. the more precise the question will be, the more likely you are to get a useful answer

[SOLVED] cannot set postgresql socket dir

Postby magfan » Mar 14th, '14, 15:33

Although the variable unix_socket_directory is set in /var/lib/pgsql/data/postgresql.conf postgres opens sockets in /tmp:
Code: Select all
# cat /var/lib/pgsql/data/postgresql.conf | grep unix_socket_directory
unix_socket_directory = '/var/run/postgresql'          # (change requires restart)
# ls -l /tmp/.s*
srwxrwxrwx 1 postgres postgres  0 Mär 14 13:51 /tmp/.s.PGSQL.5432=
-rw------- 1 postgres postgres 46 Mär 14 13:51 /tmp/.s.PGSQL.5432.lock
#

How can I force postgresql to use another socket directory than /tmp?

Code: Select all
# rpm -qa | grep postgres
postgresql9.1-plpgsql-9.1.11-2.mga4
postgresql9.1-devel-9.1.11-2.mga4
postgresql9.1-plpython-9.1.11-2.mga4
postgresql9.1-plperl-9.1.11-2.mga4
postgresql9.1-server-9.1.11-2.mga4
postgresql9.1-9.1.11-2.mga4
postgresql9.1-pl-9.1.11-2.mga4
postgresql9.1-pltcl-9.1.11-2.mga4
postgresql-jdbc-9.2.1002-6.mga4
#
Last edited by magfan on Mar 21st, '14, 11:19, edited 1 time in total.
magfan
 
Posts: 334
Joined: Apr 3rd, '12, 12:33

Re: cannot set postgresql socket dir

Postby davidwhodgins » Mar 19th, '14, 22:31

In Mageia 3 and 4, /var/run is a symlink to /run, which is a tmpfs filesystem.
I haven't tested, but suspect a file fill be needed in /etc/tmpfiles.d to create the
directory /var/run/postgresql
See /usr/lib/tmpfiles.d/initscripts.conf for a sample of the layout, or read
man tmpfiles.d

Regards, Dave Hodgins
davidwhodgins
 
Posts: 47
Joined: Nov 18th, '11, 05:14

Re: cannot set postgresql socket dir

Postby davidwhodgins » Mar 19th, '14, 22:53

Sorry for the typo. That should be will rather then fill.
davidwhodgins
 
Posts: 47
Joined: Nov 18th, '11, 05:14

Re: cannot set postgresql socket dir

Postby magfan » Mar 20th, '14, 14:52

Unfortunately, this does not help. Even if I stop postgresql.service and manually create that directory (/var/run/postgresql) starting postgresql.service will place its socket files in /tmp. I know that creating socket files in /tmp is a default for postgresql which can be changed either during compile time (rpm-package should know about it) or by defining unix_socket_directory in /var/lib/pgsql/data/postgresql.conf. The strange thing is that in mga3 I just installed postgresql and it was using /var/run/postgresql. Now after upgrading to mga4 it does not use that directory any more but the default (/tmp). However, somewhere there must be some kind of "system configuration" which tells programs that the socket directory is /var/run/postgresql. I know it because I have a commercial software package which complains during installation that there is no socket file in /var/run/postgresql. How could it know about this path if it is not even the default path? Where could I look for such a hidden configuration parameter?
magfan
 
Posts: 334
Joined: Apr 3rd, '12, 12:33

Re: cannot set postgresql socket dir

Postby davidwhodgins » Mar 20th, '14, 17:14

I just tried with postgresql9.2 (which I already had installed) ...
Code: Select all
mkdir /var/run/postgresql
chown postgres:postgres /var/run/postgresql
systemctl restart postgresql.service
ll /var/run/postgresql/
total 4
srwxrwxrwx 1 postgres postgres  0 Mar 20 10:49 .s.PGSQL.5432=
-rw------- 1 postgres postgres 62 Mar 20 10:49 .s.PGSQL.5432.lock


Did you chown the directory?

I then created cat /etc/tmpfiles.d/postgres.conf

Code: Select all
d /var/run/postgresql 0755 postgres postgres -


And after rebooting
Code: Select all
ll /var/run/postgresql/
total 4
srwxrwxrwx 1 postgres postgres  0 Mar 20 11:06 .s.PGSQL.5432=
-rw------- 1 postgres postgres 61 Mar 20 11:06 .s.PGSQL.5432.lock


So it's working with postgresql9.2-server

If chown of the directory doesn't fix it for 9.1, I can downgrade, to see if I can recreate the
problem.
Last edited by doktor5000 on Mar 20th, '14, 23:36, edited 1 time in total.
Reason: added code tags, to improve on clarity
davidwhodgins
 
Posts: 47
Joined: Nov 18th, '11, 05:14

Re: cannot set postgresql socket dir

Postby magfan » Mar 20th, '14, 18:02

No, it still does not work:
Code: Select all
# mkdir /var/run/postgresql
# chown postgres:postgres /var/run/postgresql
# systemctl restart postgresql.service
# ll /var/run/postgresql/
insgesamt 0
# ll /tmp/.s*
srwxrwxrwx 1 postgres postgres  0 Mär 20 16:49 /tmp/.s.PGSQL.5432=
-rw------- 1 postgres postgres 46 Mär 20 16:49 /tmp/.s.PGSQL.5432.lock
#
magfan
 
Posts: 334
Joined: Apr 3rd, '12, 12:33

Re: cannot set postgresql socket dir

Postby davidwhodgins » Mar 20th, '14, 18:44

I uninstalled all postgresql9 packages, deleted /var/lib/pgsql, installed postgresql9.1-server,
and started the postgresql.service, then edited postgresql.conf
grep socket /var/lib/pgsql/data/postgresql.conf |head -n 1
unix_socket_directory = '/run/postgresql'
Then restarted the service.
[root@x3 data]# ll -d /var/run/postgresql/
drwxr-xr-x 2 postgres postgres 80 Mar 20 12:37 /var/run/postgresql//
[root@x3 data]# ll /var/run/postgresql/
total 4
srwxrwxrwx 1 postgres postgres 0 Mar 20 12:37 .s.PGSQL.5432=
-rw------- 1 postgres postgres 58 Mar 20 12:37 .s.PGSQL.5432.lock
davidwhodgins
 
Posts: 47
Joined: Nov 18th, '11, 05:14

Re: cannot set postgresql socket dir

Postby davidwhodgins » Mar 20th, '14, 18:54

Is /var/run a symlink to /run?

Only other thing I can think of is that the config file doesn't like have the spaces
before and after the = sign.
davidwhodgins
 
Posts: 47
Joined: Nov 18th, '11, 05:14

Re: cannot set postgresql socket dir

Postby magfan » Mar 21st, '14, 11:19

Finally I decided to do the following:

1. stopping postgresql.service
2. uninstalling postgresql9.1
3. deleting /var/lib/pgsql completely
4. creating your /etc/tmpfiles.d/postgres.conf
5. rebooting
6. installing postgresql9.1
7. starting postgresql.service
8. editing /var/lib/pgsql/data/postgresql.conf (unix_socket_directory = '/var/run/postgresql)
9. restarting postgresql.service

Now everything works! Great! Thanks a lot!
magfan
 
Posts: 334
Joined: Apr 3rd, '12, 12:33


Return to Basic support

Who is online

Users browsing this forum: No registered users and 1 guest

cron