mirror of https://gitee.com/bigwinds/arangodb
38 lines
1.6 KiB
Plaintext
38 lines
1.6 KiB
Plaintext
!CHAPTER Syncing Collections
|
|
|
|
In order to synchronize data for a single collection from a master to a slave instance, there
|
|
is the *syncCollection* function:
|
|
|
|
It will fetch all documents of the specified collection from the master database and store
|
|
them in the local instance. After the synchronization, the collection data on the slave will be
|
|
identical to the data on the master, provided no further data changes happen on the master.
|
|
Any data changes that are performed on the master after the synchronization was started will
|
|
not be captured by *syncCollection*, but need to be replicated using the regular replication
|
|
applier mechanism.
|
|
|
|
For the following example setup, we'll use the instance *tcp://master.domain.org:8529* as the
|
|
master, and the instance *tcp://slave.domain.org:8530* as a slave.
|
|
|
|
The goal is to have all data from the collection *test* in database *_system* on master
|
|
*tcp://master.domain.org:8529* be replicated to the collection *test* in database *_system* on
|
|
the slave *tcp://slave.domain.org:8530*.
|
|
|
|
On the **master**, the collection *test* needs to be present in the *_system* database, with
|
|
any data in it.
|
|
|
|
To transfer this collection to the **slave**, issue the following commands there:
|
|
|
|
```js
|
|
db._useDatabase("_system");
|
|
require("org/arangodb/replication").syncCollection("test", {
|
|
endpoint: "tcp://master.domain.org:8529",
|
|
username: "myuser",
|
|
password: "mypasswd"
|
|
});
|
|
```
|
|
|
|
**Warning**: The syncCollection command will replace the collection's data in the slave database
|
|
with data from the master database! Only execute these commands if you have verified you are on
|
|
the correct server, in the correct database!
|
|
|