You are currently browsing legacy 2.0 version of documentation. Click here to switch to the newest 5.1 version.
Replication walkthrough
Below examples will show you how to quickly setup replication in RavenDB using The Studio.
Replicating documents from one server to another (master-slave)
To setup a master-slave replication we will need at least two servers. First server will serve as a master (in our example the server at port 8081) and second one will be a slave (server at port 8081).
Configuring master server
- Open studio on master server, create new database called
ExampleDB1
and enableReplication bundle
feature.
- Setup replication destination that will point to your slave server (in our example http://localhost:8082/) and enter
ExampleDB2
in Database Name.
- You will notice that two documents will be created, first one is called
Raven/Replication/Destinations
and you will find your replication configuration there, second document is calledRaven/Replication/Destinations/localhost8082databasesExampleDB2
and it has been created because RavenDB detected a problem with replicating documents to slave, which is expected because we haven't configured it yet.
Configuring slave server
- Open studio on slave server, create new database called
ExampleDB2
and enableReplication bundle
feature.
- To setup a slave replication, do not add any replication destinations. Just proceed by clicking
OK
.
- Document
Raven/Replication/Destinations
will be created, you will notice that, in a contrast to master server, it will be empty.
Test
- On a master server (8081) create document
users/1
as seen on a figure below.
- On a slave server (8082), you will notice that document
users/1
has been replicated successfully (this may take few moments).
Replicating documents between servers (master-master)
To setup a master-master replication we will need at least two servers. Both of them (in our example 8081 and 8082) will serve as masters.
Configuring first master server
- Open studio on first master server, create new database called
ExampleDB1
and enableReplication bundle
feature.
- Setup replication destination to your second master server (in our example http://localhost:8082/) and enter
ExampleDB2
in Database Name.
- You will notice that two documents will be created, first one is called
Raven/Replication/Destinations
and you will find your replication configuration there, second document is calledRaven/Replication/Destinations/localhost8082databasesExampleDB2
and it has been created because RavenDB detected a problem with replication documents to our second server, which is expected because we haven't configured it yet.
Configuring second master server
- Open studio on second master server, create new database called
ExampleDB2
and enableReplication bundle
feature.
- Setup replication destination to your first master server (in our example http://localhost:8081/) and enter
ExampleDB1
in Database Name.
Test
- On one of the masters (let's say 8082) create document
albums/1
as seen on a figure below.
- On other master (8081), you will notice that document
albums/1
has been replicated successfully (this may take few moments). Change content of this document and save it (changed album name from 'Raven' to 'Cake').
- Document replicates successfully to 8082.