forked from mongodb/docs-cluster-to-cluster-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnamespace-remapping.txt
139 lines (101 loc) · 3.13 KB
/
namespace-remapping.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
.. _c2c-beta-namespace-remapping:
=====================
Change Database Names
=====================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 2
:class: singlecol
.. include:: /includes/beta-feature
Starting in ``mongosync`` beta 1.8, you can remap database names during sync.
This allows you to take data in one database on the source cluster and migrate
it into a different database on the destination cluster.
Syntax
------
The :ref:`/start <c2c-api-start>` API endpoint accepts an optional ``namespaceRemap``
parameter with the following syntax:
.. code-block:: sh
curl <host>:<port>/api/v1/start -XPOST \
--data '
{
"source": "cluster0",
"destination": "cluster1"
"namespaceRemap": [
{
"from": {
"database": "<source-database>"
},
"to": {
"database": "<destination-database>"
}
}
]
} '
Parameter Fields
----------------
.. list-table::
:header-rows: 1
:stub-columns: 1
:widths: 20 13 13 54
* - Field
- Type
- Required
- Description
* - ``namespaceRemap``
- array
- Optional
- Array of documents that specify namespace changes to make during sync.
.. versionadded:: 1.8 Beta
* - ``namespaceRemap[n].`` ``from``
- document
- Required
- Document that specifies the database on the source cluster
to migrate from in the remapping operation.
.. versionadded:: 1.8 Beta
* - ``namespaceRemap[n].`` ``from.database``
- string
- Required
- Database to migrate from on the source cluster.
.. versionadded:: 1.8 Beta
* - ``namespaceRemap[n].`` ``to``
- document
- Required
- Document that specifies the database on the destination cluster
to migrate to in the remapping operation.
.. versionadded:: 1.8 Beta
* - ``namespaceRemap[n].`` ``to.database``
- string
- Required
- Database to migrate to on the destination cluster.
.. versionadded:: 1.8 Beta
Behavior
--------
Valid Namespace Remapping
~~~~~~~~~~~~~~~~~~~~~~~~~
.. include:: /includes/fact-valid-namespace-remap
Steps
-----
.. procedure::
:style: normal
.. step:: Connect the source and destination clusters
The following example connects a source cluster (``cluster0``)
with a destination cluster (``cluster1``):
.. code-block:: shell
mongosync \
--cluster0 "mongodb://localhost:27000" \
--cluster1 "mongodb://localhost:35000"
.. step:: Sync the clusters with namespace remapping
The following :ref:`/start <c2c-api-start>` call starts sync and remaps the
``accounts`` database on the source cluster to
``sales`` database on the destination cluster:
.. literalinclude:: /includes/api/requests/start-namespace-remap.sh
:language: shell
Example response:
.. literalinclude:: /includes/api/responses/success.json
:language: json
:copyable: false
Learn More
----------
- :ref:`/start <c2c-api-start>`