33
1 Getting Started with Mongo DB & OpenShift Steve Citron-Pousty Developer Evangelist, Red Hat March 20, 2012 Aka Free Mongo applications for you!

Free Mongo on OpenShift

Embed Size (px)

DESCRIPTION

My talk to the Bay Area Mongo Users Group. It has a basic introduction to PaaS, OpenShift, and using Openshift, RockMongo, and MMS on OpenShift.

Citation preview

Page 1: Free Mongo on OpenShift

1

Getting Started with Mongo DB &

OpenShift

Steve Citron-PoustyDeveloper Evangelist, Red HatMarch 20, 2012

Aka Free Mongo applications for you!

Page 2: Free Mongo on OpenShift

2

Agenda

• What is OpenShift?

• Getting Started

• Using Mongo with OpenShift

• Next Steps

Page 3: Free Mongo on OpenShift

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, SpatialNew to: OpenShift and Mongo

Page 4: Free Mongo on OpenShift

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!!!!

Page 5: Free Mongo on OpenShift

5

What is OpenShift?

Red Hat’s free platform as a service for applications in the cloud.

Page 6: Free Mongo on OpenShift

6

Kind of like Amazon, right? Nope.

Page 7: Free Mongo on OpenShift

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?”

Page 8: Free Mongo on OpenShift

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!”

Page 9: Free Mongo on OpenShift

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!”

Page 10: Free Mongo on OpenShift

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

Page 11: Free Mongo on OpenShift

11

What’s supported?

Page 12: Free Mongo on OpenShift

12

How does it work?

• Install the client tools

• Create a domain name

• Create an application

• Congrats! You are now in the cloud!

rhc-create-app –a my_app –t my_lang

Page 13: Free Mongo on OpenShift

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!

Page 14: Free Mongo on OpenShift

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

Page 15: Free Mongo on OpenShift

15

So, Let’s Get Started!

1. Sign up

2. Install the client tools

3. Create a domain name

4. Create an application

Page 16: Free Mongo on OpenShift

16

DEMO – Finally!

Page 17: Free Mongo on OpenShift

17

So here are the steps1) 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

Page 18: Free Mongo on OpenShift

18

1. Sign Up!• openshift.com

• All it takes is an email address

• Promo Code: BAMUG

Page 19: Free Mongo on OpenShift

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

Page 20: Free Mongo on OpenShift

20

On the different platforms

Easy Cheesy on Linux machines

Mac you need to install the full Xcode

Windows…well a bit more work

Page 21: Free Mongo on OpenShift

21

Don’t have Cygwin installed?

Get it here: cygwin.com/install.html

Page 22: Free Mongo on OpenShift

22

Hold up, what’s Cygwin?

A Linux-like environment for Windows making it possible

to port software running on Linux systems to Windows.

Page 23: Free Mongo on OpenShift

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

Page 24: Free Mongo on OpenShift

24

2. Install the Client Tools on Windows

Next, download and extract rubygems from:

http://rubyforge.org/projects/rubygems

Page 25: Free Mongo on OpenShift

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

Page 26: Free Mongo on OpenShift

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

Page 27: Free Mongo on OpenShift

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

Page 28: Free Mongo on OpenShift

28

Some tech to help with more learning for OpenShift1. 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 pluginhttp://www.jboss.org/tools/download/dev

3. -bliss

4. Our new shiny web consolehttps://openshift.redhat.com/app/console

Page 29: Free Mongo on OpenShift

29

4. Create an Application

$ rhc app create –a <your app name> -t jbossas-7

Password:

Page 30: Free Mongo on OpenShift

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

Page 31: Free Mongo on OpenShift

31

GitHub

• Full featured applications on GitHub

• www.github.com/gshipley

• BeerShift

• www.github.com/openshift

• A whole bunch

Page 32: Free Mongo on OpenShift

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)

Page 33: Free Mongo on OpenShift

33

Next Steps

• Forum: redhat.com/openshift/community

• Email: [email protected]

• IRC: #openshift on freenode