Ok, so I wanted to see how easy it was to try and get a cluster of CouchDBs up on my Slicehost server running on Ubuntu Jaunty and here's what I humbly did (following much of this article:
I wrote a a few ini files opened on some ports (6002,6004..etc):
e.g. couch_A.ini
[couchdb]
database_dir = /tmp/couch_A
[httpd]
port = 6002
and couch_B, couch_C.
To do this, I ssh in to my server and ran screen and opened up a couple screens, issuing:
sudo couchdb -a /usr/local/etc/couchdb/couch_x.ini
You could do it with a '&' I guess, but I just ran that and detached the screen using Ctrl+A/D. (if you need a refresh on screen, try the docs at GNU)
Now that the couches are running, I went on to my Slicehost and set up 2 new records couchA.domain.com, couchB.domain.com for testing purposes. Next I went to my Nginx 'sites-enabled' folder and setup a conf file:
upstream couches_cluster {
server localhost:6004;
server localhost:6006;
server localhost:6008;
}
server {
listen 80;
server_name deyta.northpole.sg;
location / {
proxy_pass http://couches_cluster;
proxy_next_upstream error;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Once that's done I just restart Nginx:
sudo /etc/init.d/nginx restart
I logged on to my Futons at couchA.domain.com and did a test insert of database and followed up with couchB which I setup on a seperate Nginx conf to proxy_pass from couchB.domain.com (hence the extra site for testing). Then:
curl -X POST http://localhost:6002/_replicate \
-d '{"source":"my_database", "target":"http://localhost:6004/my_database",
"continuous":true}'
and so forth as instructed from karmi's article mentioned at the start to hook them up. Once that continuous replication is setup, adding something to couch A, I see from couch B's screen:
[info] [<0.1566.0>] recording a checkpoint for my_database ->
http://localhost:6004/my_database/ at source update_seq 1
And true enough checking couch B from Futon confirms the replication! Coolness!
You can see the results of the tests at:
http://deyta.northpole.sg/_utils/index.html (couch cluster, default to A, I needed a node1 to distinguish that)
and
http://deyta2.northpole.sg/_utils/index.html (couchB single serving)
Just ignore the prompt from CouchDB's built in auth and click on my_database and view the single document there.
I didn't believe it's really so simple until I gave it a go. Awesome.
Nice, that's some elite stuff. I'm going to have to catch up with you on this!