Installing postgres & postgis
Upcoming SlideShare
Loading in...5
×
 

Installing postgres & postgis

on

  • 2,360 views

Mostly on a Mac, but also on Linux & Windows, with some helpful suggestions from the audience (Postgrespalooza 11/20/2012)

Mostly on a Mac, but also on Linux & Windows, with some helpful suggestions from the audience (Postgrespalooza 11/20/2012)

Statistics

Views

Total Views
2,360
Slideshare-icon Views on SlideShare
2,360
Embed Views
0

Actions

Likes
0
Downloads
17
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • Had a first pass, spent quite a few hours working this out, got up to 9.1 + 2.0.1\n\nFor this talk, walked up to 9.2, checked what status is now\n\nExpert on UNIX sysadm & databases, but not on postgres\n
  • As to databases, have used a lot. \nFor open source, have like violins: SQLite, MySQL, Postgres\nPostgres 9.2 has JS internally, so with node.js can run js on client, server, & database. Sweet.\n20\nHad previously installed 9.1. On an iMac with 20GB memory.\n
  • No postgis extension!\nTried copying the postgis-2.0 to /Library/PostgreSQL/9.2/lib, didn’t help\nUsed pg_config to figure out that $libdir was /Library/PostgreSQL/9.2/lib\nIs server needed for 9.2?\nWhy can’t it find postgis-2.0 in $libdir when it is there\n\n\n\n
  • \n
  • \n
  • There are lots postGIS dependences listed there:\n\n
  • \n
  • http://tedwise.com/2010/08/28/homebrew-vs-macports/\n\nFink puts stuff in /sw; have used a lot; didn't want to talk to me just now: pdb.finkproject.org\n\nthere is also http://www.pkgsrc.org/\n\n\n\n\n\n\n\n
  • \n
  • Problem is that it doesn’t hook stuff up, so have to have apache setup, launchd, and so on.\nFortunately enterprisedb does all this\n\n7412 lines later on the postgis2 upgrade! :)\n\nInstalls files in /opt/local/var/macports and various sub directories of this\n\nNow at 9.1 + 2.0.1, want to go to 9.2 + 2.0.1!\n-- so we have javascript!\n\n \n\n\n\n\n
  • \n
  • Port installs a program called daemondo wrappers the package in a way that works well with mac's launchd.\n\nNot needed for postgres since there is only one command, portmaster, to be run\n\nnot needed for postgis, since that installs as an extension within postgres\n\nso replaced call to daemondo with direct call on postmaster, less kruft\n\non first install, use port install package name, on subsequent should use port upgrade package name(s)\n\n\n\n\n\n\n
  • \n
  • \n
  • \n
  • Ubuntu software center & postgres\n\napparnetly you have to sudo to run a run command, using own passowrd!\n\nadding in apache & also phpPgAdmin\n\ndownloaded postgres & sudo'd & ran the .run file\n\ndid apt-get postgis\n\nrebuild from source ran into lots of missing pieces, i.e. xml-config\n\nhttp://linfiniti.com/2012/05/installing-postgis-2-0-on-ubuntu\n\nTrick was to go back to 9.1, then load in\nThen, load in tricks for 9.1\npushed to 9.2, but wroking on Mac\n\n
  • \n\n\n
  • A lot, ran into a series of fails on the compile, finally just gave up\nOne problem is that some tools not careful about where they litter: copies of “createdb" in /usr/local a major problem: always check tools & fix in the .profile\nThe configure broke: \n\nhad trouble with the createdb -- but still seems to have worked! as a postgis_template database had come into existence\nused scripts/launchpgadmin.sh to kick off a pgAdmin shell; preferred sudo\nbrought parallls up to rev\nfixed PGPORT using variable (& pgpass) to 5432 (had been thinking it was 5433 -- this was all the low level tools, as psql)\nadded show_system =- true to get phpPgAdmin to work\nahd a lot of trouble with wronge createdb, until realize had to fix paths: see pg_env.sh & . include that\nselect postgis_full_version(); - in a database to check\n\n\nselect oid, datname, datistemplate from pg_database;\ndrop database template_postgis2\n\nattempt to recompile from source died on some error messages about xml config, some more in the works\n-- tried various sources, but got things like createdb failures\n-- instructions basically require two things: 1) build from source all the way up 2) know what you are doing. Don't mind one, but two is a killer\n\nfigured I'd just ask Jim & Bruce\n\nCould have used a "these are the big pieces" cheat sheet; may even exist\n\nA lot of libraries have to be compiled into the tree; could walk up from ground but just poking at the problem is an issue.\n\n\n\n\n\n
  • \n
  • Downloaded 9.1 & installed\nFound 9.2 already had postgis 2.0! Great -- one strategy is just to wait!\nBecause had already installed 9.1, was using port 5433 for postgres 9.2\nSo had to fix the phppgadmin/conf/config.inc.php file, to have it go to port 5433\nAfter a bit of futzing with the permissions, was up\nRan select version()\n\n\n\n
  • \n
  • PostGIS+JSON+Maps+Open+source\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • And if you are prepping a demo for others:\n1) make it standalone\n2) test soup to nuts\n
  • \n

