|
| 1 | +Gather Connection Information |
| 2 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 3 | + |
| 4 | +The source cluster, :setting:`cluster0`, is hosted on the following |
| 5 | +servers and ports: |
| 6 | + |
| 7 | +- ``clusterOne01.fancyCorp.com:20020`` |
| 8 | +- ``clusterOne02.fancyCorp.com:20020`` |
| 9 | +- ``clusterOne03.fancyCorp.com:20020`` |
| 10 | + |
| 11 | +The destination Atlas cluster, :setting:`cluster1`, is hosted on the |
| 12 | +following servers and ports: |
| 13 | + |
| 14 | +- ``cluster2Name-01.abc123.com:27017`` |
| 15 | +- ``cluster2Name-02.abc123.com:27017`` |
| 16 | +- ``cluster2Name-03.abc123.com:27017`` |
| 17 | + |
| 18 | +There is an administrative user, ``clusterAdmin`` configured on each |
| 19 | +cluster with password, ``superSecret``. |
| 20 | + |
| 21 | +Connect the Source and Destination Clusters with ``mongosync`` |
| 22 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 23 | + |
| 24 | +The generic connection string format for the self-managed cluster is: |
| 25 | + |
| 26 | +.. code-block:: shell |
| 27 | +
|
| 28 | + mongodb://<user>:<password>@<ip-address>:<port>,<ip-address>:<port>,<ip-address>:<port> |
| 29 | +
|
| 30 | +The generic connection string format for the Atlas cluster is: |
| 31 | + |
| 32 | +.. code-block:: shell |
| 33 | +
|
| 34 | + mongodb://<user>:<password>@<clusterName>.<hostname>.mongodb.net/ |
| 35 | +
|
| 36 | +Use the connection information you gathered for the self-managed cluster |
| 37 | +to create the connection strings for ``cluster0``: |
| 38 | + |
| 39 | +.. code-block:: text |
| 40 | +
|
| 41 | + cluster0: |
| 42 | + mongodb://clusterAdmin:[email protected]:20020,clusterOne02.fancyCorp.com:20020,clusterOne03.fancyCorp.com:20020 |
| 43 | +
|
| 44 | +You can get the connection string for the Atlas cluster from the Atlas |
| 45 | +UI. To learn more, see :atlas:`Connect to a Database Deployment |
| 46 | +</connect-to-database-deployment/>`. |
| 47 | + |
| 48 | +The ``mongosync`` command layout below is modified for display. To |
| 49 | +connect ``cluster0`` to ``cluster1`` with ``mongosync``, enter the |
| 50 | +following command on one line: |
| 51 | + |
| 52 | +.. code-block:: shell |
| 53 | +
|
| 54 | + mongosync \ |
| 55 | + --cluster0 "mongodb://clusterAdmin:[email protected]:20020,clusterOne02.fancyCorp.com:20020,clusterOne03.fancyCorp.com:20020" \ |
| 56 | + --cluster1 "mongodb://clusterAdmin:[email protected]" |
| 57 | +
|
| 58 | +Atlas clusters require TLS connections. To use ``mongosync`` with Atlas |
| 59 | +clusters, you add the :urioption:`tls=true <tls>` option. For example, |
| 60 | +to connect to the ``admin`` database on ``cluster0`` and ``cluster1``: |
| 61 | + |
| 62 | +.. code-block:: shell |
| 63 | +
|
| 64 | + mongosync \ |
| 65 | + --cluster0 "mongodb://clusterAdmin:[email protected]:20020,clusterOne02.fancyCorp.com:20020,clusterOne03.fancyCorp.com:20020/admin?tls=true" \ |
| 66 | + --cluster1 "mongodb://clusterAdmin:[email protected]/admin?tls=true" |
| 67 | +
|
| 68 | +You can also use ``mongodb+srv`` connection strings with ``mongosync``. |
| 69 | +You do not need to add the :urioption:`tls=true <tls>` option to a |
| 70 | +``mongodb+srv`` connection string. For example: |
| 71 | + |
| 72 | +.. code-block:: shell |
| 73 | +
|
| 74 | + mongosync \ |
| 75 | + --cluster0 "mongodb+srv://clusterAdmin:[email protected]/" \ |
| 76 | + --cluster1 "mongodb+srv://clusterAdmin:[email protected]/" |
| 77 | +
|
| 78 | +For more details about ``mongodb+srv`` connection strings, see |
| 79 | +:ref:`connections-dns-seedlist`. |
0 commit comments