1. Getting Started
with Mongo DB &
OpenShift
Aka Free Mongo applications for you!
Steve Citron-Pousty
Developer Evangelist, Red Hat
March 20, 2012
1
2. Agenda
• What is OpenShift?
• Getting Started
• Using Mongo with OpenShift
• Next Steps
2
3. My Goal for today
Introduce you to OpenShift
Get you comfortable with using the tools.
I want you to be ready to start writing apps
A bit about me:
Long time Java, RDBMS, Spatial
New to: OpenShift and Mongo
3
4. Assumptions
1) You might know some Mongo
2) You have a favorite programming language
3) You are comfortable with the command line (for now)
4) You might know GIT
5) You are unfamiliar with PaaS
PLEASE ASK QUESTIONS!!!!
4
5. What is OpenShift?
Red Hat’s free platform as a service for applications in the cloud.
5
7. What’s Infrastructure as a Service?
• Network, storage and compute offered as an on-
demand service
• Basically, servers in the cloud
• You’re still on the hook to configure & manage the
cloud & stack
• Example: Amazon EC2
“How do I use this?”
7
8. What’s Platform as a Service?
• It’s an application platform
• Basically, an app run-time environment in the cloud
• PaaS configures & manages the cloud & stack for you
• Example: OpenShift
“The cloud is now useful!”
8
9. What’s Software as a Service?
• It’s an on-demand application
• Nothing to install or configure
• Example: Salesforce, Gmail
“This is all my customers and users care about!”
9
10. So, why should I use a PaaS?
• Realize the benefits of the cloud quickly
• Let the PaaS configure, manage & scale the stack
• Make deployments to the cloud easy
• Focus on your app & users, not the stack
10
12. How does it work?
• Install the client tools
• Create a domain name
• Create an application
rhc-create-app –a my_app –t my_lang
• Congrats! You are now in the cloud!
12
13. Looks great, but how much does it
cost?
• OpenShift is free-as-in-beer
• Five 512 MB RAM / 1 GB Storage instances
• Need more resources, just ask!
13
14. But, First….
SSH
• To keep things secure we do most things over SSH
• You need to have your keys working properly
Git
• Is used to push changes to apps on OpenShift
• Is a distributed revision control and source code
management system
Builds
• Java – we use Maven
• For others we just copy from the git repo over
14
15. So, Let’s Get Started!
1. Sign up
2. Install the client tools
3. Create a domain name
4. Create an application
15
17. So here are the steps
1) Create an account on openshift.com using the web console
2) Create a Domain using the command line
• Remember your domain has to be unique to the
rhcloud.com namespace.
• It will be used in all your apps urls
3) Then go ahead and create an app
4) I am going to use eclipse to add other cartridges and edit the
source code
• Make sure to store the usernames and passwords for the
mongo and rockmongo
5) You can now modify the source and then commit and push to
remote repository
17
18. 1. Sign Up!
• openshift.com
• All it takes is an email address
• Promo Code: BAMUG
18
19. Now to install the client tools
On the openshift site:
OpenShift > Community > Knowledge Base > Installing
OpenShift Express client tools…
Basically
1. Install ruby and ruby gems
2. Gem install rhc
3. Make sure you have git and ssh
19
20. On the different platforms
Easy Cheesy on Linux machines
Mac you need to install the full Xcode
Windows…well a bit more work
20
21. Don’t have Cygwin installed?
Get it here: cygwin.com/install.html
21
22. Hold up, what’s Cygwin?
A Linux-like environment for Windows making it
possible
to port software running on Linux systems to Windows.
22
23. 2. Install the Client Tools on Windows
• What you are going to need: Cygwin
• Plus these cygwin components:
• openssh
• Ruby
• Git
• You will need all these for SSH and for advanced
command line usage. Eclipse plugin does a lot
23
24. 2. Install the Client Tools on Windows
Next, download and extract rubygems from:
http://rubyforge.org/projects/rubygems
24
25. 2. Install the Client Tools on Windows
• In Cygwin run:
$ ruby <path_to_extracted_rubygems>/setup.rb install
Cygwin is unix so your path looks like
c:/<path_to_extracted_rubygems>/setup.rb install
• Install the gem
$ gem install rhc
25
26. Quick Tip: Client Tool Commands
rhc-* : prefix for all commands
rhc-create-domain : Create a namespace
rhc-create-app : Create an application
rhc-ctl-app : Control an app and embed components
rhc-snapshot : Backup and restore an application
26
27. 3. Create a Domain Name
$ rhc domain create –n <your domain> -l <your login>
Password:
• When creating apps the URLs will look like this:
http://<app name>-<your domain>.rhcloud.com
Example: http://javarules-jgsdomain.rhcloud.com
27
28. Some tech to help with more learning for
OpenShift
1. Git – the source control and publishing system to
openshift.
For SVN users:
https://git.wiki.kernel.org/articles/g/i/t/GitSvnCrashCourse_512d.html
2. Eclipse tooling – use the latest Jboss Studio plugin
http://www.jboss.org/tools/download/dev
3. -bliss
4. Our new shiny web console
https://openshift.redhat.com/app/console
28
30. Mongo Specific awesomeness
RockMongo
MMS
Spatial is enabled
Sharding and replication are not running yet but they will
be by time we leave Beta
30
31. GitHub
• Full featured applications on GitHub
• www.github.com/gshipley
• BeerShift
• www.github.com/openshift
• A whole bunch
31
32. One more demo
A little bit of spatial goodness
Mongo has built in 2D spatial indexing capabilities
You can build your own FourSquare or similar app.
Quick demo of loading some spatial data on an
OpenShift Mongo Instance and then doing a query at
the command line (or in RockMongo)
32
33. Next Steps
• Forum: redhat.com/openshift/community
• Email: openshift@redhat.com
• IRC: #openshift on freenode
33