|
1 | 1 | .. _c2c-mongosync:
|
2 | 2 |
|
| 3 | +.. default-domain:: mongodb |
| 4 | + |
| 5 | +.. program:: mongosync |
| 6 | + |
3 | 7 | =============
|
4 | 8 | ``mongosync``
|
5 | 9 | =============
|
6 | 10 |
|
7 |
| -.. default-domain:: mongodb |
| 11 | +.. contents:: On this page |
| 12 | + :local: |
| 13 | + :backlinks: none |
| 14 | + :depth: 1 |
| 15 | + :class: singlecol |
| 16 | + |
| 17 | +Description |
| 18 | +----------- |
| 19 | + |
| 20 | +The ``mongosync`` binary is the primary process used in Cluster-to-Cluster Sync. |
| 21 | +It migrates data from one cluster to another and can keep the clusters |
| 22 | +in continuous sync. |
| 23 | + |
| 24 | +This document provides a complete overview of all command-line options. |
| 25 | + |
| 26 | +Options |
| 27 | +------- |
| 28 | + |
| 29 | +Global Options |
| 30 | +~~~~~~~~~~~~~~ |
| 31 | + |
| 32 | +.. option:: --cluster0 <URI> |
| 33 | + |
| 34 | + Sets the :ref:`connection URI <mongodb-uri>` for the first cluster. |
| 35 | + The first cluster can serve as either the source cluster or the destination |
| 36 | + cluster in the sync process. |
| 37 | + |
| 38 | + .. note:: |
| 39 | + |
| 40 | + The cluster must use MongoDB 6.0 or later. |
| 41 | + |
| 42 | + |
| 43 | + For more information on connecting ``mongosync``, see |
| 44 | + :ref:`Connections <c2c-conn-top-level>`. |
| 45 | + |
| 46 | + |
| 47 | +.. option:: --cluster1 <URI> |
| 48 | + |
| 49 | + Sets the :ref:`connection URI <mongodb-uri>` for the second cluster. |
| 50 | + The second cluster can serve as either the source cluster or the destination |
| 51 | + cluster in the sync process. |
| 52 | + |
| 53 | + .. note:: |
| 54 | + |
| 55 | + The cluster must use MongoDB 6.0 or later. |
| 56 | + |
| 57 | + |
| 58 | + For more information on connecting ``mongosync``, see |
| 59 | + :ref:`Connections <c2c-conn-top-level>`. |
| 60 | + |
| 61 | + |
| 62 | +.. option:: --verbosity <level> |
| 63 | + |
| 64 | + *Default*: ``INFO`` |
| 65 | + |
| 66 | + Sets the verbosity level to use in log messages. Cluster-to-Cluster Sync logs |
| 67 | + all messages at the specified level as well as any messages at less severe levels. |
| 68 | + |
| 69 | + The ``--verbosity`` option supports the following values: |
| 70 | + |
| 71 | + - ``TRACE`` |
| 72 | + - ``DEBUG`` |
| 73 | + - ``INFO`` |
| 74 | + - ``WARN`` |
| 75 | + - ``ERROR`` |
| 76 | + - ``FATAL`` |
| 77 | + - ``PANIC`` |
| 78 | + |
| 79 | + |
| 80 | +.. option:: --logPath <DIR> |
| 81 | + |
| 82 | + Sets the path to the log directory. Cluster-to-Cluster Sync writes logs to |
| 83 | + files in this directory. |
| 84 | + |
| 85 | + |
| 86 | +.. option:: --port |
| 87 | + |
| 88 | + *Default*: ``27182`` |
| 89 | + |
| 90 | + Sets the port used by the HTTP server for the Cluster-to-Cluster Sync REST API. |
| 91 | + |
| 92 | + |
| 93 | +.. option:: --id <ID> |
| 94 | + |
| 95 | + Sets an identifier for the ``mongosync`` instance. |
| 96 | + |
| 97 | + Use this option when running multiple instances of ``mongosync`` on a sharded |
| 98 | + cluster, to synchronize the shards individually. The ``--id`` option must |
| 99 | + correspond to the shard ID of the shard it |
| 100 | + syncs. To find the shard ID, use the :dbcommand:`listShards` command. |
| 101 | + |
| 102 | +.. option:: --config <filename> |
| 103 | + |
| 104 | + Sets the path to the configuration file. |
| 105 | + |
| 106 | + For more information, see :ref:`c2c-mongosync-config`. |
| 107 | + |
| 108 | + |
| 109 | +.. option:: --version, -v |
| 110 | + |
| 111 | + Prints ``mongosync`` version information to stdout. |
| 112 | + |
| 113 | + |
| 114 | +.. option:: --help, h |
| 115 | + |
| 116 | + Prints usage information to stdout. |
| 117 | + |
| 118 | + |
| 119 | +Behavior |
| 120 | +-------- |
| 121 | + |
| 122 | +.. _c2c-mongosync-config: |
| 123 | + |
| 124 | +Configuration File |
| 125 | +~~~~~~~~~~~~~~~~~~ |
| 126 | + |
| 127 | +Options for ``mongosync`` can be set in a YAML configuration file, specified |
| 128 | +using the :option:`--config` option. For example: |
| 129 | + |
| 130 | +.. code-block:: yaml |
| 131 | + |
| 132 | + # Cluster Configuration |
| 133 | + cluster0: "mongodb://192.0.2.10:27017,192.0.2.11:27017,192.0.2.12:27017" |
| 134 | + cluster1: "mongodb://192.0.2.20:27017,192.0.2.21:27017,192.0.2.22:27017" |
| 135 | + |
| 136 | + |
| 137 | +Examples |
| 138 | +-------- |
| 139 | + |
| 140 | +#. Deploy a source and a destination cluster. |
| 141 | + |
| 142 | +#. Initialize Cluster-to-Cluster Sync: |
| 143 | + |
| 144 | + .. code-block:: bash |
| 145 | + |
| 146 | + mongosync \ |
| 147 | + --cluster0 'mongodb://192.0.2.10:27017,192.0.2.11:27017,192.0.2.12:27017' \ |
| 148 | + --cluster1 'mongodb://192.0.2.20:27017,192.0.2.21:27017,192.0.2.22:27017' |
| 149 | + |
| 150 | + Use the appropriate connection strings for the :option:`--cluster0` and |
| 151 | + :option:`--cluster1` options so that they can connect to your replica sets. |
| 152 | + |
| 153 | +#. To start the synchronization process, use a REST client such as cURL to send |
| 154 | + the ``start`` command to ``mongosync``: |
| 155 | + |
| 156 | + .. code-block:: bash |
| 157 | + |
| 158 | + curl localhost:27182/api/v1/start -X POST \ |
| 159 | + --data '{ "source": "cluster0", "destination": "cluster1" }' |
| 160 | + |
| 161 | + Example Output: |
| 162 | + |
| 163 | + .. code-block:: json |
| 164 | + :copyable: false |
8 | 165 |
|
9 |
| -Migrate data between clusters using ``mongosync``. |
| 166 | + { "success": true } |
0 commit comments