Postgres built by hand
I build postgres 8.4.2 by hand with a typical CMMI:
For this application I didn't need Perl or Python or other stored procedures and options. I probably should have added a couple others like:
It installed in the default location, /usr/local/pgsql.
Then followed the install guides about creating a 'postgres' user, a data dir, changing ownerships, running initd.
I had to increase some kernel values to get initdb to run; in /etc/sysctl.conf:
kern.sysv.shmmin=1 kern.sysv.shmmni=32 kern.sysv.shmseg=8 kern.sysv.shmall=65536 kern.sysv.shmmax=16777216
In order to avoid rebooting, I set these on the live system by using the command:
sudo sysctl -w $VARIABLE=$VALUE
for each variable and value above.
I'm an old FreeBSD/SunOS/Solaris/Linux UNIX guy and launchd is new to me. I eventually pieced together this startup file for OS X. In /Library/LaunchDaemons/org.postgresql.postmaster.plist:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Disabled</key> <false/> <key>Label</key> <string>org.postgresql.postmaster</string> <key>ProgramArguments</key> <array> <string>/usr/local/pgsql/bin/postgres</string> <string>-D/usr/local/pgsql/data</string> <string>--logging_collector=YES</string> <string>--log_connections=on</string> <string>--log_directory=/usr/local/pgsql/log</string> <string>--log_filename=postgres_%Y-%m-%d_%H:%M.log</string> <string>--log_rotation_size=1024</string> </array> <key>RunAtLoad</key> <true/> <key>UserName</key> <string>postgres</string> <key>KeepAlive</key> <dict> <key>SuccessfulExit</key> <false/> </dict> </dict> </plist>
In the above I have it logging to a datetime-stamped file which rotates after it gets to be 1MB in size. Remember to create that log dir and make it writable by your postgres user.
Load and go
To get the system to know about it, load it:
sudo launchctl load /Library/LaunchDaemons/org.postgresql.postmaster.plist
It should start automatically. If you've got problems (e.g., bad option switches), it won't start; check /var/log/system.log for complaints.
To stop it, use the label name you gave it in the .plist file (which for sanity, should be the same as the plist file itself, sans suffix):
sudo launchctl stop org.postgresql.postmaster