惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Vercel News
Vercel News
博客园_首页
Y
Y Combinator Blog
美团技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
阮一峰的网络日志
阮一峰的网络日志
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
GbyAI
GbyAI
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
D
DataBreaches.Net
博客园 - Franky
Engineering at Meta
Engineering at Meta
量子位
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
酷 壳 – CoolShell
酷 壳 – CoolShell
N
Netflix TechBlog - Medium

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How I Set Up MongoDB for Local Development
Orim Dominic · 2026-05-15 · via DEV Community

Some of the applications I build use MongoDB. MongoDB community server is the most common MongoDB server for local development but it is not exactly the same as MongoDB Atlas which used in production. The community server lacks two features:

  • Replica sets
  • Vector search

MongoDB Atlas has replica sets - one primary database and two secondary databases. The replica sets are important for data replication, redundancy and transactions. It also has a vector search feature which can be used for Retrieval-Augmented Generation (RAG).

The applications I build require these features but the community server lacks them. Moreover, it's important that the environment used during development is similar to the one in production.

What I Used Before Now

I used run-rs for replica sets and MongoDB Search and MongoDB Vector Search for vector search.

run-rs for Replica Sets

run-rs was what I previously used to set up a MongoDB server. Setting it up required some hacks but in general, it worked fine. Recently, I mistakenly tampered with some configurations and it cleared the data stored by the package - all the databases I used with run-rs vanished. I needed a durable solution - isn't that what the D in ACID means?

MongoDB Search and MongoDB Vector Search for Vector Search

Setting up MongoDB Search and MongoDB Vector Search was not a straightforward procedure for me, but I got it to work eventually. I didn't like the manual process I used to always start it up, so I defaulted to using a remote MongoDB Atlas server for RAG, and this was not the best for local development.

What I Use Now

For replica sets and vector search, I now use Docker images. You can find the setup at mongo-docker-local-dev. I spin up these Docker images when I need an app to connect to a MongoDB instance locally and I can use the instance with the replica set or the one with the vector search.

Replica Set

For the replica set, I set up three MongoDB server instances (mongo_1, mongo_2, mongo_3) and connect them all with a fourth instance(mongo_replicas_init). The init_replset script contains code that initialises a replica set using the first three MongoDB servers and sets their advertisment URIs. This script runs only once - the first time the container is started.

This setup requires the addition of the URIs of the instances to my /etc/hosts file:

127.0.0.1   mongo_1
127.0.0.1   mongo_2
127.0.0.1   mongo_3

Enter fullscreen mode Exit fullscreen mode

This should be done before starting the container.

To start the replica set container, I run make replicas to execute the replicas target in Makefile. I connect with the databases using the URI value mongodb://mongo_1:27001,mongo_2:27002,mongo_3:27003/?replicaSet=rs.

To confirm that it works, run make replicas in the repository's root folder and then run node scripts/replset.cjs in another terminal of the repository's root folder. You would see a connected to replica set server message in the terminal.

Vector Search

I use the mongodb/mongodb-atlas-local Docker image to set up a local version of MongoDB Atlas. This version has the vector search feature, the text search and Atlas search features for autocomplete and vector search. It also has a single-node replica set.

I use make atlas to start the local Atlas server and I connect to it with the URI: mongodb://root:secret@localhost:27004?directConnection=true.

Questions

Does this setup support change streams?

The replica set and the Atlas setups both support change streams.

Why didn't you create a three-node replica set with the local Atlas server so you have the replica sets and the vector search features in one container?

I thought you wouldn't ask. It doesn't work. The local Atlas server is a single-node replica set server and that cannot be modified (yet).

Cheers!