Cloudant and local CouchDB installation 2 way replication
Asked Answered
M

2

6

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!

Montpelier answered 19/7, 2013 at 14:44 Comment(1)
Did you try creating the replication tasks on cloudant rather than on your local CouchDB? Cloudant's replicator usually works better...Genesisgenet
M
5

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!

Montpelier answered 19/7, 2013 at 23:28 Comment(0)
P
4

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.

Procto answered 19/7, 2013 at 15:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.