software:postgresql11 [PaleoEarthLabs wiki]

PaleoEarthLabs wiki

One bucket of limited wisdom

Site Tools


software:postgresql11

PostgreSQL & PostGIS

Installing/upgrading to PostgreSQL version 11.x and PostGIS version 2.5.x on Mac OS X/MacOS Sierra (v10.12)/High Sierra.

This note is in draft stage and currently just a dump of snippets

The reason for a manual installation is that I want to utilise the GDAL framework utilised by QGIS and GMT. This setup naturally collides with Homebrew's setup to install GDAL as part of the dependency framework when installing postgis.

I also use the Python.org's Python Frameworks.

Preparation

So I am leaving the dependencies to homebrew apart from GDAL and Python.

PostgreSQL

The documentation to compile from source is available on the Postgresql.org website

./configure --with-perl --with-uuid=e2fs --with-python --with-libxml  --with-readline \\
    --with-bonjour --prefix=/usr/local/pgsql/11.x/ \\
    --with-libraries=/usr/local/Cellar/readline/x.x.x/:/usr/local/Cellar/ossp-uuid/x.x.x/:/Library/Frameworks/Python.framework/

After an upgrade of the OS it seems that the LaunchDaemon is broken.

On their OpenSource pages Apple provides a template for one of the older included PostgreSQL versions (here: 9.0.4). This deviates a bit from what I used previously for the LaunchDaemon file.

Verbatim copy of org.postgresql.postgres.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>
	<true/>
	<key>Label</key>
	<string>org.postgresql.postgres</string>
	<key>UserName</key>
	<string>_postgres</string>
	<key>GroupName</key>
	<string>_postgres</string>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/bin/postgres</string>
		<string>-D</string>
		<string>/var/pgsql</string>
		<string>-c</string>
		<string>unix_socket_directory=/var/pgsql_socket</string>
		<string>-c</string>
		<string>logging_collector=on</string>
		<string>-c</string>
		<string>log_connections=on</string>
		<string>-c</string>
		<string>log_lock_waits=on</string>
		<string>-c</string>
		<string>log_statement=ddl</string>
		<string>-c</string>
		<string>log_line_prefix=%t </string>
		<string>-c</string>
		<string>listen_addresses=</string>
		<string>-c</string>
		<string>log_directory=/Library/Logs</string>
		<string>-c</string>
		<string>log_filename=PostgreSQL.log</string>
		<string>-c</string>
		<string>unix_socket_group=_postgres</string>
		<string>-c</string>
		<string>unix_socket_permissions=0770</string>
	</array>
	<key>OnDemand</key>
	<false/>
</dict>
</plist>

Homebrew's distro uses a slightly different version - here's the excerpt from the postgresql.rb file:

  def plist; <<~EOS
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
      <key>KeepAlive</key>
      <true/>
      <key>Label</key>
      <string>#{plist_name}</string>
      <key>ProgramArguments</key>
      <array>
        <string>#{opt_bin}/postgres</string>
        <string>-D</string>
        <string>#{var}/#{name}</string>
      </array>
      <key>RunAtLoad</key>
      <true/>
      <key>WorkingDirectory</key>
      <string>#{HOMEBREW_PREFIX}</string>
      <key>StandardOutPath</key>
      <string>#{var}/log/#{name}.log</string>
      <key>StandardErrorPath</key>
      <string>#{var}/log/#{name}.log</string>
    </dict>
    </plist>
  EOS
  end

PostGIS

 ./configure --prefix=/usr/local/pgsql/11.x/ --with-projdir=/Library/Frameworks/PROJ.framework/unix/ --with-raster --with-topology --with-pgconfig=/usr/local/pgsql/11.x/bin/pg_config --with-geosconfig=/Library/Frameworks/GEOS.framework/unix/bin/geos-config 
software/postgresql11.txt · Last modified: 2019/12/27 18:08 by christian