Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudant and local CouchDB installation 2 way replication

I'm trying to sync a database in a local CouchDB installation (v 1.3.1 on a Mac) and a database on Cloudant with master-master replication.

In my local Futon http://localhost:5984/_utils I've configured Replicator to replicate my local database to Cloudant. Everything works fine replicating from the local database to the Cloudant one, but not backwards. If data changes in the Cloudant's database those changes are not been replicated to my local database.

Local -> Cloudant = works

Cloudant -> Local = doesn't work

Is this possible to be made? Can anyone help?

Thanks!

like image 859
JC Ivancevich Avatar asked Jul 19 '13 14:07

JC Ivancevich


2 Answers

Finally I figured out that I only needed to configure two replications from my local CouchDB.

Here are both replications:

{
    "source":"https://username:[email protected]/cloud_db",
    "target":"http://username:pwd@localhost:5985/local_db"
}

{
    "source":"http://username:pwd@localhost:5985/local_db",
    "target":"https://username:[email protected]/cloud_db"
}

Now, in http://localhost:5984/_utils/status.html there are two replications running.

Note that I added the username and password to the local connection too. That's because you need to be an authorized user in order to replicate design documents.

Thanks a lot Mike, your answer helped a lot!

like image 119
JC Ivancevich Avatar answered Sep 22 '22 14:09

JC Ivancevich


Can you try specifying full URLs for both source and target? I think it would look like:

#create the replicator database for your local server
curl -X PUT 'http://127.0.0.1:5984/_replicator'

then upload this document:

{  
   "source":"https://username:[email protected]/source_db",
   "target":"http://127.0.0.1:5985/target_db"
}

Then you should be able to monitor that by a:

http://127.0.0.1:5984/_active_tasks

If that doesn't work for you, can you please copy/paste:

  • the body of the document in the _replicator database
  • grep the log file for anything with _replication

Also, there's a classic 'gotcha' here, that I think you need 'writer' permissions on both the source and target database. That may seem odd, but it's because the replicator is saving checkpoint documents on both the source and the target so that the next time you ask to replicate, it doesn't have to start from scratch.

like image 21
Mike Miller Avatar answered Sep 20 '22 14:09

Mike Miller