데이터베이스 설치 및 사용 준비
1. ec2에 MongoDB를 설치 후 실행
1. /etc/yum.repos.d/mongodb-org-6.0.repo파일 생성 후 밑의 설정 입력 후 저장
[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc
2.sudo yum install -y mongodb-org입력
3.sudo systemctl start mongod입력
Install MongoDB Community Edition on Amazon Linux — MongoDB Manual
Docs Home → MongoDB Manual MongoDB AtlasMongoDB Atlas is a hosted MongoDB service option in the cloud which requires no installation overhead and offers a free tier to get started.Use this tutorial to install MongoDB 6.0 Community Edition on Amazon Linux
www.mongodb.com
2. mongoDB 접속
1. mongosh 입력
https://www.mongodb.com/docs/mongodb-shell/connect/#connect-with-authentication
Connect to a Deployment — MongoDB Shell
Docs Home → MongoDB Shell This page shows how to use the MongoDB Shell to connect to a MongoDB deployment.To use the MongoDB Shell, you must have a MongoDB deployment to connect to.You can use the MongoDB Shell to connect to MongoDB version 4.2 or greate
www.mongodb.com
3. 데이터베이스 생성
나중에 스프링부트와의 연결을 위해서 미리 데이터베이스를 생성하고 더미 데이터를 준비해준다.
https://www.mongodb.com/docs/manual/tutorial/getting-started/
Getting Started — MongoDB Manual
Docs Home → MongoDB Manual This tutorial walks you through inserting test data into a MongoDB database and querying that data using the documentation's embedded web shell. You do not need to deploy or install MongoDB to complete this tutorial.The example
www.mongodb.com
4. 어드민 계정 생성
데이터베이스에 접속하는 유저를 관리하는 관리자 계정을 생성해준다.
Use SCRAM to Authenticate Clients — MongoDB Manual
Docs Home → MongoDB Manual The following procedure sets up SCRAM for client authentication on a standalone mongod instance.To use SCRAM authentication for replica sets or sharded clusters, see Deploy Replica Set With Keyfile Authentication.Start a standa
www.mongodb.com
5. 외부에서 데이터베이스 접속 확인
ec2의 인바운드 규칙을 추가하고 mongodb의 설정을 변경하여 외부에서 접속이 가능하도록 한다.
https://www.mongodb.com/docs/manual/reference/configuration-options/#net-options
설정이 완료되면 다음과 같이 접속이 되는지 확인
mongosh --host mongodb0.example.com --port 28015
옵션. MongoDB Compass 설치
MongoDB GUI입니다.
https://www.mongodb.com/products/compass
다음글.
https://geonbbang.tistory.com/26
[MongoDB] 데이터베이스 연동하기(2)
이전글https://geonbbang.tistory.com/25 [MongoDB] 데이터베이스 연동하기(1)데이터베이스 설치 및 사용 준비1. ec2에 MongoDB를 설치 후 실행1. /etc/yum.repos.d/mongodb-org-6.0.repo파일 생성 후 밑의 설정 입력 후 저
geonbbang.tistory.com
'Database' 카테고리의 다른 글
| Redis(2) (0) | 2023.06.11 |
|---|---|
| Redis(1) (0) | 2023.06.07 |
| [MongoDB] 데이터베이스 연동하기(2) (2) | 2023.03.13 |
| TIL. 인덱스(INDEX) (0) | 2023.02.09 |
| SQL VS NoSQL (0) | 2023.02.08 |