이 튜토리얼에서는 Atlas 설정 명령을 사용하여 다음을 수행하는 방법을 보여줍니다.
Atlas 프로젝트에 cluster 한 개를 생성합니다.
샘플 데이터 를 Atlas 클러스터에 로드합니다.
프로젝트의 IP 액세스 목록에 IP 주소를 추가합니다.
Atlas cluster에 대한 MongoDB 사용자를 생성합니다.
MongoDB Shell
mongosh을(를) 사용하여 새 클러스터에 연결합니다.
새 Atlas 계정을 만드는 동시에 이 모든 단계를 수행하려면 Atlas 시작하기를 참조하세요.
구성 파일을 사용하여 cluster를 만들려면 atlas setup 대신 --file 옵션과 함께 Atlas cluster create 명령을 실행합니다. Atlas cluster의 구성 파일에 대해 자세히 알아보려면 cluster 구성 파일을 참조하세요.
atlas setup 을(를) 사용하여 Atlas 계정을 만들고 Atlas로 인증할 수도 있습니다. 자세한 내용 은 Atlas 시작하기를 참조하세요.
전제 조건
시작하기 전에 다음 작업을 완료하세요.
Atlas 조직만들기
Atlas API의 경우 포트 443 (HTTPS)에 대한 외부 액세스를 확인하고, MongoDB 연결의 경우 포트 27017 에 대한 외부 액세스를 확인합니다.
Atlas cluster 구성
atlas setup 명령을 사용하여 Atlas에서 M0 클러스터를 생성합니다. M0 클러스터에는 몇 가지 운영상의 제한이 있습니다.
이 명령은 다음과 같은 방법으로 실행할 수 있습니다.
기본 설정 모드: 이 명령은 기본 설정으로 샘플 공유 계층 cluster를 생성합니다.
대화형 모드: 이 명령은 cluster 설정을 입력하라는 메시지를 표시하고 기본값을 제공합니다.
비대화형 모드: 옵션을 사용하여 명령을 실행합니다.
탭을 클릭하면 원하는 모드에 대한 명령을 볼 수 있습니다.
이 명령은 다음과 같은 기본 설정으로 샘플 공유 계층 cluster를 생성합니다.
클러스터 이름:
Cluster<number>서비스 제공자:
AWS제공자 리전:
US_EAST_1클러스터 계층:
M0디스크 크기:
0.5GB데이터베이스 사용자 이름:
Cluster<number>데이터베이스 사용자 비밀번호:
abcdef12345IP 주소에서 연결 허용:
<YourIPAddress>샘플 데이터 로드:
Yesshell 열기:
No
참고
비밀번호는 무작위로 자동 생성된 값입니다. abcdef12345 은(는) 예시 값입니다.
atlas setup --force
We are deploying Cluster9876543... Please store your database authentication access details in a secure location Database User Username: Cluster9876543 Database User Password: abcdef12345 Creating your cluster... [Its safe to 'Ctrl + C'] Cluster created. Your connection string: mongodb+srv://cluster9876543.example.mongodb.net Loading sample data into your cluster... [Its safe to 'Ctrl + C'] Now you can connect to your Atlas cluster with: mongosh -u Cluster9876543 -p abcdef12345 mongodb+srv://cluster9876543.example.mongodb.net
이 명령은 클러스터 설정을 입력하라는 메시지를 표시하고 기본값 옵션을 제공합니다. 메시지가 표시되면 Y 를 누른 다음 Enter 를 눌러 기본값 설정을 수락합니다.
atlas setup
Press [Enter] to use the default values. Enter [?] on any option to get help. [Default Settings] Cluster Name: Cluster9876543 Cloud Provider and Region: AWS - US_EAST_1 Database User Username: Cluster9876543 Load sample data: Yes Allow connections from (IP Address): <your-IP> ? Do you want to set up your first free database in Atlas with default settings (it's free forever)? Yes We are deploying Quickstart-9876543... Please store your database authentication access details in a secure location: Database User Username: Cluster9876543 Database User Password: abcdef12345 Creating your cluster... [Its safe to 'Ctrl + C'] Cluster created. Your connection string: mongodb+srv://cluster9876543.example.mongodb.net Loading sample data into your cluster... [Its safe to 'Ctrl + C'] Now you can connect to your Atlas cluster with: mongosh -u Cluster9876543 -p abcdef12345 mongodb+srv://cluster9876543.example.mongodb.net
이 명령은 다음 설정을 사용하여 샘플 공유 계층 클러스터 를 생성합니다.
클러스터 이름:
getStarted서비스 제공자:
AWS제공자 리전:
US_EAST-1클러스터 계층:
M0디스크 크기:
2GBMongoDB 버전:
5.0복제본 세트 멤버:
3
atlas setup --clusterName getStarted --provider AWS --region US_EAST_1 --username testUser --password changeMe --accessListIp 192.0.2.15 --skipSampleData --force
We are deploying getStarted... Please store your database authentication access details in a secure location: Database User Username: testUser Database User Password: changeMe Creating your cluster... [Its safe to 'Ctrl + C'] Now you can connect to your |service| cluster with: mongosh -u testUser -p changeMe mongodb+srv://getStarted.example.mongodb.net
배포서버 확인
클러스터 프로비저닝 후 연결하기 전에 준비되었는지 확인합니다.
체크포인트 | 유효성 검사 단계 |
|---|---|
CLI 설치됨 |
|
인증됨 |
|
클러스터 생성 | CLI 출력에는 연결 문자열이 있는 |
IP 액세스 목록 업데이트 | CLI 출력에서 IP 주소가 추가되었음을 확인합니다. |
연결 성공 | 연결 문자열을 사용하여 |
다음 단계
Atlas 클러스터를 생성하고 확인한 후에는 다음을 수행할 수 있습니다.
애플리케이션 연결:
mongosh또는 MongoDB 드라이버와 연결 문자열을 사용하세요.보안 구성: 액세스 목록에 IP 주소를 추가하거나, 애플리케이션 특정 데이터베이스 사용자를 만들거나, 생산 워크로드에 대해 비공개 엔드포인트를 활성화합니다.
데이터 로드: 설정 시
--loadSampleData플래그를 사용하거나 mongoimport 또는 mongorestore로 자체 데이터를 로드합니다.클러스터 상태 보기: UI에 로그인 하거나 Atlas CLI에서
atlas clusters명령을 실행합니다.클러스터 확장 또는 수정: 클러스터 수정을 참조하세요.