postgres launch daemon not working
Hi all, I've been unable to get launchctl to start the PostgreSQL server, even though the daemon appears to be loading. First I installed postgresql84 @8.4.10_0, but it appeared that a launch daemon plist file was not included with the installation. Google searches suggested that the plist file comes with the server, so I installed postgresql84-server @8.4.10_0, which indeed installed the plist file. In contrast with installing '84, '84-server took only moments to complete installation. Invoking launchctl to load the plist file, rebooting or not, then calling `psql` yields the familiar error: psql: 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? Thinking that the launch daemon was not loaded, I tried loading it again: % sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql84-server.plist only to find that it was already loaded: org.macports.postgresql84-server: Already loaded The plist file specifies /opt/local/bin/daemondo, which I confirmed exists and is executable on my machine. I currently have both postgres variants active: postgresql84 @8.4.10_0 (active) postgresql84-server @8.4.10_0 (active) Any suggestions? Thanks in advance! Scott ___ macports-users mailing list macports-users@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macports-users
Re: postgres launch daemon not working
Forgot to mention that this is on OSX Lion (10.7.2). On Jan 31, 2012, at 9:55 AM, Scott Frankel wrote: Hi all, I've been unable to get launchctl to start the PostgreSQL server, even though the daemon appears to be loading. First I installed postgresql84 @8.4.10_0, but it appeared that a launch daemon plist file was not included with the installation. Google searches suggested that the plist file comes with the server, so I installed postgresql84-server @8.4.10_0, which indeed installed the plist file. In contrast with installing '84, '84-server took only moments to complete installation. Invoking launchctl to load the plist file, rebooting or not, then calling `psql` yields the familiar error: psql: 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? Thinking that the launch daemon was not loaded, I tried loading it again: % sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql84-server.plist only to find that it was already loaded: org.macports.postgresql84-server: Already loaded The plist file specifies /opt/local/bin/daemondo, which I confirmed exists and is executable on my machine. I currently have both postgres variants active: postgresql84 @8.4.10_0 (active) postgresql84-server @8.4.10_0 (active) Any suggestions? Thanks in advance! Scott ___ macports-users mailing list macports-users@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macports-users ___ macports-users mailing list macports-users@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macports-users
Re: postgres launch daemon not working
On Jan 31, 2012, at 12:55 PM, Scott Frankel wrote: Google searches suggested that the plist file comes with the server, so I installed postgresql84-server @8.4.10_0, which indeed installed the plist file. In contrast with installing '84, '84-server took only moments to complete installation. Invoking launchctl to load the plist file, rebooting or not, then calling `psql` yields the familiar error: psql: 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? did you follow the instructions to create a database instance that the postgresql84-server port printed? (incidentally, they should be moved to notes instead of post-install so that port notes postgresql84-server would print them again). It would have said something like this: To create a database instance, after install do sudo mkdir -p /opt/local/var/db/postgresql84/defaultdb sudo chown postgres:postgres /opt/local/var/db/postgresql84/defaultdb sudo su postgres -c '$/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/db/postgresql84/defaultdb' To tweak your DBMS, consider increasing kern.sysv.shmmax by adding an increased kern.sysv.shmmax .. to /etc/sysctl.conf Any suggestions? I believe if launchd has trouble starting something it will print some error text in /var/log/system.log -- Daniel J. Luke ++ | * dl...@geeklair.net * | | *-- http://www.geeklair.net -* | ++ | Opinions expressed are mine and do not necessarily | | reflect the opinions of my employer. | ++ ___ macports-users mailing list macports-users@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macports-users
Re: postgres launch daemon not working
Hi Daniel, On Jan 31, 2012, at 10:47 AM, Daniel J. Luke wrote: On Jan 31, 2012, at 12:55 PM, Scott Frankel wrote: Google searches suggested that the plist file comes with the server, so I installed postgresql84-server @8.4.10_0, which indeed installed the plist file. In contrast with installing '84, '84-server took only moments to complete installation. Invoking launchctl to load the plist file, rebooting or not, then calling `psql` yields the familiar error: psql: 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? did you follow the instructions to create a database instance that the postgresql84-server port printed? Yes, I should've mentioned that. The installation is perfectly functional once I start it manually; eg: % sudo su postgres -c /opt/local/lib/postgresql84/bin/pg_ctl -D /opt/local/var/postgresql84/defaultdb -l /opt/local/var/postgresql84/defaultdb/data/logfile.txt start Previous to this installation, I had postgresql83 running on MacOSX 10.5 (also via macports) and its server started automatically on machine reboots. Not sure why postgres84 on OSX 10.7 isn't behaving similarly. (incidentally, they should be moved to notes instead of post-install so that port notes postgresql84-server would print them again). That'd be nice. It would have said something like this: To create a database instance, after install do sudo mkdir -p /opt/local/var/db/postgresql84/defaultdb sudo chown postgres:postgres /opt/local/var/db/postgresql84/defaultdb sudo su postgres -c '$/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/db/postgresql84/defaultdb' To tweak your DBMS, consider increasing kern.sysv.shmmax by adding an increased kern.sysv.shmmax .. to /etc/sysctl.conf Any suggestions? I believe if launchd has trouble starting something it will print some error text in /var/log/system.log Thanks for the tip! Jan 31 08:26:02 tiento org.macports.postgresql84-server[1920]: server starting Jan 31 08:29:07 tiento com.apple.SystemStarter[53]: Starting PostgreSQL database server Jan 31 08:29:07 tiento com.apple.SystemStarter[53]: pg_ctl: could not open PID file /Library/PostgreSQL8/data/postmaster.pid: Permission denied Jan 31 08:29:08 tiento SystemStarter[53]: PostgreSQL database server (90) did not complete successfully Looks like pg_ctl is trying to open a postmaster.pid file it doesn't have permissions for. How can I point launchd invocations of pg_ctl to the correct postgres data dir? I initialized my db according to info I gleaned from searches; eg: % sudo su postgres \ -c '/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/postgresql84/defaultdb' Prior to that, I reinstated the postgres user name with: % sudo dscl . -append /Users/postgres UniqueID 401 I assigned the postgres username to UID 401, as my previous installation's postgres files seemed to be owned by user 401 of group postgres. I wonder if this is the source of the permissions problem. Thanks! Scott -- Daniel J. Luke ++ | * dl...@geeklair.net * | | *-- http://www.geeklair.net -* | ++ | Opinions expressed are mine and do not necessarily | | reflect the opinions of my employer. | ++ ___ macports-users mailing list macports-users@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macports-users
Re: postgres launch daemon not working
On Jan 31, 2012, at 13:52, Scott Frankel wrote: Jan 31 08:26:02 tiento org.macports.postgresql84-server[1920]: server starting Jan 31 08:29:07 tiento com.apple.SystemStarter[53]: Starting PostgreSQL database server Jan 31 08:29:07 tiento com.apple.SystemStarter[53]: pg_ctl: could not open PID file /Library/PostgreSQL8/data/postmaster.pid: Permission denied Jan 31 08:29:08 tiento SystemStarter[53]: PostgreSQL database server (90) did not complete successfully Looks like pg_ctl is trying to open a postmaster.pid file it doesn't have permissions for. How can I point launchd invocations of pg_ctl to the correct postgres data dir? I initialized my db according to info I gleaned from searches; eg: % sudo su postgres \ -c '/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/postgresql84/defaultdb' Prior to that, I reinstated the postgres user name with: % sudo dscl . -append /Users/postgres UniqueID 401 I assigned the postgres username to UID 401, as my previous installation's postgres files seemed to be owned by user 401 of group postgres. I wonder if this is the source of the permissions problem. It should not have caused a problem, though it was also unnecessary to create your own postgres user, since that (along with creating the server directories, and the launchd plist) is the purpose of installing the postgresql*-server ports. I'm more concerned about /Library/PostgreSQL8 -- what is that? That doesn't sound like a normal MacPorts location, though I am not actually familiar with postgres so I could be mistaken. ___ macports-users mailing list macports-users@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macports-users
Re: postgres launch daemon not working
On Jan 31, 2012, at 2:52 PM, Scott Frankel wrote: % sudo su postgres -c /opt/local/lib/postgresql84/bin/pg_ctl -D /opt/local/var/postgresql84/defaultdb -l /opt/local/var/postgresql84/defaultdb/data/logfile.txt start Jan 31 08:29:07 tiento com.apple.SystemStarter[53]: pg_ctl: could not open PID file /Library/PostgreSQL8/data/postmaster.pid: Permission denied Jan 31 08:29:08 tiento SystemStarter[53]: PostgreSQL database server (90) did not complete successfully This looks like you are pointing to a different directory than the one you set up when you installed postgresql84-server (and also a different one than the one you're pointed to when you manually start postgres). Looks like pg_ctl is trying to open a postmaster.pid file it doesn't have permissions for. How can I point launchd invocations of pg_ctl to the correct postgres data dir? If you look at the plist that macports installed, you'll see that it uses a wrapper script to launch the postgres server process. That script will default to using the environment variable $POSTGRESQL84DATA for the data dir (and fall back on the one you show that you're using). It's very likely that you have $POSTGRESQL84DATA set, and you don't want it set. -- Daniel J. Luke ++ | * dl...@geeklair.net * | | *-- http://www.geeklair.net -* | ++ | Opinions expressed are mine and do not necessarily | | reflect the opinions of my employer. | ++ ___ macports-users mailing list macports-users@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macports-users
Re: postgres launch daemon not working
Hi Daniel, It works! Details follow below. On Jan 31, 2012, at 1:13 PM, Daniel J. Luke wrote: On Jan 31, 2012, at 2:52 PM, Scott Frankel wrote: % sudo su postgres -c /opt/local/lib/postgresql84/bin/pg_ctl -D /opt/local/var/postgresql84/defaultdb -l /opt/local/var/postgresql84/defaultdb/data/logfile.txt start Jan 31 08:29:07 tiento com.apple.SystemStarter[53]: pg_ctl: could not open PID file /Library/PostgreSQL8/data/postmaster.pid: Permission denied Jan 31 08:29:08 tiento SystemStarter[53]: PostgreSQL database server (90) did not complete successfully This looks like you are pointing to a different directory than the one you set up when you installed postgresql84-server (and also a different one than the one you're pointed to when you manually start postgres). That's exactly what I was trying to explain in my last email. I'm doing nothing explicit to point to the /Library/PostgreSQL8/ directory. Looks like pg_ctl is trying to open a postmaster.pid file it doesn't have permissions for. How can I point launchd invocations of pg_ctl to the correct postgres data dir? If you look at the plist that macports installed, you'll see that it uses a wrapper script to launch the postgres server process. That script will default to using the environment variable $POSTGRESQL84DATA for the data dir (and fall back on the one you show that you're using). It's very likely that you have $POSTGRESQL84DATA set, and you don't want it set. Looks like that env var gets set directly in the wrapper. Thanks for pointing to the script! A quick edit of the script's paths and now the server starts on reboot! Thanks! Scott -- Daniel J. Luke ++ | * dl...@geeklair.net * | | *-- http://www.geeklair.net -* | ++ | Opinions expressed are mine and do not necessarily | | reflect the opinions of my employer. | ++ ___ macports-users mailing list macports-users@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macports-users
Re: postgres launch daemon not working
On Tue, Jan 31, 2012 at 04:47:09PM -0800, Scott Frankel wrote: On Jan 31, 2012, at 12:34 PM, Ryan Schmidt wrote: It should not have caused a problem, though it was also unnecessary to create your own postgres user, since that (along with creating the server directories, and the launchd plist) is the purpose of installing the postgresql*-server ports. Good to know. How would I have been able to find that out myself? Knowing that ahead of time would've saved me significant effort. It probably wouldn't hurt if the postgresql*-server ports had a more descriptive description... Dan -- Dan R. K. Ports MIT CSAILhttp://drkp.net/ ___ macports-users mailing list macports-users@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macports-users
Re: postgres launch daemon not working
That'd be great! Happy to contribute to the effort if I can. Thanks Scott On Jan 31, 2012, at 7:13 PM, Dan Ports wrote: On Tue, Jan 31, 2012 at 04:47:09PM -0800, Scott Frankel wrote: On Jan 31, 2012, at 12:34 PM, Ryan Schmidt wrote: It should not have caused a problem, though it was also unnecessary to create your own postgres user, since that (along with creating the server directories, and the launchd plist) is the purpose of installing the postgresql*-server ports. Good to know. How would I have been able to find that out myself? Knowing that ahead of time would've saved me significant effort. It probably wouldn't hurt if the postgresql*-server ports had a more descriptive description... Dan -- Dan R. K. Ports MIT CSAILhttp://drkp.net/ ___ macports-users mailing list macports-users@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macports-users