Thread: initdb problem
Hello people, Having installed the universal binary for pg 8.2.4 on my mac running 10.3.9, I'm now trying to use the initdb command, but keep running into problems. I can't seem to get the right syntax. Can anyone suggest where I'm going wrong? Here's what terminal shows: Acorn acorn 1 acorn$ login root Password: Last login: Thu Jun 14 13:43:54 on ttyp1 Welcome to Darwin! Acorn:~ root# su postgres shell-init: could not get current directory: getcwd: cannot access parent directories: Permission denied su: /dev/null/.bashrc: Not a directory Acorn:/var/root postgres$ initdb -D /Library/PostgreSQL8/data su: initdb: command not found Acorn:/var/root postgres$ cd chdir: could not get current directory: getcwd: cannot access parent directories: Permission denied su: cd: /dev/null: Not a directory Acorn:/var/root postgres$ cwd su: cwd: command not found Acorn:/var/root postgres$ /Library/PostgreSQL8/initdb -D /Library/PostgreSQL8/data su: /Library/PostgreSQL8/initdb: No such file or directory Acorn:/var/root postgres$ /Library/PostgreSQL8/bin/initdb -D /Library/PostgreSQL8/data could not identify current directory: Permission denied could not identify current directory: Permission denied could not identify current directory: Permission denied The program "postgres" is needed by initdb but was not found in the same directory as "initdb". Check your installation. Acorn:/var/root postgres$ TIA, Joe
No MAC expert but try this when changing to the postgres user: su - postgres the hyphen gives you an environment for the postgres user. J. Herbers Quoting Joe Barwell <jbar@es.co.nz>: > Hello people, > > Having installed the universal binary for pg 8.2.4 on my mac > running 10.3.9, I'm now trying to use the initdb command, > but keep running into problems. I can't seem to get the > right syntax. Can anyone suggest where I'm going wrong? > Here's what terminal shows: > > Acorn acorn 1 acorn$ login root > Password: > Last login: Thu Jun 14 13:43:54 on ttyp1 > Welcome to Darwin! > Acorn:~ root# su postgres > shell-init: could not get current directory: getcwd: cannot > access parent directories: Permission denied > su: /dev/null/.bashrc: Not a directory > Acorn:/var/root postgres$ initdb -D > /Library/PostgreSQL8/data > su: initdb: command not found > Acorn:/var/root postgres$ cd > chdir: could not get current directory: getcwd: cannot > access parent directories: Permission denied > su: cd: /dev/null: Not a directory > Acorn:/var/root postgres$ cwd > su: cwd: command not found > Acorn:/var/root postgres$ /Library/PostgreSQL8/initdb -D > /Library/PostgreSQL8/data > su: /Library/PostgreSQL8/initdb: No such file or directory > Acorn:/var/root postgres$ /Library/PostgreSQL8/bin/initdb -D > /Library/PostgreSQL8/data > could not identify current directory: Permission denied > could not identify current directory: Permission denied > could not identify current directory: Permission denied > The program "postgres" is needed by initdb but was not found > in the > same directory as "initdb". > Check your installation. > Acorn:/var/root postgres$ > > TIA, > > Joe > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend >
I'm guessing all the problems below are something to do with the 'postgres' user not having a correct shell login setup. It looks like the home directory is set to /dev/null which would explain all the "not a directory" errors. You'll need to edit the postgers user to have a proper login shell (/bin/bash maybe?) but I specifically avoid Mac's so that's about all I can tell you. B) Cheers, ~p -----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of James Herbers Sent: Wednesday, 20 June 2007 11:11 To: pgsql-admin@postgresql.org Subject: Re: [ADMIN] initdb problem No MAC expert but try this when changing to the postgres user: su - postgres the hyphen gives you an environment for the postgres user. J. Herbers Quoting Joe Barwell <jbar@es.co.nz>: > Hello people, > > Having installed the universal binary for pg 8.2.4 on my mac > running 10.3.9, I'm now trying to use the initdb command, > but keep running into problems. I can't seem to get the > right syntax. Can anyone suggest where I'm going wrong? > Here's what terminal shows: > > Acorn acorn 1 acorn$ login root > Password: > Last login: Thu Jun 14 13:43:54 on ttyp1 > Welcome to Darwin! > Acorn:~ root# su postgres > shell-init: could not get current directory: getcwd: cannot > access parent directories: Permission denied > su: /dev/null/.bashrc: Not a directory > Acorn:/var/root postgres$ initdb -D > /Library/PostgreSQL8/data > su: initdb: command not found > Acorn:/var/root postgres$ cd > chdir: could not get current directory: getcwd: cannot > access parent directories: Permission denied > su: cd: /dev/null: Not a directory > Acorn:/var/root postgres$ cwd > su: cwd: command not found > Acorn:/var/root postgres$ /Library/PostgreSQL8/initdb -D > /Library/PostgreSQL8/data > su: /Library/PostgreSQL8/initdb: No such file or directory > Acorn:/var/root postgres$ /Library/PostgreSQL8/bin/initdb -D > /Library/PostgreSQL8/data > could not identify current directory: Permission denied > could not identify current directory: Permission denied > could not identify current directory: Permission denied > The program "postgres" is needed by initdb but was not found > in the > same directory as "initdb". > Check your installation. > Acorn:/var/root postgres$ > > TIA, > > Joe > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend > ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly *******************Confidentiality and Privilege Notice******************* The material contained in this message is privileged and confidential to the addressee. If you are not the addressee indicated in this message or responsible for delivery of the message to such person, you may not copy or deliver this message to anyone, and you should destroy it and kindly notify the sender by reply email. Information in this message that does not relate to the official business of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta. Weatherbeeta, its employees, contractors or associates shall not be liable for direct, indirect or consequential loss arising from transmission of this message or any attachments
Seems to be a permissions problem, make sure your /Library/postgreSQL8/ directory is owned by the postgres user. If you installed using binaries as root you have to chown /Library/postgreSQL8/ -R (this is what you do in Linux). Hope that helps. S -----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of James Herbers Sent: Tuesday, June 19, 2007 9:11 PM To: pgsql-admin@postgresql.org Subject: Re: [ADMIN] initdb problem No MAC expert but try this when changing to the postgres user: su - postgres the hyphen gives you an environment for the postgres user. J. Herbers Quoting Joe Barwell <jbar@es.co.nz>: > Hello people, > > Having installed the universal binary for pg 8.2.4 on my mac running > 10.3.9, I'm now trying to use the initdb command, but keep running > into problems. I can't seem to get the right syntax. Can anyone > suggest where I'm going wrong? > Here's what terminal shows: > > Acorn acorn 1 acorn$ login root > Password: > Last login: Thu Jun 14 13:43:54 on ttyp1 Welcome to Darwin! > Acorn:~ root# su postgres > shell-init: could not get current directory: getcwd: cannot access > parent directories: Permission denied > su: /dev/null/.bashrc: Not a directory Acorn:/var/root postgres$ > initdb -D /Library/PostgreSQL8/data > su: initdb: command not found > Acorn:/var/root postgres$ cd > chdir: could not get current directory: getcwd: cannot access parent > directories: Permission denied > su: cd: /dev/null: Not a directory > Acorn:/var/root postgres$ cwd > su: cwd: command not found > Acorn:/var/root postgres$ /Library/PostgreSQL8/initdb -D > /Library/PostgreSQL8/data > su: /Library/PostgreSQL8/initdb: No such file or directory > Acorn:/var/root postgres$ /Library/PostgreSQL8/bin/initdb -D > /Library/PostgreSQL8/data could not identify current directory: > Permission denied could not identify current directory: Permission > denied could not identify current directory: Permission denied The > program "postgres" is needed by initdb but was not found in the same > directory as "initdb". > Check your installation. > Acorn:/var/root postgres$ > > TIA, > > Joe > > ---------------------------(end of > broadcast)--------------------------- > TIP 6: explain analyze is your friend > ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly
Hello People, My thanks to the several people who gave suggestions for how to solve my initdb problem. 1. "Phillip Smith" <phillip.smith@weatherbeeta.com.au> suggested the problems stemmed from: the 'postgres' user not having a correct shell login setup. It looks like the home directory is set to /dev/null which would explain all the "not a directory" errors. You'll need to edit the postgers user to have a proper login shell (/bin/bash maybe?). I had previously been told something along these lines, and so had already given postgres a shell of /bin/bash (using NetInfo Manager). It is only since making that change that I have been able to login as postgres at all. I note, however, that postgres' home is still set to /dev/null, and would be interested in trying to re-set that to something possibly more useful, except I don't know what to use--any suggestions, anyone? 2. "'James Herbers'" <james@herbers.ca> suggested: as root you have to chown /Library/postgreSQL8/ -R (this is what you do in Linux). As shown below, the binary installer for pg 8.2.4 seemed to already set that up correctly: Acorn:/Library/PostgreSQL8 root# ls -l total 0 drwxr-xr-x 27 postgres admin 918 12 Jun 15:19 bin drwx------ 2 postgres admin 68 11 Jun 08:10 data drwxr-xr-x 3 postgres admin 102 12 Jun 15:19 doc drwxr-xr-x 21 postgres admin 714 12 Jun 15:19 include drwxr-xr-x 20 postgres admin 680 12 Jun 15:19 lib drwxr-xr-x 3 postgres admin 102 11 Jun 08:10 log drwxr-xr-x 4 postgres admin 136 12 Jun 15:19 man drwxr-xr-x 3 postgres admin 102 12 Jun 15:19 share James also suggested I should: try this when changing to the postgres user: su - postgres the hyphen gives you an environment for the postgres user. Unfortunately, I either used the wrong syntax, or it doesn't work for some other reason: Acorn:/Library/PostgreSQL8 root# su - postgres su: no directory I wonder whether the above line, and the following, relate to the lack of a home for the postgres user? Acorn:/Library/PostgreSQL8 root# su postgres su: /dev/null/.bashrc: Not a directory 3. Another list member suggested off-list that: If you run the command as `sudo su postgres -c 'initdb'` then it should run the command as the postgres user but not require the postgres account to be a full account, which it requires if you just do su postgres and then run the command seperately... But I got the following: Acorn:/Library/PostgreSQL8 root# sudo su postgres -c 'initdb' su: line 1: initdb: command not found When I tried that again, but as acorn (my username) instead of root, terminal more promisingly said I had to specify the directory. What finally appeared to work, was the following: Acorn acorn 3 acorn$ sudo su postgres -c 'initdb -D /Library/PostgreSQL8/data' This gave me a pid, but looking in Activity Monitor that pid does not appear (nor anything else that looks like pg). I note that the directory /Library/PostgreSQL8/data/ still contains nothing, so for example this fails: pg_ctl start -l logfile -D /Library/PostgreSQL8/data pg_ctl: could not open PID file "/Library/PostgreSQL8/data/postmaster.pid": Permission denied I earlier downladed & installed the Postgres_Startup_Item.pkg, but either initdb didn't really work, or there's some other problem. I guess what I'm asking now is: how do I know if initdb has worked, and what do I do next to start pg? Sorry for the length. Cheers! Joe
My bad - is has the shell, but as you say, the home directory is /dev/null NOW, I must preface this with a warning saying that I have NOT tested this, and do not guarantee that it will work. I found it on a Mac forum and have never tried it, or seen confirmation that it will work. Follow on at your own risk! Apparently Mac stores all it's user info in something called Net Info (not /etc/passwd unless in Single User Mode). To change the home directory of a user (as best I can tell), you would need to execute this at a terminal prompt: niutil -destroyval -u admin . /users/postgres home /dev/null niutil -appendprop -u admin . /users/postgres home /Library/postgreSQL8 Once again, use at your own risk! Do let us know if it worked or not. Cheers, ~p *******************Confidentiality and Privilege Notice******************* The material contained in this message is privileged and confidential to the addressee. If you are not the addressee indicated in this message or responsible for delivery of the message to such person, you may not copy or deliver this message to anyone, and you should destroy it and kindly notify the sender by reply email. Information in this message that does not relate to the official business of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta. Weatherbeeta, its employees, contractors or associates shall not be liable for direct, indirect or consequential loss arising from transmission of this message or any attachments
"Phillip Smith" <phillip.smith@weatherbeeta.com.au> wrote: > My bad - is has the shell, but as you say, the home > directory is /dev/null > > niutil -destroyval -u admin . /users/postgres home > /dev/null niutil -appendprop -u admin . /users/postgres > home /Library/postgreSQL8 > > Once again, use at your own risk! Do let us know if it > worked or not. Hi Phillip, I just used NetInfo Manager itself to make the change. Question is, though: how will I know if it's worked? In my earlier email I said I had been unable to login as postgres until I'd added a shell for that user. In fact I still cannot login as postgres, being refused each time after I try to enter a password--and yes, I did use NetInfo Manager to give postgres a password I knew, seeing as I didn't know the default one. Giving postgres a shell, however, has allowed me to use the form sudo su postgres... When I do this: acorn$ sudo su postgres -c 'pg_ctl start -l logfile -D /Library/PostgreSQL8/data' Password: sh: line 1: logfile: Permission denied server starting terminal seems to say the server has begun, but there is still no sign of the server either in Activity Monitor or in being able to use the pg gui client tools to create a user or a database--both say the server is not active, or not accepting tcp/ip on port 5432. The following, however, makes me suspect it's still a problem with initdb: acorn$ postgres postgres cannot access the server configuration file "/Library/PostgreSQL8/data:/postgresql.conf": No such file or directory Surely initdb should have created the configure file? Cheers! Joe
So did initdb execute without errors after you changed the home directory? It looks like your postgresql.conf file is pointing Postgres to log to a directory / file that the Postgres user doesn't have permission to write to. ~p -----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Joe Barwell Sent: Thursday, 21 June 2007 14:50 To: pgsql-admin@postgresql.org Subject: Re: [ADMIN] initdb problem acorn$ sudo su postgres -c 'pg_ctl start -l logfile -D /Library/PostgreSQL8/data' Password: sh: line 1: logfile: Permission denied server starting acorn$ postgres postgres cannot access the server configuration file "/Library/PostgreSQL8/data:/postgresql.conf": No such file or directory Surely initdb should have created the configure file? *******************Confidentiality and Privilege Notice******************* The material contained in this message is privileged and confidential to the addressee. If you are not the addressee indicated in this message or responsible for delivery of the message to such person, you may not copy or deliver this message to anyone, and you should destroy it and kindly notify the sender by reply email. Information in this message that does not relate to the official business of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta. Weatherbeeta, its employees, contractors or associates shall not be liable for direct, indirect or consequential loss arising from transmission of this message or any attachments
Joe Barwell <jbar@es.co.nz> writes: > The following, however, makes me suspect it's still a > problem with initdb: > acorn$ postgres > postgres cannot access the server configuration file > "/Library/PostgreSQL8/data:/postgresql.conf": No such file > or directory What's that colon doing in the directory name? I think you've probably got a bad value set for PGDATA. regards, tom lane
Hello people, Fixing the postgres user's home may have been an improvement, but now I get problems with the shared memory segment: acorn$ sudo su postgres -c 'initdb -D /Library/PostgreSQL8/data' Password: The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale C. fixing permissions on existing directory /Library/PostgreSQL8/data ... ok creating subdirectories ... ok selecting default max_connections ... 10 selecting default shared_buffers/max_fsm_pages ... 400kB/20000 creating configuration files ... ok creating template1 database in /Library/PostgreSQL8/data/base/1 ... FATAL: could not create shared memory segment: Cannot allocate memory DETAIL: Failed system call was shmget(key=2, size=1646592, 03600). HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory or swap space. To reduce the request size (currently 1646592 bytes), reduce PostgreSQL's shared_buffers parameter (currently 50) and/or its max_connections parameter (currently 10). The PostgreSQL documentation contains more information about shared memory configuration. child process exited with exit code 1 initdb: removing contents of data directory "/Library/PostgreSQL8/data" The pg docs suggest: In OS X 10.3.9 and later, instead of editing /etc/rc you may create a file named /etc/sysctl.conf, containing variable assignments such as kern.sysv.shmmax=4194304 kern.sysv.shmmin=1 kern.sysv.shmmni=32 kern.sysv.shmseg=8 kern.sysv.shmall=1024 This method is better than editing /etc/rc because your changes will be preserved across system updates. Note that all five shared-memory parameters must be set in /etc/sysctl.conf, else the values will be ignored. Beware that recent releases of OS X ignore attempts to set SHMMAX to a value that isn't an exact multiple of 4096. SHMALL is measured in 4 kB pages on this platform. In all OS X versions, you'll need to reboot to make changes in the shared memory parameters take effect. ---- Unfortunately, I got the above error (again) with the initdb command after creating the /etc/sysctl.conf file, using the values suggested above, and then rebooting. Any suggestions? Cheers! Joe
Joe Barwell <jbar@es.co.nz> writes: > Fixing the postgres user's home may have been an > improvement, but now I get problems with the shared memory > segment: Hmm ... Apple's default for SHMMAX is definitely penurious, but it's not so small that PG shouldn't be able to start at all. What do you get from sysctl -a | grep shm ? If it shows shmmax as at least 4 million (as I expect), maybe there's something else already eating shmem --- try also sudo ipcs -a Also, which OSX release is this again? regards, tom lane
Hi Tom, acorn$ sysctl -a | grep shm kern.sysv.shmmax: 4194304 kern.sysv.shmmin: 1 kern.sysv.shmmni: 32 kern.sysv.shmseg: 8 kern.sysv.shmall: 1024 acorn$ sudo ipcs -a Password: sudo: ipcs: command not found > Also, which OSX release is this again? 10.3.9 on a g4. Joe
Joe Barwell <jbar@es.co.nz> writes: > acorn$ sysctl -a | grep shm > kern.sysv.shmmax: 4194304 > kern.sysv.shmmin: 1 > kern.sysv.shmmni: 32 > kern.sysv.shmseg: 8 > kern.sysv.shmall: 1024 OK, so you should be able to do 4MB without problems. > acorn$ sudo ipcs -a > Password: > sudo: ipcs: command not found >> Also, which OSX release is this again? > 10.3.9 on a g4. Ugh. I don't recall exactly when Apple got around to including ipcs, but I guess it wasn't in 10.3.9. Your problem is that you're flying blind because you cannot tell what's going on in shared memory. What I suspect is that there's an unused shared memory segment sitting there (perhaps left over from a failed initdb) and eating a sufficiently large fraction of SHMALL that there's no room for another. If correct, then rebooting should make it go away and let you initdb. Since you haven't got ipcrm either, there's basically no other way to get rid of an unwanted shmem segment :-( You should think about upgrading to 10.4.x btw --- for Postgres admin purposes, having ipcs and ipcrm available is alone worth the price of admission. And it does seem they've improved the OS's performance in various ways too. regards, tom lane
Tom Lane <tgl@sss.pgh.pa.us> wrote: > Ugh. I don't recall exactly when Apple got around to > including ipcs, but I guess it wasn't in 10.3.9. Your > problem is that you're flying blind because you cannot > tell what's going on in shared memory. > > What I suspect is that there's an unused shared memory > segment sitting there (perhaps left over from a failed > initdb) and eating a sufficiently large fraction of SHMALL > that there's no room for another. If correct, then > rebooting should make it go away and let you initdb. Hi Tom, I get the same result trying to initdb after rebooting, the end of which is: fixing permissions on existing directory /Library/PostgreSQL8/data ... ok creating subdirectories ... ok selecting default max_connections ... 10 selecting default shared_buffers/max_fsm_pages ... 400kB/20000 creating configuration files ... ok creating template1 database in /Library/PostgreSQL8/data/base/1 ... FATAL: could not create shared memory segment: Cannot allocate memory DETAIL: Failed system call was shmget(key=2, size=1646592, 03600). HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory or swap space. To reduce the request size (currently 1646592 bytes), reduce PostgreSQL's shared_buffers parameter (currently 50) and/or its max_connections parameter (currently 10). The PostgreSQL documentation contains more information about shared memory configuration. child process exited with exit code 1 initdb: removing contents of data directory "/Library/PostgreSQL8/data" ---- Does the size=1646592 bit mean it's ignoring my /etc/sysctl.conf file? > Since you haven't got ipcrm either, there's basically no > other way to get rid of an unwanted shmem segment :-( > > You should think about upgrading to 10.4.x btw --- for > Postgres admin purposes, having ipcs and ipcrm available > is alone worth the price of admission. And it does seem > they've improved the OS's performance in various ways too. Out of my hands, it's not my computer to upgrade. <shrug> Not even sure if a g4 will run 10.4.x, will it? Cheers! Joe
Joe Barwell <jbar@es.co.nz> writes: > I get the same result trying to initdb after rebooting, the > end of which is: > /Library/PostgreSQL8/data/base/1 ... FATAL: could not > create shared memory segment: Cannot allocate memory > DETAIL: Failed system call was shmget(key=2, size=1646592, > 03600). > HINT: This error usually means that PostgreSQL's request > for a shared memory segment exceeded available memory or > swap space. Hmph. That is definitely not a SHMMAX violation (you get "Invalid argument" for that). AFAIK the only two causes are SHMALL violation (which, since your SHMMAX and SHMALL are effectively the same, means someone is already eating part of SHMALL); or that you actually have not got enough RAM to allocate the shmem segment. Which does not seem real probable, for a mere 1.6MB. So I'm thinking something somewhere is allocating a shmem segment behind your back. Maybe those earlier "failed" attempts actually did install a working Postgres server? You should troll through the "ps" listing carefully. We're really seriously handicapped here by not having ipcs handy :-(. I wonder whether it is available anywhere for 10.3.9? > Does the size=1646592 bit mean it's ignoring my > /etc/sysctl.conf file? Well, the sysctl -a thing prints out the active settings, and they are more than that. > Not even sure if a g4 will run 10.4.x, will it? Certainly. I'm typing on one right now (g4 laptop actually). Heck, I've got 10.4 running on a Cube upstairs. (Well, "run" might be overly kind; the GUI is a bit sluggish due to lack of RAM. But it works perfectly well as a server.) regards, tom lane
Tom Lane wrote: > Joe Barwell <jbar@es.co.nz> writes: >> I get the same result trying to initdb after rebooting, the >> end of which is: >> /Library/PostgreSQL8/data/base/1 ... FATAL: could not >> create shared memory segment: Cannot allocate memory >> DETAIL: Failed system call was shmget(key=2, size=1646592, >> 03600). >> HINT: This error usually means that PostgreSQL's request >> for a shared memory segment exceeded available memory or >> swap space. > > Hmph. That is definitely not a SHMMAX violation (you get "Invalid > argument" for that). AFAIK the only two causes are SHMALL violation > (which, since your SHMMAX and SHMALL are effectively the same, means > someone is already eating part of SHMALL); or that you actually have not > got enough RAM to allocate the shmem segment. Which does not seem real > probable, for a mere 1.6MB. So I'm thinking something somewhere is > allocating a shmem segment behind your back. Maybe those earlier > "failed" attempts actually did install a working Postgres server? > You should troll through the "ps" listing carefully. Doesn't MacOSX install postgresql by default for one of their management services? Joshua D. Drake -- === The PostgreSQL Company: Command Prompt, Inc. === Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 Providing the most comprehensive PostgreSQL solutions since 1997 http://www.commandprompt.com/ Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate PostgreSQL Replication: http://www.commandprompt.com/products/
"Joshua D. Drake" <jd@commandprompt.com> writes: > Doesn't MacOSX install postgresql by default for one of their management > services? Good point --- IIRC, there is a PG 7.3.something embedded in Apple Remote Desktop. I'm not sure whether it starts automatically on boot; I seem to recall a recent thread suggesting that you had to actually do something with ARD to cause it to launch. Still, that could be happening on Joe's machine. Another reason to dig through ps auxww output ... regards, tom lane
Hi Joe, This has got to be the longest thread ever to get PostgreSQL running on the Mac -- but I'm glad you have not given up :). On Jun 21, 2007, at 12:49 AM, Joe Barwell wrote: > acorn$ sudo su postgres -c 'pg_ctl start -l logfile -D > /Library/PostgreSQL8/data' > Password: > sh: line 1: logfile: Permission denied > server starting Since you did not specify the full path for the log file, I assume it is created in the current directory. Check your permissions there. > acorn$ postgres > postgres cannot access the server configuration file > "/Library/PostgreSQL8/data:/postgresql.conf": No such file > or directory > > Surely initdb should have created the configure file? Change to the data directory and see what is there. If you don't see lots of folders along with pg_hba.conf and postgresql.conf, then initdb did not work. At the risk of sending you down another path when you are close, you might want to look at this distribution and instructions: http://www.entropy.ch/software/macosx/postgresql/ If you still don't have initdb working, you might want to rename your postgres user and create a new one as described in these instructions. John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL
John DeSoi <desoi@pgedit.com> wrote: >This has got to be the longest thread ever to get PostgreSQL running on the Mac -- but I'm glad you have not given up :). Hi John, Partly it's because I don't have much time to spend investigating this, partly it's a very positive reflection of the great willingness of so many people on this forum--such as yourself--to help novices like me. Many thanks, all. > acorn$ sudo su postgres -c 'pg_ctl start -l logfile -D > /Library/PostgreSQL8/data' > Password: > sh: line 1: logfile: Permission denied > server starting >Since you did not specify the full path for the log file, I assume it is created in the current directory. Check your permissions there. I tried this: sudo su postgres -c 'pg_ctl start -l /Library/PostgreSQL8/logfile -D /Library/PostgreSQL8/data' and terminal said server starting, & no complaints. I then viewed the logfile (which was created where specified), and it showed: postgres cannot access the server configuration file "/Library/PostgreSQL8/data/postgresql.conf": No such file or directory So I think it's confirming the problem lies with initdb. >Change to the data directory and see what is there. If you don't see lots of folders along with pg_hba.conf and postgresql.conf, then initdb did not work. /data is empty. >At the risk of sending you down another path when you are close, you might want to look at this distribution and instructions: >http://www.entropy.ch/software/macosx/postgresql/ That url says: Versions 8.1.3 and up have been tested and will work on Mac OS X version 10.4/Tiger only. The software is built as Universal Binary and will run natively on PPC and Intel Macs. NOTE: On Mac OS X 10.3 (and possibly later), it seems you have to adjust some system configuration parameters first. The advice there (about putting values in an /etc/rc file) seems to contradict, or possibly be superceded by, the info in the pg docs: <PostgreSQL8/doc/postgresql/html/kernel-resources.html#SYSVIPC> , which states: ---- MacOS X In OS X 10.2 and earlier, edit the file /System/Library/StartupItems/SystemTuning/SystemTuning and change the values in the following commands: sysctl -w kern.sysv.shmmax sysctl -w kern.sysv.shmmin sysctl -w kern.sysv.shmmni sysctl -w kern.sysv.shmseg sysctl -w kern.sysv.shmall In OS X 10.3 and later, these commands have been moved to /etc/rc and must be edited there. Note that /etc/rc is usually overwritten by OS X updates (such as 10.3.6 to 10.3.7) so you should expect to have to redo your editing after each update. In OS X 10.3.9 and later, instead of editing /etc/rc you may create a file named /etc/sysctl.conf, containing variable assignments such as kern.sysv.shmmax=4194304 kern.sysv.shmmin=1 kern.sysv.shmmni=32 kern.sysv.shmseg=8 kern.sysv.shmall=1024 This method is better than editing /etc/rc because your changes will be preserved across system updates. Note that all five shared-memory parameters must be set in /etc/sysctl.conf, else the values will be ignored. Beware that recent releases of OS X ignore attempts to set SHMMAX to a value that isn't an exact multiple of 4096. SHMALL is measured in 4 kB pages on this platform. In all OS X versions, you'll need to reboot to make changes in the shared memory parameters take effect. ---- I'm running 10.3.9, so last week I created the /etc/sysctl.conf file in vi, using the values shown above, rebooted, but still got/get the same problems with initdb. I've just rebooted, & ran the following (a list member advised me off-list to try creating the cluster in a "fresh" dir.): acorn$ sudo mkdir /data Password: acorn$ cd / acorn$ sudo chown postgres:postgres /data acorn$ sudo su postgres -c 'initdb -D /data' The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale C. fixing permissions on existing directory /data ... ok creating subdirectories ... ok selecting default max_connections ... 10 selecting default shared_buffers/max_fsm_pages ... 400kB/20000 creating configuration files ... ok creating template1 database in /data/base/1 ... FATAL: could not create shared memory segment: Cannot allocate memory DETAIL: Failed system call was shmget(key=2, size=1646592, 03600). HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory or swap space. To reduce the request size (currently 1646592 bytes), reduce PostgreSQL's shared_buffers parameter (currently 50) and/or its max_connections parameter (currently 10). The PostgreSQL documentation contains more information about shared memory configuration. child process exited with exit code 1 initdb: removing contents of data directory "/data" Should I uninstall pg 8.2.4 & try with an earlier version, even though the docs. seem to imply 8.2.4 should work with 10.3.9? Cheers! Joe
Tom Lane <tgl@sss.pgh.pa.us> wrote: Joe Barwell <jbar@es.co.nz> writes: > I get the same result trying to initdb after rebooting, the > end of which is: > /Library/PostgreSQL8/data/base/1 ... FATAL: could not > create shared memory segment: Cannot allocate memory > DETAIL: Failed system call was shmget(key=2, size=1646592, > 03600). > HINT: This error usually means that PostgreSQL's request > for a shared memory segment exceeded available memory or > swap space. Hmph. That is definitely not a SHMMAX violation (you get "Invalid argument" for that). AFAIK the only two causes are SHMALL violation (which, since your SHMMAX and SHMALL are effectively the same, means someone is already eating part of SHMALL); or that you actually have not got enough RAM to allocate the shmem segment. Which does not seem real probable, for a mere 1.6MB. So I'm thinking something somewhere is allocating a shmem segment behind your back. Maybe those earlier "failed" attempts actually did install a working Postgres server? You should troll through the "ps" listing carefully. Hello Tom, Um, what's that? You'll need to be pretty specific in giving me instructions about what to do/look at, sorry. If pg (of whatever version) were already running on my machine, surely it would appear in Activity Monitor? What name should I look for there--postgres? I see nothing that looks like that. I have asked here at work about upgrading my machine to 10.4.x, and was advised that when they first tried on a machine like this one (g4 powermac, 400MHz, 640mb sdram), the installer said it would not install. <shrug> I'd say getting my machine upgraded to 10.4.x is not likely to happen in a hurry. Cheers! Joe
Hello people, My initdb problem has been solved (PostgreSQL 8.2.4, Mac OS X 10.3.9). I thought I would post a brief summary, but first I'd like to thank everyone on this list who so kindly and generously made suggestions. I'd particularly like to thank Sean Dooley <srd1@st-andrews.ac.uk>, who assisted me greatly offlist, and whose suggestions eventually provided the solution. Earlier in this thread it was suggested that another, older version of postgres may already be running on my machine, but I believe that not to have been the case. One of Sean's suggestions was to run the following in Terminal: ps -aux | grep post which returned nothing other than itself, whereas run earlier today it shows: postgres 686 0.0 0.2 40484 1284 std- S Fri07AM 0:03.53 /opt/local/lib/postgresql82/bi postgres 689 0.0 0.1 40484 484 ?? Ss Fri07AM 1:00.27 postgres: writer process postgres 690 0.0 0.0 36460 168 ?? Ss Fri07AM 0:07.16 postgres: stats collector proc postgres 1228 0.0 0.4 41092 2804 ?? Ss 7:57AM 0:00.46 postgres: acorn testdb 127.0.0 postgres 1230 0.0 0.4 41092 2428 ?? Ss 7:58AM 0:00.18 postgres: acorn postgres 127.0 acorn 1255 0.0 0.0 8860 120 std R+ 9:56AM 0:00.00 grep post Postgres is also now clearly visible in Activity Monitor (five times, as above). What worked for me was the following: At Sean's suggestion I uninstalled the Postgres 8.2.4 I'd got from the universal binary installer, and instead used macports <http://svn.macosforge.org/repository/macports/downloads/> (NB, requires apple developer tools be already installed) to install postgres: sudo port selfupdate sudo port install postgresql82 sudo port install postgresql82-doc sudo port install postgresql82-server The latter installation handily advised (in Terminal) editing the file /etc/hostconfig by adding the line: POSTGRESQL82-SERVER=-YES- to make postgres server run on startup. I then ran through the following: sudo mkdir -p /opt/local/var/db/postgresql82/defaultdb sudo chown postgres:postgres /opt/local/var/db/postgresql82/defaultdb sudo su postgres -c '/opt/local/lib/postgresql82/bin/initdb -D /opt/local/var/db/postgresql82/defaultdb' which created the cluster. At the end of that Terminal advised using: /opt/local/lib/postgresql82/bin/postgres -D /opt/local/var/db/postgresql82/defaultdb or /opt/local/lib/postgresql82/bin/pg_ctl -D /opt/local/var/db/postgresql82/defaultdb -l logfile start to start the database server, but what actually worked was the following: sudo su postgres -c '/opt/local/lib/postgresql82/bin/pg_ctl -D /opt/local/var/db/postgresql82/defaultdb start' (this fed the log back to Terminal). Beware when trying to specify a logfile location that one chooses a directory to which the postgres user can write--i.e. it may be simpler to use a full path, such as: sudo su postgres -c '/opt/local/lib/postgresql82/bin/pg_ctl -D /opt/local/var/db/postgresql82/defaultdb -l /opt/local/var/db/postgresql82/defaultdb/logfile start' as otherwise the logfile will default to creation in the current directory, for which postgres may not have permissions. Now that I have postgres running I think it best if I soon leave this forum, and join another more suited to the no-doubt many other very basic problems and questions I shall encounter. Thanks again. Cheers! Joe