<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>The Napkin ~ A Blog By Highgroove Studios comments on Howto: PostgreSQL on Leopard gotchas</title>
    <link>http://napkin.highgroove.com/</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>The Napkin ~ A Blog By Highgroove Studios comments</description>
    <item>
      <title>"Howto: PostgreSQL on Leopard gotchas" by andre</title>
      <description>&lt;p&gt;For a recent Rails project, I had to use PostgreSQL instead of the standard MySQL for the database. Setting up Postgres on Mac OS 10.5 has some quirks, which I will share with you here.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There are three primary ways to get PostGRES onto Leopard: &lt;a href="http://www.postgresqlformac.com/"&gt;a pre-built binary&lt;/a&gt;, MacPorts, and &lt;a href="http://www.postgresql.org/ftp/source/v8.2.6/"&gt;source&lt;/a&gt;. My choice was to build with source. There are several good posts on building from source:
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.stiefels.net/2007/11/22/building-postgresql-on-leopard/"&gt;stiefels.net&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://developer.apple.com/internet/opensource/postgres.html"&gt;developer.apple.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://brilliantcorners.org/node/84-getting-postgresql-running-for-rails-on-a-mac"&gt;brilliantcorners.org&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://forums.realsoftware.com/viewtopic.php?t=16418&amp;amp;view=previous"&gt;forums.realsoftwrae.com&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I do not recommend creating a separate user to run postgres. Doing so clutters your startup screen with another user, and requires you to su to that user to start the database. Instead:&lt;/p&gt;

&lt;p&gt;1) install Postgres as root &lt;/p&gt;

&lt;p&gt;2) after install, from the command line: chown -R andre /usr/local/pgsql/data. The -r flag changes the ownership recursively. Obviously, substitute your own username for "andre" in the example.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Since I don't use PostGres all the time, I don't want it to be started up automatically. Instead, I set up two aliases in by .bashrc:&lt;/p&gt;

&lt;p&gt;alias startpostgres='/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/data/logfile start'
alias stoppostgres='/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/data/logfile stop'&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;when you start postgres, you'll probably get the dreaded "shared memory error," which looks like this:&lt;/p&gt;

&lt;p&gt;FATAL: could not create shared memory segment: Cannot allocate memory
DETAIL: Failed system call was shmget(key=1, size=1081344, 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 1081344 bytes), reduce PostgreSQL's shared&lt;em&gt;buffers parameter (currently 50) and/or its max&lt;/em&gt;connections parameter (currently 10).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;some resources will tell you to edit the /etc/rc file, which is &lt;em&gt;incorrect&lt;/em&gt; for Leopard. Instead, create &lt;code&gt;/etc/sysctl.conf&lt;/code&gt; (if it does not already exist -- mine didn't), and add the following lines:&lt;/p&gt;

&lt;p&gt;kern.sysv.shmmax=167772160
kern.sysv.shmmin=1
kern.sysv.shmmni=32
kern.sysv.shmseg=8
kern.sysv.shmall=65536 &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You'll need to su to root to create &lt;code&gt;/etc/rc&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Have fun with Postgres!&lt;/p&gt;

</description>
      <pubDate>Wed, 16 Jan 2008 18:51:00 EST</pubDate>
      <guid>&lt;a href="/articles/2008/01/16/howto-postgresql-on-leopard-gotchas"&gt;Howto: PostgreSQL on Leopard gotchas&lt;/a&gt;</guid>
      <link>&lt;a href="/articles/2008/01/16/howto-postgresql-on-leopard-gotchas"&gt;Howto: PostgreSQL on Leopard gotchas&lt;/a&gt;</link>
    </item>
  </channel>
</rss>
