티스토리 뷰
Step-by-step guide : How to Configure MongoDB Replica Set in Ubuntu
creams 2023. 3. 15. 19:24
1. Install MongoDB on all the servers that will be part of the replica set.
You can do this by following the instructions provided in the MongoDB documentation for your Ubuntu version.
2. Once MongoDB is installed, create a directory for the data files and a directory for the log files on each server.
For example, you could create a data directory at /data/db and a log directory at /var/log/mongodb.
3. Create a configuration file for each MongoDB instance that will be part of the replica set.
You can do this by creating a file at /etc/mongodb.conf with the following contents:
dbpath=/data/db
logpath=/var/log/mongodb/mongodb.log
logappend=true
bind_ip=your_ip_address
port=27017
fork=true
replSet=your_replica_set_name
Replace your_ip_address with the IP address of the server, and your_replica_set_name with the name
you want to give to your replica set.
4. Start the MongoDB instances using the following command:
sudo service mongodb start
5. Log in to one of the MongoDB instances and initiate the replica set using the following command:
mongo
rs.initiate()
6. Add the other MongoDB instances to the replica set by running the following command on each instance:
mongo
rs.add("ip_address:port")
Replace ip_address with the IP address of the server and port with the port number on which MongoDB is running.
7. Verify that the replica set is working by running the following command on any of the instances:
mongo
rs.status()
This should show the status of the replica set and the name of the primary node.
That's it! Your MongoDB replica set is now configured and ready to use.
'Dev Story > MongoDB' 카테고리의 다른 글
Python을 활용한 MongoDB 인덱스 생성 방법: 빠른 검색과 쿼리 성능 최적화 (0) | 2023.04.11 |
---|---|
MongoDB 6.0에서 추가된 Time Series Collection 생성부터 조회까지 (1) | 2023.03.21 |
Mastering MongoDB: A Guide to Commonly Used Commands (0) | 2023.03.15 |
Python MongoDB connect ( 연결하기 ) (0) | 2023.03.09 |
MongoDB Atlas 평생 무료로 사용해보기 (0) | 2023.03.08 |
- Total
- Today
- Yesterday
- svelte
- 따라해보기
- cloudcomputing
- GPT
- ML
- Docker 관리
- python
- 티스토리
- 개발이야기
- AWS
- ubuntu
- EC2
- docker
- Containerization
- 한식
- AI
- 따라하기
- 쉽게따라하기
- MongoDB
- frontend
- Redis
- svelte 따라해보기
- nestjs
- ChartGPT
- 딥러닝
- lambda
- typescript
- 실습
- 클라우드
- DevOps
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |