Wednesday, June 25, 2008

PgPool

I wasn't really up to date on high availability solutions for postgres. From browsing around it looked like pgpool provided a reasonable solution to the problem. So I went ahead and installed postgres on my ubuntu server and on my desktop machine (running windows, yuk I know).

While the pgpool config is fairly simple, it did take me some time to get it running correctly. Replication mode just didnt want to work at first and pgpool doesnt log anything, unless you start it with '-d -n' so it doesnt detach from the terminal.
The debug output showed a mismatch in a reply packet from the 2 postgres servers.. the cause was a slight difference in pg_hba.conf. Once fixed, the replication worked.

Next up was testing the high availability.. I stopped 1 postgres server, which caused my psql client to block.. seems like the default config on ubuntu didnt set the health check interval, so pgpool never noticed the server was down. After entering a reasonable value, pgpool detected the node as down and aborted/disconnected the psql connection.

This also means that an app has to reestablish the link itself, hence needs to be aware of this. The thing that bugged me though, was that changes done while 1 node is down, go unnoticed if you bring the node back up.. meaning there is no sync or even detection that both nodes are different, resulting in different results depending on which node your query gets executed. Maybe this is configurable? Something to check out another time.

Wednesday, June 18, 2008

Firefox 3 local weave repository

Here's how I setup Weave to use my own server to sync, as registration at mozilla is disabled atm. Weave uses DAV to store the data, so all it takes is to configure apache with DAV support.

Enable DAV on apache:

$ sudo a2enmod dav_fs dav dav_lock

Weave will store the data at http://server/user/sha1hash-of-user

$ sudo mkdir /var/www/user
$ sudo chown www-data:www-data /var/www/user

Edit /etc/apache2/httpd.conf and put something like this in it:


<Directory "/var/www/user">
Dav On
AuthName "WebDAV Login"
AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
require valid-user
Order allow,deny
Allow from all
Options +Indexes
</Directory>


Create the password file with:

$ sudo htpasswd -m -c /etc/apache2/.htpasswd emailaddress

Where the email address is the one you use in the Weave preferences.

Restart apache and then configure Weave. Make sure you change the server location in the Advanced tab to point to the root of your server (http://server/)

NOTE: don't enable forms/password sync, it appears to be broken.. weave will get stuck in a busy loop when it tries to sync with those enabled.

Firefox 3: AwesomeBar... no it's not!

To make it just a tad less annoying, change browser.urlbar.matchOnlyTyped to true in about:config.

Firefox 3 <=> Google Browsersync

Recently upgraded my laptop to Ubuntu 8.04, which comes with Firefox 3. Which isnt too bad, weren't it for the fact that Google decided to discontinue their browsersync extension. I've gotten so used to that extension that I really don't want to give up on the features it provided.

My initial reaction was to use firefox2, which is also available on Hardy Heron. The only problem with that is, once you have started firefox3, your profile will have been converted to a format that messes up addons in firefox2.. so no extension works anymore on ff2. There are some solutions on the web, but those involve deleting your old profile directory.. something I didn't want to do as I'd have to reinstall all the plugins again.

That left me looking for alternatives...

A popular one is foxmarks.. however it only does bookmark syncs, whereas Google Browsersync also did history, cookies and passwords. It does look like a nice addon, but didn't have everything I needed.

Next stop.. Mozilla Weave.. it's early in the development, but that doesn't scare me too much.. unfortunately the signup page has been disabled. It does however look like the best option feature wise and it'll probably become the defacto sync tool, meaning the other external ones will probably become obsolete anyway.

So... I downloaded the addon and had a look at the code. The webserver storage part is done with standard DAV access, figured I might be able to set something up on my own server... I was right.

I'll describe the setup in a next post...

Starting a Blog

Finally took the time to start a Blog.. Hardest part was finding a name that wasn't taken tbh. Since this is a blank slate to dump thoughts on, I figured the POKE 1,52 wasnt too bad.. as I'll probably write about technical stuff..

I'm sure the C=64 crowd gets the name :-)