Installing postgres & postgis Installing postgres & postgis Presentation Transcript

  • Installing Postgres & Postgis Mostly on a Mac, but also on Linux & Windows John Ashmead
  • Why? •Building a mapping website! •Wanted Postgres 9.2 to go pure Javascript: client, server (node.js), & database!! •And wanted latest & greatest mapping Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Objective •Postgres 9.2! •Postgis 2.0 http://www.postgis.org/! •psql, pgAdmin3, & phpPgAdmin! •Node.js! •PL/Javascript Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Stack Builder Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Strategies •EnterpriseDB - provides Stack Builder not currently current, but good starting point! •DMGs - not always current, but good intel! •Open source: fink, homebrew, macports - can be hacked, instructive Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • EnterpriseDB % sudo vi /etc/sysctl.conf ! On a MacBook Pro with 2GB of RAM, the author's sysctl.conf contains: ! kern.sysv.shmmax=1610612736 kern.sysv.shmall=393216 kern.sysv.shmmin=1 kern.sysv.shmmni=32 kern.sysv.shmseg=8 kern.maxprocperuid=512 kern.maxproc=2048 Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Kyngchaos •Stackbuilder! •Not quite current: when did first, was Postgres 9.1, PostGIS 1.5. (Now is 9.1, but 2.0.0)! •But lots of good information, i.e. PostGIS has lots of dependencies: geos, proj4, some others Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Xcode Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Open source packagers •Fink - precompiled binaries preferred. Not as up to date. Not current enough.! •Homebrew - easier to use. On github. Uses ruby. Less intrusive. Assumes single user.! •Macports - tends to pull a lot of stuff down. Possibly more general. Used here. http:// www.macports.org/ Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Portfiles https://trac.macports.org/browser/trunk/dports/databases/ postgis2/Portfile variant postgresql92 description {Builds with postgresql 9.2} conflicts postgresql90 postgresql91 { depends_lib-append port:postgresql92 archcheck.files-append lib/postgresql92/libpq.dylib configure.args-append --libdir=${prefix}/lib/postgresql92 --with-pgconfig=${prefix}/lib/ postgresql92/bin/pg_config build.args-append PGSQL_DOCDIR=${destroot}${prefix}/ share/doc/postgresql91 PGSQL_MANDIR=${destroot}${prefix}/ share/man } ! Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Port commands port list > /dev/null Warning: port definitions are more than two weeks old, consider using selfupdate port selfupdate [ port upgrade postgresql92 skipped ] port -v install postgresql91 +perl +tcl +python port -v install postgresql91-doc port install pgAdmin3 +postgresql91 +with_postgresql91 port install postgis2 +postgresql91 +raster +gui +topology Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Daemondo <key>ProgramArguments</key> <array> <string>/opt/local/bin/daemondo</string> <string>--label=vm-pop3d</string> <string>--start-cmd</string> <string>/opt/local/sbin/vm-pop3d</string> <string>-d</string> <string>10</string> <string>-t</string> <string>600</string> <string>;</string> </array> Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Launch Daemons Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Processes 507 7714 1 0 5:22PM ?? 0:00.04 /Library/ PostgreSQL/9.2/bin/postmaster -D/Library/PostgreSQL/9.2/data 507 7715 7714 0 5:22PM ?? 0:00.00 postgres: logger process 507 7717 7714 0 5:22PM ?? 0:00.01 postgres: checkpointer process 507 7718 7714 0 5:22PM ?? 0:00.05 postgres: writer process 507 7719 7714 0 5:22PM ?? 0:00.03 postgres: wal writer process 507 7720 7714 0 5:22PM ?? 0:00.05 postgres: autovacuum launcher process 507 7721 7714 0 5:22PM ?? 0:00.07 postgres: stats collector process ~ Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Profile variables vi .profile # to change back to Postgres 9.1, fix path & set PGPORT to 5432, export PATH=".:/opt/local/lib/postgresql92/bin:/Library/ PostgreSQL/9.2/bin:$PATH” ! export PGDATABASE=talkinvite export PGUSER=talkinvite export PGPORT=5433 vi apache/conf/httpd.conf # ServerRoot "/Library/PostgreSQL/EnterpriseDB-ApachePHP/apache" # Listen: Allows you to bind Apache to specific IP addresses and/ # Listen 8081 vi phpPgAdmin/conf/config.inc.php # to change back to Postgres 9.1, fix path & set PGPORT to 5432, // Database port on server (5432 is the PostgreSQL default) // Using 5433 for Postgres 9.2 $conf['servers'][0]['port'] = 5433; Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Verify •Check psql, pgAgent3, pgPhpAdmin (using apache)! •Bounce box, make sure it comes back! •Hand save some simple maps, then recover Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Linux/Parallels Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Pre-Requisites for PostGIS •Obvious ones (database, compiler, …)! •PROJ4 - makes round things flat! •GEOS - “fairly safe to upgrade”! •LibXML2 - what may have broken! •JSON-C - JSON support for GEO! •GDAL - raster support Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Of the 36 strategies, running away is the best •Loaded in Postgres 9.1, PostGIS 1.5! •Tried upgrade to postGIS 2.0 using various tricks on web. Kept hitting failures, missing bits & so on, dead parrots from previous runs, ! •Ask Bruce & Jim Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Windows/ VMWare Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Download latest Fixed www/phppgadmin/conf/config.inc.php to use port 5433 Ran “select version()” to get: select postgis_full_version() -> POSTGIS="2.0.1 r9979" GEOS="3.3.5-CAPI-1.7.5" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.9.1, released 2012/05/15" LIBXML="2.7.8" LIBJSON="UNKNOWN" RASTER Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Node.js Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Fun with maps • • • MVC & mapping libraries • A plan, ney, a map • PostGIS Javascript & node Open source maps - MapServer, PostGIS Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Checklist •Software downloads: node, npm, express, … ! •Setup hackable app: my what lovely stack traces we are showing today…! •Verify hackable’s access to postgres! •Find & load in initial spatial data! •Manage spatial data (leaflet)! •Create MVC wrappers for all this GIS goodness Installing Postgres & PostGIS on a Mac - November 20th, 2012 http://www.ashmeadsoftware.com
  • Recommendations (your mileage may vary) •Go with packages, defaults when you can! •If you can’t, build up in layers.! •Trust but verify! •Learn a bit more than you need to; ask around! Installing Postgres & PostGIS on a Mac - November 20th, 2012 •Keep a log http://www.ashmeadsoftware.com