mongomirror is a tool for manually migrating data from an existing MongoDB replica set to a MongoDB Atlas replica set. See Download mongomirror.
mongomirror는 기존 복제본 세트 또는 애플리케이션을 종료할 필요가 없습니다. 또한 사용자 또는 역할 데이터를 가져오지 않으며 config 데이터베이스를 복사하지 않습니다.
다음과 같은 경우 mongomirror를 사용하세요.
MongoDB Atlas 외부에서 호스팅되는 MongoDB 배포에서 MongoDB Atlas 클러스터로 데이터 세트 마이그레이션을 1회 실행합니다.
한 Atlas 클러스터에서 다른 Atlas 클러스터로 데이터 세트 마이그레이션을 1회 실행합니다.
또한 데이터 가져오기 및 마이그레이션 도구 선택을 참조하세요.
전제 조건
소스 MongoDB 배포
The source MongoDB deployment must be a replica set. If the source is a standalone MongoDB deployment, before running
mongomirror, convert the standalone to a replica set.소스 복제본 세트는 MongoDB 버전 2.6 이상을 실행해야 합니다.
소스 MongoDB 복제본 세트 무료 클러스터 (이전의
M0) 또는 Flex 클러스터 일 수 없습니다.소스 MongoDB 복제본 세트 time series 컬렉션의 데이터를 포함할 수 없습니다.
절차 중 어떤 경우에도
featureCompatibilityVersion플래그를 변경하지 않습니다.MongoDB 4.4 이하에서 MongoDB 7.0 이상을 실행하는 Atlas 클러스터로 마이그레이션하는 경우, 컬렉션에서 geoHaystack 인덱스를 제거하세요.
mongomirroris not compatible with TTL indexes. Drop any existing TTL indexes and rebuild them when the migration process is complete. If you do not want to drop an existing index because it is important for query performance, contact support for alternative options.Don't make any namespace changes during the migration process, such as using the
renameCollectioncommand or executing an aggregation pipeline that includes the$outaggregation stage.You can't use the
renameCollectioncommand or the$outaggregation stage as part of initial sync, which runs as a part of themongomirrorprocess.마이그레이션의 초기 동기화 단계에서는 프라이머리를 재시작하지 않도록 합니다.
If your MongoDB deployment contains indexes with keys which exceed the Index Key Limit, before you start the live migration procedure, modify indexes so that they do not contain oversized keys.
소스 복제본 세트에 대한 필수 액세스 권한
mongomirror는 소스 복제본 세트에 대한 네트워크 액세스 권한이 있어야 합니다. 소스 복제본 세트에 인증이 필요한 경우 mongomirror를 실행할 때 사용자 자격 증명을 포함하세요. 최소한 다음 권한을 가진 데이터베이스 사용자를 지정합니다.
Read all databases and collections. The
readAnyDatabaserole on theadmindatabase covers this requirement.Read the oplog. See Oplog Access.
Run the
getParametercommand.
If no such user exists, create the user in your source MongoDB replica set. Different MongoDB Server versions have different built-in roles. Select a built-in role based on your MongoDB Server version and run the appropriate commands in the mongosh:
For source clusters a user must have the
readAnyDatabase,clusterMonitor, andbackuproles.To verify that the database user who will run the live migration process has these roles, run the db.getUser() command on the
admindatabase.use admin db.getUser("admin") { "_id" : "admin.admin", "user" : "admin", "db" : "admin", "roles" : [ { "role" : "backup", "db" : "admin" }, { "role" : "clusterMonitor", "db" : "admin" } { "role" : "readAnyDatabase", "db" : "admin" } ] } ... 이외에도 소스 클러스터의 데이터베이스 사용자는 데이터베이스의 oplog를 읽을 수 있는 역할이 있어야
admin합니다. 자세히 알아보려면 Oplog 액세스를참조하십시오.For source clusters running MongoDB 3.4 a user must have, at a minimum, both
clusterMonitorandreadAnyDatabaseroles. For example:use admin db.createUser( { user: "mySourceUser", pwd: "mySourceP@$$word", roles: [ "clusterMonitor", "readAnyDatabase" ] } ) For source clusters running MongoDB 3.2 a user must have, at a minimum, both
clusterManagerandreadAnyDatabaseroles, as well as read access on thelocaldatabase. This requires a custom role, which you can create with the following commands:use admin db.createRole( { role: "migrate", privileges: [ { resource: { db: "local", collection: "" }, actions: [ "find" ] } ], roles: ["readAnyDatabase", "clusterManager"] } ) db.createUser( { user: "mySourceUser", pwd: "mySourceP@$$word", roles: [ "migrate" ] } ) For source clusters running MongoDB 2.6 or 3.0 a user must have, at a minimum, the
readAnyDatabaserole. For example:use admin db.createUser( { user: "mySourceUser", pwd: "mySourceP@$$word", roles: [ "readAnyDatabase" ] } )
대상 Atlas 배포
대상 Atlas 배포:
무료 클러스터 또는 Flex 클러스터 일 수 없습니다.
복제본 세트이어야 합니다.
Must have the version that is the same as or later than the source cluster MongoDB version. See Upgrade Path.
소스 클러스터와 겹치는 네임스페이스를 포함해서는 안 됩니다.
mongomirror2}가 대상 클러스터에서 겹치는 네임스페이스를 감지하는 경우 프로세스를 시작하기 전에 실패합니다. 대상 클러스터에 네임스페이스가 겹치는 경우--drop를 사용하여 대상 클러스터에서 데이터를 모두 삭제하거나--includeNamespace사용하여 소스 클러스터에서 가져올 네임스페이스를 나열합니다.다음 중 하나의 IP 액세스 목록에도 포함되어야 합니다.
mongomirror가 실행 중인 서버의 공용 IP 주소 또는VPC 피어링을 설정한 경우, 상대방의 VPC CIDR 블록(또는 서브넷) 또는 상대방 VPC의 보안 그룹(Security Group) 중 하나를 사용해야 합니다.
참고
클러스터 내 임의의 노드에 대한 공용 IP 주소를 찾으려면 명령줄에서
nslookup도구를 사용합니다. 자세한 내용은 Atlas 클러스터의 공용 IP가 변경되나요?를 참조하세요.
대상 cluster에 대한 필수 액세스 권한
mongomirror 대상 클러스터에 대한 네트워크 액세스 권한이 있어야 합니다.
You must specify a database user with the Atlas admin role to run mongomirror. To learn more, see Configure Database Users.
경로 업그레이드
중요
mongomirror 는 MongoDB 6.0+ 소스 클러스터와 6.0+ 대상 클러스터 간의 마이그레이션에는 지원되지 않습니다. 를 사용하여 소스 복제본 세트 에서 마이그레이션 할 mongomirror 수 60 없습니다..x 이상을 대상 복제본 세트 6에 추가합니다.0.x 또는 그 이후 버전.
를 사용하여 이전 버전의 소스 복제본 세트 mongomirror 6.0 에서 MongoDB 버전 이 있는 대상 복제본 세트 로 마이그레이션 할 수 있습니다.
Alternatively, you can upgrade your source replica set to 6.0+ or 7.0+ and use this live migration procedure to migrate an upgraded replica set to Atlas.
mongomirror 다음 마이그레이션 경로를 지원합니다.
소스 복제본 세트 MongoDB 버전 | 대상 Atlas 복제본 세트 MongoDB 버전 |
|---|---|
5.0 | 6.0 |
4.4 | 6.0 |
4.2 | 6.0 |
4.0 | 6.0 |
3.6 | 6.0 |
3.4 | 6.0 |
3.2 | 6.0 |
3.0 | 6.0 |
2.6 | 6.0 |
다운로드 mongomirror
참고
macOS 64비트에서 mongomirror 파일 다운로드한 후 처음으로 열려고 하면 보안 경고 나타납니다. 계속하려면 보안 설정을 재정의하여 앱 열기를 참조하세요.
운영 체제 | 다운로드 |
|---|---|
Amazon Linux 1 | |
Amazon Linux 2 | |
Debian 9.2 | |
Debian 10 | |
macOS 64-bit | |
RHEL 7.0 | |
RHEL 7.1 PPC64LE | |
RHEL 7.2 s390x | |
RHEL 8.0 | |
RHEL 8.1 PPC64LE | |
SLES 12 | |
SLES 15 | |
Ubuntu 16.04 | |
Ubuntu 16.04 ARM | |
Ubuntu 18.04 | |
Ubuntu 18.04 ARM | |
Ubuntu 20.04 | |
Ubuntu 20.04 ARM | |
Windows |
mongomirror 프로세스
mongomirror를 시작하면 다음과 같은 작업이 수행됩니다.
TLS를 통해 Atlas에 연결합니다.
초기 동기화를 수행하면 기존 MongoDB 복제본 세트의 컬렉션이 Atlas의 대상 클러스터로 복사됩니다.
초기 동기화 후 수신 변경 사항에 대해 복제본 세트의 oplog 지속적으로 테일링하고 Atlas 의 대상 클러스터 에서 이를 재생합니다.
mongomirrorconfig는 데이터베이스 복사하지 않습니다.mongomirror는 소스 또는 대상 클러스터 에서 와이어 압축을 활성화 경우 이를 사용하고 을(를) 사용하여 허용할 압축 라이브러리를--compressors지정합니다.mongomirrorbuilds all indexes on the destination cluster in the foreground, regardless of how the indexes were built on the source cluster. Foreground index builds block all other operations on the database. To learn more, see Index Build Operations on a Populated Collection.
mongomirror는 일단 시작되면 종료될 때까지 계속 실행됩니다.
초기 동기화 단계에서
mongomirror를 종료한 경우,mongomirror를 다시 시작하기 전에 대상 클러스터가 비어 있는지 확인하거나--drop으로mongomirror를 실행하세요.If you shut down
mongomirrorduring the oplog tailing stage, the process stops tailing the oplog. You can restartmongomirrorto continue tailing from the last processed oplog record using--bookmarkFile.
실행 mongomirror
소스 복제본 세트에서 데이터베이스 사용자를 설정합니다.
If the source replica set requires authentication, you must include user credentials when running mongomirror. For requirements, see Required Access on Source Replica Set.
mongomirror 실행하는 경우 이러한 자격 증명을 지정해야 하기 때문에 새 사용자에 대해 선택한 사용자 이름과 패스워드 기록해 둡니다.
Atlas 에서 프로젝트 의 Database & Network Access 페이지로 이동합니다.
아직 표시되지 않은 경우 탐색 표시줄의 Organizations 메뉴에서 프로젝트가 포함된 조직을 선택합니다.
아직 표시되지 않은 경우 내비게이션 바의 Projects 메뉴에서 프로젝트를 선택합니다.
사이드바에서 Security 제목 아래의 Database & Network Access를 클릭합니다.
The Database & Network Access page displays after you complete the preceding steps.
대상 Atlas 클러스터에서 데이터베이스 사용자를 설정하세요.
You must specify a database user with the Atlas admin role to run mongomirror. See Configure Database Users for documentation on creating a database user.
해당 사용자가 없는 경우 사용자를 만듭니다:
아직 표시되지 않은 경우 Database Users 탭을 클릭합니다.
딸깍 하는 소리 Add New Database User.
Atlas admin 0} 사용자를 추가합니다.
mongomirror 실행하는 경우 이러한 자격 증명을 지정해야 하기 때문에 새 사용자에 대해 선택한 사용자 이름과 패스워드 기록해 둡니다.
IP 액세스 목록을 업데이트합니다.
mongomirror를 실행할 호스트가 원하는 클러스터의 IP 액세스 목록에 없으면 이 목록을 업데이트하세요. 다음 두 가지 중 하나를 지정할 수 있습니다.
mongomirror실행될 서버의 공인 IP 주소 혹은VPC 피어링을 설정한 경우, 상대방의 VPC CIDR 블록(또는 서브넷) 또는 상대방 VPC의 보안 그룹(Security Group) 중 하나를 사용해야 합니다.
Atlas 에서 프로젝트 의 Clusters 페이지로 이동합니다.
아직 표시되지 않은 경우 탐색 표시줄의 Organizations 메뉴에서 원하는 프로젝트가 포함된 조직을 선택합니다.
아직 표시되지 않은 경우 탐색 표시줄의 Projects 메뉴에서 원하는 프로젝트를 선택합니다.
사이드바에서 Database 제목 아래의 Clusters를 클릭합니다.
Clusters(클러스터) 페이지가 표시됩니다.
대상 cluster 호스팅 정보를 복사합니다.
Atlas 클러스터의 호스트 이름 정보는 Atlas 사용자 인터페이스에서 확인할 수 있습니다.
참고
mongomirror로 데이터를 마이그레이션할 때는 드라이버를 사용할 필요가 없습니다.
Connect 대화 상자에서 Shell을 클릭합니다.
드롭다운 목록에서 3.4 or earlier 선택합니다. 연결 문자열은 다음과 같은 예시와 유사해야 합니다. 이러한 예시는 가독성을 위해 여러 줄로 나뉘어져 있습니다.
mongodb://<db_username>:<db_password>@ 00.foo.mongodb.net:27017, 01.foo.mongodb.net:27017, 02.foo.mongodb.net:27017/test? ssl=true&replicaSet=myAtlasRS&authSource=admin 다음 예시와 같이 텍스트 편집기에서
replicaSet값을 붙여 넣고 전방 슬래시(/)를 추가한 다음, 호스트 목록을 쉼표로 구분된 값으로 추가하세요.myAtlasRS/00.foo.mongodb.net:27017,01.foo.mongodb.net:27017,02.foo.mongodb.net:27017
다음 단계에서 --destination 에 이 값을 사용합니다.
마이그레이션 프로세스를 완료하려면 데이터 전송을 확인하고 Atlas로 전환합니다.
Atlas로 전환
mongomirror 초기 동기화를 완료하고 복제본 세트의 oplog를 추적한 후 대상 Atlas 클러스터로 전환할 수 있습니다.
데이터 전송 을 확인합니다.
다음 검증 전략 중 하나를 사용하여 데이터가 대상 클러스터로 전송되었는지 확인합니다. 소스 또는 대상 클러스터가 데이터를 쓰고 있지 않음을 확인한 후에만 다음 검증 방법을 사용하세요.
Use the db.collection.countDocuments() method on each collection on the source and the destination clusters to obtain document counts and compare them between the clusters.
소스 클러스터의 컬렉션을 쿼리한 다음 대상 클러스터에 동일한 값을 가진 올바른 문서, 인덱스, 컬렉션, 메타데이터 및 보기가 존재하는지 확인하는 스크립트를 작성합니다. 스크립트에서 소스 및 대상 클러스터에 다음 명령을 사용하세요.
To verify the transfer of indexes and compare the results, use the db.collection.getIndexes() method.
메타데이터 전송을 확인하고 결과를 비교하려면 db.getCollectionInfos() 메서드를 사용하세요.
Atlas 클러스터를 사용할 수 있도록 클라이언트 애플리케이션을 업데이트하세요.
cluster 패널의 Connect 버튼을 통해 제공된 Atlas 연결 문자열로 클라이언트 애플리케이션을 업데이트하세요.
Atlas 연결에 대한 자세한 내용은 클라이언트 라이브러리를 통해 클러스터에 연결하기를 참조하세요.
모니터링
mongomirror진행 상황을 터미널의 표준 출력에 기록합니다. 초기 동기화가 진행되는 동안 mongomirror 복사하는 각 collection에 대해 진행 표시줄을 기록합니다. 예시:
2024-08-09T16:35:50.227-0000 [#....................] park.events 2179/34184 (6.4%) 2024-08-09T16:35:50.227-0000 [#############........] zoo.animals 29000/49778 (58.3%)
oplog를 테일링할 경우 mongomirror 소스 클러스터의 가장 최근 oplog 항목과 대상 클러스터에서 마지막으로 처리된 oplog 항목 간의 지연 시간(단위: 초)을 기록합니다. 예시:
2024-12-12T16:22:17.027-0800 Current lag from source: 6s
지연 시간이 6초라는 것은 마지막으로 처리된 mongomirror oplog 항목이 소스 클러스터에서 사용 가능한 가장 최근 항목보다 6초 전에 발생했다는 의미입니다.
참고
mongomirror를 사용해서 따라잡기까지 걸리는 시간은 초당 유입되는 항목의 수에 따라 6초보다 많을 수도 있고 적을 수도 있습니다.
지연 시간이 0초라는 것은 mongomirror가 최신 oplog 항목보다 1초 이내에 빨리 유입된 항목을 처리 중이라는 뜻입니다.
소스 클러스터에 인덱스가 있다면 mongomirror가 대상 클러스터에서 동일한 인덱스를 구축합니다. 진행 로그에는 인덱스 구축 프로세스의 시작 시간과 종료 시간이 표시됩니다. 인덱스 빌드의 진행 상황을 보려면 다음 두 가지 방법 중 하나를 사용하면 됩니다.
대상 cluster의 프라이머리 노드에서 currentOp 명령어를 사용합니다.
command필드는 실행 중인 작업에 대한 정보를 표시합니다. 인덱스 생성 항목은 다음과 유사합니다."command" : { "createIndexes" : "perfs", "indexes" : [ { "key" : { "animal" : "text" }, "name" : "animal_text" } ]... 대상 클러스터에 대한 mongodb 로그를 다운로드하고 인덱스 관련 라인의 최근 항목을 검색합니다. 인덱스 작성과 관련된 로그 메시지는 다음과 유사하게 표시됩니다.
{"t":{"$date":"2024-08-09T16:35:50.227+00:00"},"s":"I", "c":"INDEX", "id":20447, "ctx":"conn1080","msg":"Index build: completed","attr":{"buildUUID":{"uuid":{"$uuid":"c4a62739-bf19-456d-bbd6-7baa29f1063b"}}}}
성능
To avoid contention for network and CPU resources, run mongomirror on hosts other than your replica set's mongod instance hosts.
mongomirror은(는) 소스 복제본 세트의 성능에 보조로 설정할 때와 비슷한 영향을 미칩니다.초기 동기화 단계에서는 데이터 세트의 크기에 따라 로드가 확장됩니다.
초기 동기화가 완료되면 시간당 사용되는 oplog 기가바이트에 따라 로드가 확장됩니다.
명령 구문, 옵션 및 예시
mongomirror의 구문, 옵션 및 예시는 mongomirror 참조 페이지를 참조하세요.