In light of last week’s EBS issues, we wanted to make sure MongoDB users on EBS are configured to be as robust as possible. A basic setup would consist of a 3 node replica set. The nodes would be roughly laid out like this: * A: us-east-1a priority 1 * B: us-east-1b priority 1 * C: us-west-1a priority 0
During steady state, either A or B would be primary. If the primary went down for any reason (system crash, or loss of one availability zone) the other node in us-east would take over. This is guaranteed because the west coast node has a priority of 0. If instead the entire east coast region were lost, then you would still have a ful copy of data on C. If you decided that you were going to make the west coast your primary data center for the duration, you would just bring up a couple more nodes there, and make a new replica set with the data from C. More information about running MongoDB on ec2 is available from our recent ec2 webinar. We are big fans of cloud computing in general and want MongoDB to only get more and more cloud-friendly over time. -Eliot
Getting started with VMware CloudFoundry, MongoDB and Rails
Listen to Jared Rosoff’s June 2 webinar “VMware Cloud Foundry with MongoDB” . Read about getting started with Cloud Foundry, MongoDB, and Node.js . Last week, VMware launched Cloud Foundry : an open-source platform as a service. It’s pretty radical in that not only can you run your apps on infrastructure operated by VMware, you can also download Cloud Foundry itself and run it on your own machines! But what’s most awesome about Cloud Foundry is that it supports MongoDB right out of the box! In today’s post, we’re going to walk through the creation of a Rails application using MongoDB and Cloud Foundry. Here’s what we’re going to need to do: Create a new rails project (skipping Active Record) Add the dependencies for MongoMapper Build a simple app that interacts with the database Set up our credentials so we can talk to Cloud Foundry’s MongoDB Push our application to CloudFoundry Create our rails project First we’ll create our new Rails project. My preference is for MongoMapper , so I’m going to skip the ActiveRecord generators when I initialize my project. <pre > $ rails new my_app –skip-active-record Add the dependencies for MongoMapper Next we need to setup our dependencies. Cloud Foundry will automatically detect that we’re a Rails app, and it will process our Gemfile if we’ve got one. So we’re need to add any dependencies to our Gemfile so they’ll get installed when we deploy. This is what our Gemfile looks like: source "http://rubygems.org" gem "rails", "3.0.5" gem "mongo_mapper" gem "bson_ext" I’m assuming you’re using Rails 3 here, but you can easily adapt these instructions for other versions. Build a simple app that interacts with the database Now we’ll write a little code to interact with the DB so we can be sure everything’s working. $ script/rails generate scaffold messages message:string --orm mongo_mapper I’m also going to set the root of my rails app to be our new messages controller and remove our public/index.html . Here’s my routes file: CloudFoundryRailsTutorial::Application.routes.draw do resources :messages root :to => "messages#index" end Be sure to delete your public/index.html !! Set up our credentials so we can talk to Cloud Foundry’s MongoDB MongoMapper comes with a generator that will create a basic config/mongo.yml configuration file for us. $ script/rails generate mongo_mapper:config The file looks like this: defaults: &defaults host: 127.0.0.1 port: 27017 development: <<: *defaults database: myapp_development test: <<: *defaults database: myapp_test set these environment variables on your prod server production: <<: *defaults database: myapp username: <%= ENV['MONGO_USERNAME'] %> password: <%= ENV['MONGO_PASSWORD'] %> We need to modify this so that it can talk to Cloud Foundry’s infrastructure. When CloudFoundry runs your app, it passes in a bunch of information through an environment variable. We need to pull the host, port, username, and password for MongoDB out of this environment variable. After some modification, the production section of your config/mongo.yml should look something like this: production: host: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-1.8'].first['credentials']['hostname'] rescue 'localhost' %> port: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-1.8'].first['credentials']['port'] rescue 27017 %> database: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-1.8'].first['credentials']['db'] rescue 'cloud_foundry_mongodb_tutorial' %> username: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-1.8'].first['credentials']['username'] rescue '' %> password: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-1.8'].first['credentials']['password'] rescue '' %> Note: The “rescue” clauses are so that you can run this app locally. If you don’t include this and you try to run this app outside of cloud foundry, you’ll get an exception because there’s no VCAP_SERVICES environment variable passed into your app. Push our application to CloudFoundry Now we’re ready to test things out. If you haven’t already, you should go ahead and install the vmc command line tool. There’s a getting started with VMC guide here . Here’s what it looked like when I deployed my app: redeye:myapp jsr$ vmc push --runtime ruby19 Would you like to deploy from the current directory? [Yn]: y Application Name: mongodb-on-cf-demo Application Deployed URL: 'mongodb-on-cf-demo.cloudfoundry.com'? Detected a Rails Application, is this correct? [Yn]: y Memory Reservation [Default:256M] (64M, 128M, 256M or 512M) 256M Creating Application: OK Would you like to bind any services to 'mongodb-on-cf-demo'? [yN]: y Would you like to use an existing provisioned service [yN]? n The following system services are available:: 1. mysql 2. mongodb 3. redis Please select one you wish to provision: 2 Specify the name of the service [mongodb-a8a43]: Creating Service: OK Binding Service: OK Uploading Application: Checking for available resources: OK Processing resources: OK Packing application: OK Uploading (5K): OK Push Status: OK Starting Application: OK redeye:myapp jsr$ Now you can point your browser to http://mongodb-on-cf-demo.cloudfoundry.com/ and you should see the list of messages! Congrats! You’ve got your first Rails app up and running on Cloud Foundry and MongoDB! The code for this mongodb + rails + Cloud Foundry app is up on github Happy coding and be sure to tell us about all the awesome apps you build on Cloud Foundry! – Jared Rosoff
Top 5 MongoDB Podcast Episodes in 2022 (so far)
At MongoDB, one of our core values is to be focused on building together. One way we lean into this value is by bringing some of the best voices and stories from the database and tech communities onto our podcast. Podcasts help communities learn and connect. So as we head toward the end of the year, let’s take a look back—or, perhaps, a listen back—to our top episodes based on listens from The MongoDB Podcast so far in 2022. Episode 107 - Introduction to WiredTiger with Dr. Michael Cahill Dr. Michael Cahill co-founded the WiredTiger company and the storage engine by the same name. In our most-listened to episode from 2022 so far, Dr. Cahill sits down with Michael to talk about the storage engine, its strengths and capabilities, and a little about his journey as a database industry legend. Episode 108 - Exploring Postman with Arlemi Turpault In this episode of the MongoDB Podcast, Michael Lynn discusses Postman with Arlemi Turpault, Senior Developer Advocate at Postman. Postman is an application used for API testing. It is an HTTP client that tests HTTP requests, utilizing a graphical user interface through which we obtain different types of responses that need to be validated. Episode 109 - Prisma and MongoDB - Better Together Prisma is an open source ORM for Node.js and TypeScript that helps developers build faster and make fewer errors. On this episode, host Mike Lynn sits down with Nikolas Burk and Matt Miller of the Prisma team to discuss the Prisma + MongoDB launch week. Burk is a Developer Advocate and Miller is a Product Manager at Prisma, and together they outline what Prisma is now capable of with MongoDB support, including effects on developer workflows and efficiency. Episode 106 - Securing the Internet with Josh Aas, Sarah Gran of ISRG In this episode of the podcast, Michael talks with Josh Aas and Sarah Gran of the Internet Security Research Group (ISRG). They walk listeners through their mission to secure the internet through projects like Let's Encrypt , the automated digital certificate authority, and Prossimo , which focuses on transforming risks around memory safety in popular open source projects. MongoDB World Series Our number five blog so far in 2022 was a preview of MongoDB World. But why listen to a preview when you can dive into the actual event? Live at MongoDB World 2022, host Michael Lynn met with a variety of customers, partners, and experts on-site in New York City. Those conversations formed a great series filled with stories, learning and community. Check out the series episodes: Ep. 121 The MongoDB World Series - Oli Proulx from ChargeHub Ep. 120 The MongoDB World Series - Simcha Coleman from Inspirit Ep. 119 The MongoDB World Series - David Sarabia from inRecovery Ep. 118 The MongoDB World Series - Nick Gamble from Unqork Ep. 117 The MongoDB World Series - Beray Bentesen from Qubitro Ep. 116 The MongoDB World Series - Vatsal Singhal from Ultrahuman Subscribe to The MongoDB Podcast wherever you listen to your podcasts so you can stay up to date with all our new episodes, dropping weekly. And if you are a tech expert or enthusiast with a passion for sharing your thoughts, opinions, and stories, connect with Michael Lynn to discuss a podcast guest opportunity.