Обсуждение: Trouble installing Drupal 5 using sockets (a little long)
Greetings and Hello!
I am trying to get my little ALIX server that is running OpenBSD
4.4-current to run pgsql. I've been successful in installing 8.3.3,
and since OpenBSD uses a chrooted environment, I intend on using unix
sockets for making database connections. I read the man pages, ran
"initdb -D /var/postgresql/data -U postgres -A md5 -W" and edited the
/var/postgresql/data/postgresql.conf file to read:
-----------------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = 'localhost' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost', '*' = all
# (change requires restart)
#port = 5432 # (change requires restart)
max_connections = 40 # (change requires restart)
# Note: Increasing max_connections costs ~400 bytes of shared memory per
# connection slot, plus lock space (see max_locks_per_transaction). You might
# also need to raise shared_buffers to support more connections.
#superuser_reserved_connections = 3 # (change requires restart)
unix_socket_directory = '/var/www/tmp' # (change requires restart)
unix_socket_group = '' # (change requires restart)
unix_socket_permissions = 0777 # begin with 0 to use octal notation
# (change requires restart)
#bonjour_name = '' # defaults to the computer name
-------------------------------------------------------------------------------------
I only have 256MB of RAM, so my connections will stay low. I started
pgsql using:
# pg_ctl -D /var/postgresql/data -l logfile start
And the following shows in the /var/postgresql/logfile:
-------------------------------------------------------------------------------------
LOG: database system was shut down at 2008-08-09 20:33:22 UTC
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
-------------------------------------------------------------------------------------
An output of netstat -a shows the following:
# netstat -a | grep /var
0xd60cab9c stream 0 0 0xd604394c 0x0 0x0 0x0 /var/www/tmp/.s.PGSQL.5432
0xd61f81a8 dgram 0 0 0xd61f3cd0 0x0 0x0 0x0 /var/empty/dev/log
At this point, I think I am good to go, and can continue.
After I installed Drupal 5, I attempted to create the database that
drupal will use in pgsql. pkginfo -D gives me the following:
-------------------------------------------------------------------------------------
In postgresql, assuming an `admin' account has all rights:
createuser -U admin --pwprompt --no-superuser --createdb --no-createrole drupal
createdb -U drupal -E UTF8 drupal
-------------------------------------------------------------------------------------
When I type the following:
# createuser -U admin --pwprompt --no-superuser --createdb
--no-createrole drupal
I get the following output:
-------------------------------------------------------------------------------------
Enter password for new role:
Enter it again:
createuser: could not connect to database postgres: could not connect
to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
-------------------------------------------------------------------------------------
Now, something in pgsql is still set and is overiding the config that
I set up. I did do the initdb and then set the socket, is there
something inside the inital database that needs to be set? After
searching the internet, I found that someone mentioned that a reboot
after some system updates fixed the issue
(http://www.dbforums.com/showthread.php?t=1625811), but I have not
made any systems changes, and restarting pgsql does start the service
and create the socket inside the chroot (/var/www/).
So, is there any other place that I need to change that tells the
system where the unix socket is?
Much obliged,
Bryan Brake
Bryan wrote:
> I am trying to get my little ALIX server that is running OpenBSD
> 4.4-current to run pgsql. I've been successful in installing 8.3.3,
> and since OpenBSD uses a chrooted environment, I intend on using unix
> sockets for making database connections. I read the man pages, ran
> "initdb -D /var/postgresql/data -U postgres -A md5 -W" and edited the
> /var/postgresql/data/postgresql.conf file to read:
> -------------------------------------------------------------------------------------
> In postgresql, assuming an `admin' account has all rights:
>
> createuser -U admin --pwprompt --no-superuser --createdb --no-createrole drupal
> createdb -U drupal -E UTF8 drupal
> -------------------------------------------------------------------------------------
>
> When I type the following:
>
> # createuser -U admin --pwprompt --no-superuser --createdb
> --no-createrole drupal
You are running createuser under your "root" account and root is not a
priviledged user of pgsql under OpenBSD.
1) login as the pgsql "admin" user (I think it's _postgresql; I changed
it on my system). this was created for you if you used OpenBSD package
to install pgsql.
# su - _postgresql
2) Issue the createuser and createdb commands from that account.
On Thu, Aug 14, 2008 at 12:10 PM, Frank Bax <fbax@sympatico.ca> wrote: > Bryan wrote: >> >> I am trying to get my little ALIX server that is running OpenBSD >> 4.4-current to run pgsql. I've been successful in installing 8.3.3, >> and since OpenBSD uses a chrooted environment, I intend on using unix >> sockets for making database connections. I read the man pages, ran >> "initdb -D /var/postgresql/data -U postgres -A md5 -W" and edited the >> /var/postgresql/data/postgresql.conf file to read: >> >> ------------------------------------------------------------------------------------- >> In postgresql, assuming an `admin' account has all rights: >> >> createuser -U admin --pwprompt --no-superuser --createdb --no-createrole >> drupal >> createdb -U drupal -E UTF8 drupal >> >> ------------------------------------------------------------------------------------- >> >> When I type the following: >> >> # createuser -U admin --pwprompt --no-superuser --createdb >> --no-createrole drupal > > > You are running createuser under your "root" account and root is not a > priviledged user of pgsql under OpenBSD. > > 1) login as the pgsql "admin" user (I think it's _postgresql; I changed it > on my system). this was created for you if you used OpenBSD package to > install pgsql. > # su - _postgresql > 2) Issue the createuser and createdb commands from that account. > Frank, Thanks for the help. Unfortunately, I did do it with the _postgresql user, I just was stupid in the copy paste. I hit "#", then pasted the output. The error you see above is using _postgresql as the user. I did run the command again making sure I was _postgresql and the error above is still valid. I was further reading about people who were taking the source and building postgresql. As a option, you can set the socket directory to be used by the program when you build it? Shouldn't the postgresql.conf override that directive? Regards, Bryan
Bryan wrote: > On Thu, Aug 14, 2008 at 12:10 PM, Frank Bax <fbax@sympatico.ca> wrote: >> Bryan wrote: >>> I am trying to get my little ALIX server that is running OpenBSD >>> 4.4-current to run pgsql. I've been successful in installing 8.3.3, >>> and since OpenBSD uses a chrooted environment, I intend on using unix >>> sockets for making database connections. I read the man pages, ran >>> "initdb -D /var/postgresql/data -U postgres -A md5 -W" and edited the >>> /var/postgresql/data/postgresql.conf file to read: >>> >>> ------------------------------------------------------------------------------------- >>> In postgresql, assuming an `admin' account has all rights: >>> >>> createuser -U admin --pwprompt --no-superuser --createdb --no-createrole >>> drupal >>> createdb -U drupal -E UTF8 drupal >>> >>> ------------------------------------------------------------------------------------- >>> >>> When I type the following: >>> >>> # createuser -U admin --pwprompt --no-superuser --createdb >>> --no-createrole drupal >> >> You are running createuser under your "root" account and root is not a >> priviledged user of pgsql under OpenBSD. >> >> 1) login as the pgsql "admin" user (I think it's _postgresql; I changed it >> on my system). this was created for you if you used OpenBSD package to >> install pgsql. >> # su - _postgresql >> 2) Issue the createuser and createdb commands from that account. >> > > Frank, > > Thanks for the help. Unfortunately, I did do it with the _postgresql > user, I just was stupid in the copy paste. I hit "#", then pasted the > output. The error you see above is using _postgresql as the user. I > did run the command again making sure I was _postgresql and the error > above is still valid. > > I was further reading about people who were taking the source and > building postgresql. As a option, you can set the socket directory to > be used by the program when you build it? Shouldn't the > postgresql.conf override that directive? OK. I went back and took a closer look at original email. Hopefully you are running all commands as _postgresql. Did you also read: /usr/local/share/doc/postgresql/README.OpenBSD Which suggests a variation to startup command? You've shown that the socket is at /var/www/tmp/ which is great for apps running in chroot'd apache; but it's not great for running commands at the command line which as you can see from the error message indicate they want to socket at /tmp/ I suspect you might need to create a symbolic link from one to the other; but I don't know where the "real" one should be. Perhaps someone else knows that. If you only need the command-line to work one-time while you create the databases; you could modify your config to have socket in /tmp/; cycle pgsql; create user and db; modify config back to /var/www/tmp/ recycle pgsql and get on with Drupal testing. Frank
<snipped...> > > OK. I went back and took a closer look at original email. Hopefully you > are running all commands as _postgresql. Did you also read: > /usr/local/share/doc/postgresql/README.OpenBSD > Which suggests a variation to startup command? > Variation? You mean setting login class and what not? I have the rc.local scripts already in the right places. I don't want to have to start the database everytime I restart the box (which shouldn't be often, but still...) > You've shown that the socket is at /var/www/tmp/ which is great for apps > running in chroot'd apache; but it's not great for running commands at the > command line which as you can see from the error message indicate they want > to socket at /tmp/ > > I suspect you might need to create a symbolic link from one to the other; > but I don't know where the "real" one should be. Perhaps someone else knows > that. > But, the database starts and sees the socket, what part of pgsql is not seeing the socket? Could the fact that I did the "initdb" without the /var/www/tmp socket be causing the issue? Pgsql d > If you only need the command-line to work one-time while you create the > databases; you could modify your config to have socket in /tmp/; cycle > pgsql; create user and db; modify config back to /var/www/tmp/ recycle pgsql > and get on with Drupal testing. > I will try that, but it looks like a workaround... I shouldn't have to do what you propose. Do the devs look at this list, or do they just look at the other lists? I reply back as to the success or failure of this in the near future... Regards, Bryan
Bryan wrote: >> I suspect you might need to create a symbolic link from one to the other; >> but I don't know where the "real" one should be. Perhaps someone else knows >> that. > > But, the database starts and sees the socket, what part of pgsql is > not seeing the socket? Could the fact that I did the "initdb" without > the /var/www/tmp socket be causing the issue? Pgsql d The database SERVER creates the socket, so of course it can see it; the problem is that your database CLIENTS do not see the socket. When you run createuser and createdb; you are running client interfaces which expect to communicate with the PG server via the socket at /tmp/ but that's not where it is; it is created in /var/www/tmp/ everytime the PG server is started. The conf file tells PG server where to create the socket; not where the clients should look for it. Yes, I presented a workaround. I also suggested that the proper permanent solution is to include creation of a symbolic link on every boot; which I don't have the proper syntax for since I've never used it (I chose to disable chroot instead). Here's my guess at command you need to add to startup: ln /var/www/tmp/.s.PGSQL.5432 /tmp/.s.PGSQL.5432 Frank
On Thu, Aug 14, 2008 at 7:53 PM, Frank Bax <fbax@sympatico.ca> wrote: > Bryan wrote: >>> >>> I suspect you might need to create a symbolic link from one to the other; >>> but I don't know where the "real" one should be. Perhaps someone else >>> knows >>> that. >> >> But, the database starts and sees the socket, what part of pgsql is >> not seeing the socket? Could the fact that I did the "initdb" without >> the /var/www/tmp socket be causing the issue? Pgsql d > > > > The database SERVER creates the socket, so of course it can see it; the > problem is that your database CLIENTS do not see the socket. > > When you run createuser and createdb; you are running client interfaces > which expect to communicate with the PG server via the socket at /tmp/ but > that's not where it is; it is created in /var/www/tmp/ everytime the PG > server is started. The conf file tells PG server where to create the > socket; not where the clients should look for it. > > Yes, I presented a workaround. I also suggested that the proper permanent > solution is to include creation of a symbolic link on every boot; which I > don't have the proper syntax for since I've never used it (I chose to > disable chroot instead). Here's my guess at command you need to add to > startup: > > ln /var/www/tmp/.s.PGSQL.5432 /tmp/.s.PGSQL.5432 > Frank, et al... I just wanted to give an update. I was able to successfully install Drupal with pgsql. The problem still stands though. I can make it work with apache not chrooted. I ran apache not chrooted and was able to install the DB, do the initial setup for Drupal, and create user#1. Now, as to the socket, postgresql puts the socket in /tmp. You cannot make a symbolic link from /tmp to /var/www/tmp. You receive a "cross link device" error. I did attempt to put the socket in /var/postgresql/data, and make the link to /var/www/var/postgresql/data. I rebooted the box (to enable the chrooting of apache). Everything starts, but Drupal is unable to connect to the database. I intend to continue to play around, but I'd rather not have to run apache in a way that it was not intended to run. I would like the extra security. Any help would be greatly appreciated... Bryan