mongosync 유틸리티는 MongoDB 클러스터 간에 연결을 생성합니다. mongosync 는 다음 클러스터 중 하나에 연결할 수 있습니다.
MongoDB Atlas 호스팅 클러스터
자체 관리형 클러스터 및 Atlas 호스팅 클러스터
이 페이지에서는 MongoDB Mongosync를 사용하여 자체 관리 클러스터 Atlas cluster 에 연결하는 방법에 대해 설명합니다.
Atlas 클러스터 연결에 대한 자세한 내용은 데이터베이스 배포서버에 연결참조하세요.
참고
최상의 성능을 위해 자체 관리형 클러스터 에서 마이그레이션 하기 전에 최신 MongoDB Server 패치 출시하다 로 업그레이드 하세요. 자세한 내용 은 MongoDB 의 최신 자체 관리 패치 릴리스로 업그레이드를 참조하세요.
연결 문자열
mongosync uses a MongoDB URI connection string to connect self-managed clusters:
SRV 연결 체계의 형식은 다음과 같습니다.
mongodb+srv://[username:password@][host.domain.TLD][/defaultauthdb][?options] 표준 URI 연결 체계의 형식은 다음과 같습니다.
mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]
Specify the hostnames of the mongod instances the same way that they are listed in your replica set configuration.
For sharded clusters, specify the hostnames of the mongos instances instead of the mongod instances.
참고
mongosync does not require the replicaSet option.
mongosync uses a MongoDB URI connection string to connect Atlas clusters:
SRV 연결 체계의 형식은 다음과 같습니다.
mongodb+srv://[username:password]@[clusterName].[host].mongodb.net/ For information on how to find your SRV connection string in Atlas, see Connect to Your Cluster.
표준 URI 연결 체계의 형식은 다음과 같습니다.
mongodb://[username:password]@[clusterName].[host].mongodb.net/
mongosync requires the primary read preference to connect to the source and destination clusters. For more information, see Read Preference Options.
인증
Provide valid authentication to connect to a MongoDB Atlas cluster. If you do not already have an Atlas database user, you must create a user.
소스 또는 대상 cluster에 인증이 필요한 경우 mongosync 호출할 때 올바른 자격 증명을 제공해야 합니다.
역할
mongosync 연결 문자열 에 지정된 사용자에게는 소스 및 대상 클러스터에 대한 필수 권한이 있어야 합니다. 권한은 환경과 역 동기화 사용 여부에 따라 달라집니다.
소스 클러스터 에 대한 자체 관리형 권한은 다음과 같습니다.
동기화 유형 | 필수 소스 권한 |
|---|---|
기본값 | |
이중 쓰기 차단 | |
반전 | |
다중 반전 |
For details on server roles, see: Role-Based Access Control in Self-Managed Deployments.
To update user permissions, see: grantRolesToUser.
대상 클러스터 에 대한 Atlas 권한은 다음과 같습니다.
동기화 유형 | 필수 대상 권한 |
|---|---|
기본값 |
|
이중 쓰기 차단, 반전 또는 다중 반전 |
|
For details on Atlas roles, see Atlas User Roles.
To update Atlas user permissions, see: Manage Access to a Project.
During synchronization, mongosync uses the setUserWriteBlockMode command to block writes on the destination cluster. The database user that mongosync uses to connect to the destination cluster must have both of the following actions at the same time:
setUserWriteBlockMode, which allowsmongosyncto run the command that blocks writes.bypassWriteBlockingMode, which allowsmongosyncto keep writing to the destination while writes are blocked.
두 조치 중 하나라도 누락되면 mongosync은(는) 중지되고 누락된 권한을 보고합니다.
atlasAdmin 은 내장 역할이며, 이 두 가지 조치는 역할이 아닌 권한 조치입니다. 이러한 권한을 부여하려면 두 가지 조치를 모두 포함하는 사용자 지정 역할을 만들고 해당 사용자 지정 역할을 데이터베이스 사용자에게 할당하세요.
사용자 지정 역할을 생성하고 이를 데이터베이스 사용자에게 할당하려면 다음을 수행합니다.
사용자 지정 역할을 만들려면 다음 명령을 실행합니다.
atlas customDbRoles create mongosyncWriteBlocking \ --privilege SET_USER_WRITE_BLOCK,BYPASS_USER_WRITE_BLOCK
사용자 지정 역할을 데이터베이스 사용자에게 할당하려면 다음 명령을 실행합니다. --role 옵션은 사용자의 기존 역할을 대체하므로 사용자가 이미 가지고 있는 역할과 사용자 지정 역할을 함께 나열합니다. 예를 들어 atlasAdmin 역할을 유지하려면 다음을 수행합니다.
atlas dbusers update <username> \ --role atlasAdmin,mongosyncWriteBlocking
행동
호스팅
The mongosync utility can be hosted on its own hardware close to either the source or destination cluster. It does not have to be hosted on the same server as one of the mongod or mongos instances in the cluster. This flexibility allows you to push, or pull, data to the destination cluster with minimal impact on the mongod or mongos instances running there.
초기 상태
mongosync 가 연결되면 IDLE 상태가 됩니다. 동기화를 시작하려면 시작 명령을 실행해야 합니다.
제한 사항
Before you attempt to run mongosync with an M10+ Atlas cluster, disable the Require Indexes for All Queries option to set notablescan to false on both the source and destination clusters.
예시
연결 정보 수집
소스 클러스터cluster0 은(는) 다음 서버 및 포트에서 호스팅됩니다.
clusterOne01.fancyCorp.com:20020clusterOne02.fancyCorp.com:20020clusterOne03.fancyCorp.com:20020
대상 Atlas 클러스터 cluster1 는 다음 서버 및 포트에서 호스팅됩니다.
cluster2Name-01.abc123.com:27017cluster2Name-02.abc123.com:27017cluster2Name-03.abc123.com:27017
관리 사용자 clusterAdmin 가 각 cluster에 superSecret 비밀번호로 구성되어 있습니다.
소스 및 대상 cluster 연결 mongosync
자체 관리형 클러스터 의 일반 연결 string 형식은 다음과 같습니다.
mongodb://<user>:<password>@<ip-address>:<port>,<ip-address>:<port>,<ip-address>:<port>
클러스터 의 일반 연결 string 형식은 Atlas 다음과 같습니다.
mongodb://<user>:<password>@<clusterName>.<hostname>.mongodb.net/
자체 관리형 클러스터에 대해 수집한 연결 정보를 사용하여 cluster0 에 대한 연결 문자열을 만듭니다.
cluster0: mongodb://clusterAdmin:superSecret@clusterOne01.fancyCorp.com:20020,clusterOne02.fancyCorp.com:20020,clusterOne03.fancyCorp.com:20020
You can get the connection string for the Atlas cluster from the Atlas UI. To learn more, see Connect to a Database Deployment.
아래의 mongosync 명령 레이아웃은 표시되도록 수정되었습니다. mongosync 을 사용하여 cluster0 를 cluster1 에 연결하려면 다음 명령을 한 줄에 입력합니다.
mongosync \ --cluster0 "mongodb://clusterAdmin:superSecret@clusterOne01.fancyCorp.com:20020,clusterOne02.fancyCorp.com:20020,clusterOne03.fancyCorp.com:20020" \ --cluster1 "mongodb://clusterAdmin:superSecret@cluster2Name.abc123.mongodb.net"
Atlas clusters require TLS connections. To use mongosync with Atlas clusters, you add the tls=true option. For example, to connect to the admin database on cluster0 and cluster1:
mongosync \ --cluster0 "mongodb://clusterAdmin:superSecret@clusterOne01.fancyCorp.com:20020,clusterOne02.fancyCorp.com:20020,clusterOne03.fancyCorp.com:20020/admin?tls=true" \ --cluster1 "mongodb://clusterAdmin:superSecret@cluster2Name.abc123.mongodb.net/admin?tls=true"
You can also use mongodb+srv connection strings with mongosync. You do not need to add the tls=true option to a mongodb+srv connection string. For example:
mongosync \ --cluster0 "mongodb+srv://clusterAdmin:superSecret@clusterOne01.fancyCorp.com/" \ --cluster1 "mongodb+srv://clusterAdmin:superSecret@cluster2Name.abc123.mongodb.net/"
For more details about mongodb+srv connection strings, see SRV Connection Format.