Archive for the 'databases' Category

Database replication

Part of my fabulous new plans for portable gis (which will be revealed soon-ish) involve including a database replication option. This might or might not work on the USB drive, but it needs to be open source, portable, and connect to postgresql at the very least. I have been looking at a couple of options for this, without a vast amount of success, it has to be said.

The packages that I have tried are: Daffodil Replicator, dbreplicator (a fork of daffodil replicator), Symmetric-DS, and db -connector for Funambol. Of these, daffodil and dbreplicator seem like the best bet as they will attempt to do some conflict resolution (eg when the same record is added/altered in both databases). They are also java-based, so should be nicely configurable. Symmetric-DS works well, but doesn’t do conflict resolution, so that kind of rules it out for me. I don’t really know about db-connector for funambol as the documentation that I found was quite out of date and I didn’t get very far with it.

So, daffodil replicator and dbreplicator…

They are quite easy to set up, although the documentation in both cases assumes rather more end-user knowledge than perhaps they should do. Basically you find an appropriate jdbc jar file for your database, grab log4j.jar from somewhere, and tell daffodilreplicator/dbreplicator where to find it, by setting appropriate paths in batch files. Then you start the publication server and set up the details for your “master” database, and then do the same for the subscription server and the “client” database. Both are clever enough to translate between different database types, such as postgresql and mysql, which in some cases would be really handy.

My difficulty with both flavours of the package came when creating the “subscription”, ie telling the client database where to go find the master database. In neither case have I been able to sucessfully set this up, because of various errors. Weirdly, both flavours of the package give me an error in my log file about the first ever subscription that I tried to set up, despite having reinstalled, deleted everything I could find, and started from scratch several times.

The documentation in both cases hasn’t been good enough to resolve my issues, and neither have the forums. Actually, I’m still waiting on dbreplicator, which seems to be a little more active, so I should give them the benefit of the doubt for a couple of days.

I can see a great need for this kind of setup, assuming I can get around these initial teething troubles. So, my question is, has anyone successfully set up any of these packages on windows (sorry, but it needs to be windows at this stage), or does anyone know of any other packages I should try?

If I do manage to get things sorted I’ll post a detailed how-to…

Thursday Tip Day: Running PostgreSQL without making it a service

PostgreSQL from 8.2 onwards can be run easily from the command line in windows, without setting up as a service.

Go to your postgresql/bin folder and at a command line type:

pg_ctl start -D location\of\your\data\folder (as specified in initdb) -l logfile

This should output a notice telling you whether the server has started up correctly. It also saves output to a logfile in the bin folder. If the server starts without incident, open another command window at the same location and type:

psql -d yourdatabase

This will allow you to use PostgreSQL as a command line tool.

To stop the server, type (in your second command window):

pg_ctl stop -D location\of\your\data\folder

Archaeogeek Tumblog

A post from Daily Cup of Tech a while ago inspired me to add a “tumblog” to my site, for short-format posts on tips and tricks. I will be posting to this regularly to build up a library of code snippets, linux and windows tips and archaeological information.

Read more »

Portable GIS redux

This is an idea that seems to come up every so often- what GIS programmes can you run from a USB stick. Well it appears that the list has just got longer. I’m probably the last person to realise it’s possible to do this, but I was really pleased to see that both GRASS and PostgreSQL can now be run from a USB stick, along with QGIS, XAMPP (inc Mapserver, OpenLayers, Tilecache), and FWTools.

Before I go any further, I should state that my aims for creating a portable GIS are not so much having a production GIS setup on a stick, because obviously performance and storage are an issue, but it might be useful for demonstration purposes, and I do feel as if the take up of these opensource tools might be more if they were easier to install and came in one handy package. So what I really want to achieve is a single portable package, probably a zip-file, that can be downloaded and unzipped onto a Window pc (they can learn about the joys of linux once we’ve won them over to the basic concept of opensource). No separate downloads, long installation and configuration processes, just a zip file. I do also like having portable packages on my main computer, as if it breaks it’s a lot easier to reconstruct the setup!

The light-bulb moment for me was when Leif told me that he had seen GRASS working on a USB stick using Msys at the recent CAA conference in Berlin. This intrigued me, so I looked into it and it works quite nicely- as long as you use the same drive letter to mount your USB stick to all the time. I still have to figure out how to figure out the drive letter and change the paths, probably in a batch file. Put simply, you download Mingw and Msys onto the stick, follow the instructions for downloading GRASS, edit the install_grass.bat file to change the drive letters, and off it goes.

PostgreSQL was something I had looked into a while ago, been told it wasn’t possible, and given up on. However, the recent 8.2 release appears to have dropped the requirement for a dedicated non-administrative user to run it. If you download the windows binaries, without the installer, you can set it up whilst logged on as the standard user. When you next run PostgreSQL from a different machine, you just have to use the same username as on your installation pc, regardless of whether that user exists on the pc that you are currently using. Once you have PostgreSQL installed, you can install Postgis into the same directory.

Currently there are a couple of gotchas. Most of these programmes require you to set environment variables, which might not be allowed on the particular pc that you are using, and require some command line experience. I still haven’t quite figured out how to get GRASS to work if I change the drive letter. Also, PostgreSQL does indeed run very slowly on a USB stick. And, I haven’t fully explored this to make sure there isn’t a hidden trap somewhere, or security holes that might be exploited. Having said that, if you want a package that can be unzipped onto a pc with a minimum of fuss then I think it’s almost there.

What’s next? Documentation, as always, and the permission of the various programmers that it’s OK to do this. Oh, and comments please, on what else we might include, or words of wisdom if you’ve already tried it.

Next Page »