OpenShift Online 2.0 User Guide en US

80
Red Hat OpenShift Documentation Team OpenShift Online All Versions User Guide Managing Applications in the Cloud with OpenShift Online Edition 1.0

description

Managing Applications in the Cloud with OpenShift OnlineCopyright © 2013 Red Hat.This document is licensed by Red Hat under the Creative Commons Attribution-ShareAlike 3.0 Unported License. If you distribute this document, or a modified version of it, you must provide attribution to Red Hat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must be removed. https://www.openshift.com/documentation

Transcript of OpenShift Online 2.0 User Guide en US

Page 1: OpenShift Online 2.0 User Guide en US

Red Hat OpenShift Documentation Team

OpenShift Online All VersionsUser Guide

Managing Applications in the Cloud with OpenShift OnlineEdition 1.0

Page 2: OpenShift Online 2.0 User Guide en US

OpenShift Online All Versions User Guide

Managing Applications in the Cloud with OpenShift OnlineEdition 1.0

Red Hat OpenShift Documentation Team

Page 3: OpenShift Online 2.0 User Guide en US

Legal Notice

Copyright © 2013 Red Hat.

This document is licensed by Red Hat under the Creative Commons Attribution-ShareAlike 3.0 UnportedLicense. If you distribute this document, or a modified version of it, you must provide attribution to RedHat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must beremoved.

Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section4d of CC-BY-SA to the fullest extent permitted by applicable law.

Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, OpenShift, theInfinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and othercountries.

Linux ® is the registered trademark of Linus Torvalds in the United States and other countries.

Java ® is a registered trademark of Oracle and/or its affiliates.

XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United Statesand/or other countries.

MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and othercountries.

Node.js ® is an official trademark of Joyent. Red Hat Software Collections is not formally related to orendorsed by the official Joyent Node.js open source or commercial project.

All other trademarks are the property of their respective owners.

Abstract

This guide provides an introduction to OpenShift Online and documents its application managementfunctions.

Page 4: OpenShift Online 2.0 User Guide en US

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Table of Contents

Preface1. Document Conventions

1.1. Typographic Conventions1.2. Pull-quote Conventions1.3. Notes and Warnings

2. Getting Help2.1. Do You Need Help?2.2. We Need Feedback!

Chapter 1. Introduction1.1. Product Introduction1.2. Platform Overview

Chapter 2. Getting Started2.1. User Interfaces

2.1.1. Management Console2.1.2. Client Tools

2.2. Basic Administration2.2.1. Management Console2.2.2. Client Tools

Chapter 3. Authorization Tokens3.1. Authorization Tokens3.2. Creating Authorization Tokens3.3. Viewing Authorization Tokens3.4. Deleting Authorization Tokens

Chapter 4 . Domains4.1. About Domains4.2. Creating a Domain4.3. Listing Available Domains4.4. Viewing a Domain4.5. Renaming a Domain4.6. Deleting a Domain4.7. Custom Domains and SSL Certificates

4.7.1. Using Custom Domain Names4.7.2. Using Custom SSL Certificates

Chapter 5. Members5.1. About Members5.2. Adding a Member5.3. Listing Members5.4. Removing a Member

Chapter 6. Applications and Cartridges6.1. About Applications

6.1.1. About Scaled Applications6.1.1.1. How Scaling Works

6.1.2. About Non-Scaled Applications6.1.3. Viewing Accessible Applications

6.2. About Cartridges6.2.1. Web Cartridges6.2.2. Add-on Cartridges

55567778

999

11111112121213

1515151616

18181818191920212122

2323232324

252525252626272727

Table of Contents

1

Page 5: OpenShift Online 2.0 User Guide en US

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6.2.3. Downloadable Cartridges6.3. Creating an Application

6.3.1. Creating Scaled Applications6.3.2. Creating Single-Instance Applications6.3.3. Manually Scaling an Application

6.4. Adding and Managing Cartridges6.4.1. Adding Cartridges6.4.2. Managing Cartridges

6.4.2.1. Cartridge Action Hooks6.5. Deployment

6.5.1. Build and Deployment Action Hooks6.5.2. Preparing an Application for Deployment6.5.3. Deploying an Application6.5.4. Configuring Application Deployment

6.5.4.1. Deploying an Application From a Snapshot6.5.5. About Hot Deployment

6.5.5.1. Hot Deployment Build Details6.5.5.2. Enabling and Disabling Hot Deployment

6.5.6. JBoss Application Deployment6.5.6.1. Deploying on Java 6 or Java 76.5.6.2. Automatic Deployment6.5.6.3. Types of Marker Files6.5.6.4. Example JBoss Application Deployment Workflows

6.6. About Jenkins Online Build System6.6.1. Configuring Jenkins

6.6.1.1. Resource Requirements for Jenkins6.6.2. Creating Jenkins-enabled Applications

6.6.2.1. Creating a Scaled Jenkins-Enabled Application6.6.2.2. Creating a Single-Instance Jenkins-Enabled Application6.6.2.3. Confirming that a Jenkins-Enabled Application is Created

6.6.3. Building Applications with Jenkins6.6.3.1. Building Custom Applications

6.7. Deleting an Application6.7.1. Deleting Local Application Data

6.8. Gears and Storage Management6.8.1. Viewing Gear Storage6.8.2. Adding Gear Storage6.8.3. Set Gear Storage6.8.4. Removing Gear Storage6.8.5. Managing Application Disk Space

6.8.5.1. Disk Space Cleanup Tool

Chapter 7. Application Management7.1. Application Management Commands7.2. Managing Applications in a Secure Shell Environment

7.2.1. Accessing an Application7.2.2. Accessing a Specific Gear7.2.3. Accessing a Database Cartridge

7.3. Environment Variables7.3.1. Informational Environment Variables7.3.2. Directory Environment Variables7.3.3. Database Environment Variables7.3.4. Jenkins Environment Variables7.3.5. Gear Environment Variables7.3.6. JBoss Environment Variables7.3.7. Custom Environment Variables

2829303032333334343535363637383839394040414242434343444444444546464647474848494949

5151515152535455555657575758

OpenShift Online All Versions User Guide

2

Page 6: OpenShift Online 2.0 User Guide en US

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7.4. About Node.js Applications7.4.1. Repository Layout7.4.2. Installing Node Modules

7.5. Scheduling T imed Jobs with Cron7.6. Available Ports for Binding Applications

7.6.1. WebSocket Port Configuration7.6.2. Email Port Configuration

Chapter 8. Authentication and SSH Keys8.1. Viewing All Public Keys8.2. Viewing a Specific Public Key8.3. Generating Keys Manually8.4. Adding a Key

8.4.1. Creating a Specific SSH Key Type8.4.2. Removing a Key

8.5. Resolving Authentication Issues8.5.1. Resolving Issues with Interactive Setup Wizard

Chapter 9. Monitoring and Troubleshooting9.1. Monitoring Application Resources9.2. MongoDB Monitoring Service (MMS)

9.2.1. Configuring an Application with MMS9.2.2. Monitoring Applications with MMS

9.2.2.1. Adding Hosts to MMS9.2.2.2. MMS Monitoring with a Browser

9.3. Troubleshooting JBoss Applications9.3.1. Debugging with Thread Dumps9.3.2. Inspecting Server, Boot and Other Log Files

9.4. Performing Application Maintenance from Workstation9.4.1. Port Forwarding

9.4.1.1. Port Forwarding on Mac OS X

Chapter 10. Backing Up and Restoring Application Data10.1. Creating Application Snapshots10.2. Restoring Application Snapshots10.3. Migrating an Application to Another Gear

Revision History

59595960616363

646464656565666666

67676767686869696970717172

74747475

77

Table of Contents

3

Page 7: OpenShift Online 2.0 User Guide en US

OpenShift Online All Versions User Guide

4

Page 8: OpenShift Online 2.0 User Guide en US

Preface

1. Document ConventionsThis manual uses several conventions to highlight certain words and phrases and draw attention tospecific pieces of information.

In PDF and paper editions, this manual uses typefaces drawn from the Liberation Fonts set. TheLiberation Fonts set is also used in HTML editions if the set is installed on your system. If not, alternativebut equivalent typefaces are displayed. Note: Red Hat Enterprise Linux 5 and later include the LiberationFonts set by default.

1.1. Typographic ConventionsFour typographic conventions are used to call attention to specific words and phrases. Theseconventions, and the circumstances they apply to, are as follows.

Mono-spaced Bold

Used to highlight system input, including shell commands, file names and paths. Also used to highlightkeys and key combinations. For example:

To see the contents of the file my_next_bestselling_novel in your current workingdirectory, enter the cat my_next_bestselling_novel command at the shell promptand press Enter to execute the command.

The above includes a file name, a shell command and a key, all presented in mono-spaced bold and alldistinguishable thanks to context.

Key combinations can be distinguished from an individual key by the plus sign that connects each part ofa key combination. For example:

Press Enter to execute the command.

Press Ctrl+Alt+F2 to switch to a virtual terminal.

The first example highlights a particular key to press. The second example highlights a key combination:a set of three keys pressed simultaneously.

If source code is discussed, class names, methods, functions, variable names and returned valuesmentioned within a paragraph will be presented as above, in mono-spaced bold. For example:

File-related classes include filesystem for file systems, file for files, and dir fordirectories. Each class has its own associated set of permissions.

Proportional Bold

This denotes words or phrases encountered on a system, including application names; dialog-box text;labeled buttons; check-box and radio-button labels; menu titles and submenu titles. For example:

Choose System → Preferences → Mouse from the main menu bar to launch MousePreferences. In the Buttons tab, select the Left-handed mouse check box and clickClose to switch the primary mouse button from the left to the right (making the mousesuitable for use in the left hand).

To insert a special character into a gedit file, choose Applications → Accessories →

Preface

5

Page 9: OpenShift Online 2.0 User Guide en US

Character Map from the main menu bar. Next, choose Search → Find… from theCharacter Map menu bar, type the name of the character in the Search field and clickNext. The character you sought will be highlighted in the Character Table. Double-clickthis highlighted character to place it in the Text to copy field and then click the Copybutton. Now switch back to your document and choose Edit → Paste from the gedit menubar.

The above text includes application names; system-wide menu names and items; application-specificmenu names; and buttons and text found within a GUI interface, all presented in proportional bold and alldistinguishable by context.

Mono-spaced Bold Italic or Proportional Bold Italic

Whether mono-spaced bold or proportional bold, the addition of italics indicates replaceable or variabletext. Italics denotes text you do not input literally or displayed text that changes depending oncircumstance. For example:

To connect to a remote machine using ssh, type ssh [email protected] at a shellprompt. If the remote machine is example.com and your username on that machine isjohn, type ssh [email protected] .

The mount -o remount file-system command remounts the named file system. Forexample, to remount the /home file system, the command is mount -o remount /home.

To see the version of a currently installed package, use the rpm -q package command. Itwill return a result as follows: package-version-release.

Note the words in bold italics above: username, domain.name, file-system, package, version and release.Each word is a placeholder, either for text you enter when issuing a command or for text displayed bythe system.

Aside from standard usage for presenting the title of a work, italics denotes the first use of a new andimportant term. For example:

Publican is a DocBook publishing system.

1.2. Pull-quote ConventionsTerminal output and source code listings are set off visually from the surrounding text.

Output sent to a terminal is set in mono-spaced roman and presented thus:

books Desktop documentation drafts mss photos stuff svnbooks_tests Desktop1 downloads images notes scripts svgs

Source-code listings are also set in mono-spaced roman but add syntax highlighting as follows:

OpenShift Online All Versions User Guide

6

Page 10: OpenShift Online 2.0 User Guide en US

package org.jboss.book.jca.ex1;

import javax.naming.InitialContext;

public class ExClient{ public static void main(String args[]) throws Exception { InitialContext iniCtx = new InitialContext(); Object ref = iniCtx.lookup("EchoBean"); EchoHome home = (EchoHome) ref; Echo echo = home.create();

System.out.println("Created Echo");

System.out.println("Echo.echo('Hello') = " + echo.echo("Hello")); }}

1.3. Notes and WarningsFinally, we use three visual styles to draw attention to information that might otherwise be overlooked.

Note

Notes are tips, shortcuts or alternative approaches to the task at hand. Ignoring a note shouldhave no negative consequences, but you might miss out on a trick that makes your life easier.

Important

Important boxes detail things that are easily missed: configuration changes that only apply to thecurrent session, or services that need restarting before an update will apply. Ignoring a boxlabeled “Important” will not cause data loss but may cause irritation and frustration.

Warning

Warnings should not be ignored. Ignoring warnings will most likely cause data loss.

2. Getting Help

2.1. Do You Need Help?If you experience difficulty with a procedure or other information described in this documentation, visit theRed Hat Customer Portal at http://access.redhat.com where you can:

search or browse through a knowledgebase of technical support articles about Red Hat products

submit a support case to Red Hat Global Support Services (GSS)

access other product documentation

Preface

7

Page 11: OpenShift Online 2.0 User Guide en US

You can also access the OpenShift web site at https://openshift.redhat.com/ to find blogs, FAQs, forums,and other sources of information.

Red Hat also hosts a large number of electronic mailing lists for discussion of Red Hat software andtechnology. You can find a list of publicly available mailing lists at https://www.redhat.com/mailman/listinfo.Click the name of any mailing list to subscribe to that list or to access the list archives.

2.2. We Need Feedback!If you find a typographical or any other error in this manual, or if you have thought of a way to make thismanual better, we would love to hear from you! Please submit a report in Bugzilla:http://bugzilla.redhat.com/ against the product Openshift Online.

When submitting a bug report, be sure to mention the manual's identifier: Docs User Guide

If you have a suggestion for improving the documentation, try to be as specific as possible whendescribing it. If you have found an error, please include the section number and some of the surroundingtext so we can find it easily.

OpenShift Online All Versions User Guide

8

Page 12: OpenShift Online 2.0 User Guide en US

Chapter 1. Introduction

1.1. Product IntroductionOpenShift Online by Red Hat is a Platform as a Service (PaaS) that enables developers to build anddeploy web applications. OpenShift Online provides a wide selection of programming languages andframeworks including Java, Ruby, and PHP. It also provides integrated developer tools to support theapplication life cycle, including Eclipse integration, JBoss Developer Studio, and Jenkins. OpenShiftOnline uses an open source ecosystem to provide a platform for mobile applications, database services,and more.

OpenShift Online is built on Red Hat Enterprise Linux, which provides integrated application runtimesand libraries and a secure and scalable multi-tenant operating system for addressing the needs ofenterprise-class applications.

This document describes how to navigate and use an OpenShift Online environment. It providesinformation on overall architecture, common application management tasks, and basic troubleshooting. Itis intended for developers and application administrators.

Report a bug

1.2. Platform OverviewOpenShift Online enables you to create, deploy and manage applications online. It provides disk space,CPU resources, memory, network connectivity, and an Apache or JBoss server. For most types ofapplications, OpenShift Online creates a file system layout that you can use as a template for building anapplication. OpenShift Online also generates a limited Domain NameSpace (DNS) so that yourapplication is accessible online.

The two main functional units of OpenShift Online are the broker and cartridges.

Broker

The broker is responsible for managing user logins, DNS, and application state. Users interact with thebroker using the Management Console, command line interface tools, or a REST-based API.

Cartridges

Cartridges provide the functionality to run applications. Numerous cartridges are currently available tosupport languages such as Perl, PHP, and Ruby, as well as many database cartridges such asPostgreSQL and MySQL.

System Resources and Application Containers

The system resources and security containers provided by the OpenShift Online platform are gears andnodes.

Gears provide a resource-constrained container where you can run one or more cartridges. Theydetermine the amount of RAM and disk space available to a cartridge.

OpenShift Online currently provides three gear sizes:

Small gears provide 512MB of RAM, 100MB of swap space, and 1GB of disk space

Medium gears provide 1GB of RAM, 100MB of swap space, and 1GB of disk space

Large gears provide 2GB of RAM, 100MB of swap space, and 1GB of disk space

Chapter 1. Introduction

9

Page 13: OpenShift Online 2.0 User Guide en US

Large gears provide 2GB of RAM, 100MB of swap space, and 1GB of disk space

By default, you can use up to three small gears (a total of 1.5GB of RAM and 3GB of disk space).OpenShift Online can assign these three gears to a single application and its cartridges (Cron, MySQL,etc.), use each gear for a separate application, or use the gears for scaling an application.

Nodes enable resource sharing so that multiple gears can run on a single physical or virtual machine.This machine is referred to as a node host.

Report a bug

OpenShift Online All Versions User Guide

10

Page 14: OpenShift Online 2.0 User Guide en US

Chapter 2. Getting Started

2.1. User Interfaces

2.1.1. Management ConsoleThe OpenShift Online Management Console is a graphical interface accessed with a web browser athttps://www.openshift.com/. The management console is best suited for:

The Management Console is best suited for:

Setting up, administering and managing accounts

Launching new applications

Managing and monitoring applications

The following screenshot shows the home page of the Management Console when you first log into youraccount. Each tab across the top navigation bar provides further functionality to help you manage youraccount, applications, and more.

Figure 2.1. Management Console

The table below provides a brief description of the different pages and settings available in theManagement Console.

Page Description

Applications View and manage your applications and cartridges. If you do not have anyapplications, you can create new applications from this page.

Settings View and manage SSH keys, domains, and account authorizations.

Help Access to KBase articles, community forums, tutorials, and other communityresources. A wide variety of resources are available for diagnosing andresolving issues with your account or your applications.

My Account View and manage account information, including account upgrades. Thispage shows your account details, subscription plan, and your account

Chapter 2. Getting Started

11

Page 15: OpenShift Online 2.0 User Guide en US

usage. Red Hat technical support is available from here if you aresubscribed to the upgraded plan.

Note that the Management Console currently provides limited functionality. Therefore, most of theinstructions in this guide are for the client tools. However, tasks that can be performed in theManagement Console will be highlighted accordingly in their respective sections.

An OpenShift Online user account is required for creating and managing applications within a uniquenamespace. This guide assumes a user account is already set up and configured.

Report a bug

2.1.2. Client ToolsThe OpenShift Online CLI tools, or more commonly referred to as the client tools, are used to manage acloud environment using a command line interface, and provide features that are not currently availablein the Management Console. The client tools are best suited for:

Coding

Debugging

Advanced application management

For example, although you can create an application using the Management Console, the applicationmust be cloned to your workstation to make any code changes, and then redeployed to the remoteserver using the client tools.

This guide assumes the client tools are already installed and configured. See the OpenShift OnlineClient Tools Installation Guide for instructions on how to install and configure the client tools.

For a full list of client tool commands, run rhc --help.

Report a bug

2.2. Basic AdministrationYou can manage your account using either the Management Console or client tools.

Report a bug

2.2.1. Management ConsoleThe OpenShift Online Management Console is used for most account administrative tasks, with some ofthe more common tasks described below.

Changing a Password

Navigate to the My Account page, and click Change your settings to change your password.

Managing Subscription Plans

Navigate to the My Account page, and click Plan Details to view your current plan, and to view theavailable upgrade and downgrade options.

Account Help and Technical Support

There are two types of help and support available based on the type of subscription plan.

OpenShift Online All Versions User Guide

12

Page 16: OpenShift Online 2.0 User Guide en US

Silver PlanNavigate to the My Account page, and click Account Help to access the help page. If theproblem is not addressed in the frequently asked questions list, submit your account-relatedquestions using the Submit a question regarding your account box.

For technical support, visit the Red Hat Customer Portal athttps://access.redhat.com/support/offerings/openshift/. You can also go to the OpenShift OnlineForum at https://www.openshift.com/forums/openshift or log on to IRC on Freenode (#openshift)for support.

Note

You are prompted to accept the terms and conditions when accessing Red HatCustomer Portal for the first time.

Free PlanClick Help to access the help page. This page gives out information about how to get startedwith OpenShift Online, explore the OpenShift Online platform, basic troubleshooting, and gettinginvolved with the OpenShift Online community.

Type in a keyword in the Search the forums box to access the Knowledge Base for knownissues and general questions. You can also go to the OpenShift Online Forum athttps://www.openshift.com/forums/openshift or log on to IRC on Freenode (#openshift) forsupport.

Report a bug

2.2.2. Client ToolsAlthough using the OpenShift Online Management Console for account administration is recommended,the following tasks can be performed using the client tools.

Viewing Account Details

Use the rhc account command to get an overview of the currently logged in user and theircapabilities:

$ rhc account

Server: broker.example.com Login: demo Gears Used: 1 Gears Allowed: 100 Allowed Gear Sizes: small SSL Certificates Supported: no

You can also view account details in the Management Console by navigating to the My Account page.

Chapter 2. Getting Started

13

Page 17: OpenShift Online 2.0 User Guide en US

Note

The rhc package found in the OpenShift Online client tools channel is based on the RHEL6 rpmversion of the client tools, and not the Ruby gem version, which are updated more frequently. Thisleads to updated features being temporarily only available in the Ruby gem version. To ensureyou have the latest version and all available features, see the OpenShift Online Client ToolsInstallation Guide for the Ruby gem installation method.

Ending the Current Session

Use the rhc logout command to end the current session with the OpenShift Online server andremove all local session files:

$ rhc logout

Ending session on server ... deletedAll local sessions removed.

Report a bug

OpenShift Online All Versions User Guide

14

Page 18: OpenShift Online 2.0 User Guide en US

Chapter 3. Authorization Tokens

3.1. Authorization TokensAn authorization token is a secret value that is used with an OpenShift Online account without enteringlogin information. A token is also used to grant another user full or partial access to your accountdepending on the token's scope. The table below describes the different types of scopes available withauthorization tokens.

Table 3.1. Authorization Token Scopes

Scope Description Validity

session Access to all API functions against an account. 1 day

read Read-only access to account resources, but cannot view authorizationtokens.

1 month

userinfo Access to login name, unique id, and user capabilities. 1 month

When the client tools are installed and the rhc setup command is initially run to configure the clienttools, the setup wizard prompts you to create an authorization token. If you answer YES, the wizardcreates a session token in the ~/.openshift directory. With this token, all client tool commands canbe run without entering your login credentials each time. When the token expires the client toolsautomatically prompt you to renew the token by reentering your login information. See the Client ToolsInstallation Guide for more information on installing and configuring the client tools.

If an authorization token was not created during the client tools installation process, use the rhc setupcommand to run the setup wizard again to create one.

If an existing authorization token is no longer required and you do not wish to be prompted for tokenrenewal, run the rhc logout command to delete the token.

Management Console

Authorization tokens can be managed in the Management Console. Click Settings in the navigationbar to view a list of current authorization tokens for your account. From this page you can add newtokens, edit current tokens, and delete tokens.

Report a bug

3.2. Creating Authorization TokensRun the rhc authorization add command to create a new token. Specify the scope for the tokenwith the --scopes option, and a name for the token with the --note option:

Chapter 3. Authorization Tokens

15

Page 19: OpenShift Online 2.0 User Guide en US

$ rhc authorization add --scopes session --note My_token

Adding authorization ... done

My_token-------- Token: 787a57211d42f251204136b05d490038830d9b7057f54f816c2a9fcd0c8333b8 Scopes: session Created: 4:40 PM Expires In: about 1 day

After creating a new authorization token, use the --token token_string global option to run rhccommands as the user associated with the authorization token you provide.

Report a bug

3.3. Viewing Authorization TokensView the tokens associated with your account using the rhc authorization command:

$ rhc authorization

My_token-------- Token: 787a57211d42f251204136b05d490038830d9b7057f54f816c2a9fcd0c8333b8 Scopes: session Created: 4:40 PM Expires In: about 23 hours

RHC/1.8.0 (from laptop.example.com on x86_64-linux)--------------------------------------------------- Token: 28f6e375dc7ea57b0dcabb3850d08ee9bc023f7df5dbfa4958afe7ad71d33e37 Scopes: session Created: 12:58 PM Expires In: about 19 hours

Report a bug

3.4. Deleting Authorization TokensFollow the instructions below to delete authorization tokens when they are no longer required, or whenyou no longer wish to grant access to your account to other users.

Delete Specific Authorization Tokens

Run the rhc authorization delete command to delete one or multiple tokens:

$ rhc authorization delete token_1, token_2

Deleting authorization ... done

Delete All Authorization Tokens

Run the rhc authorization delete-all command to delete all the tokens associated with youraccount:

OpenShift Online All Versions User Guide

16

Page 21: OpenShift Online 2.0 User Guide en US

Chapter 4. Domains

4.1. About DomainsAn OpenShift Online domain forms part of an application's URL and is unique to your account. Thesyntax for an application URL is application-domain.example.com. Each user name supports a singledomain, but you can create multiple applications within the domain. Note that you must create a domainbefore you can create an application.

OpenShift Online uses a blacklist to restrict the domains available to you. The blacklist is maintained onthe server. A message warns you that you have chosen a blacklisted name and asks you to choose adifferent domain if you try to create or alter a domain using a blacklisted name.

Domains consist of a maximum of 16 alphanumeric characters and cannot have spaces or symbols.

Management Console

Click Settings in the navigation bar to view domain management options and manage domains in theManagement Console.

Report a bug

4.2. Creating a DomainRun the rhc domain create command to create a new domain:

$ rhc domain create automobile

Creating domain 'automobile'

You may now create an application using the 'rhc app create' command

This command will create the domain automobile.

Note

Silver Plan users can create multiple domains. You are unable to create more domains than youraccount limit (Silver plan users can use up to 16 gears at any time). You will receive a messagewhen you try to go beyond the allowed limitations of your account.

Report a bug

4.3. Listing Available DomainsRun the rhc domain list command to see all available domains.

OpenShift Online All Versions User Guide

18

Page 22: OpenShift Online 2.0 User Guide en US

$ rhc domain listDomain automobile--------------- Created: Oct 01 7:28 PM Allowed Gear Sizes: small, medium

Domain automobile2----------------- Created: Oct 01 7:46 PM Allowed Gear Sizes: small, medium

Alternatively, run the rhc domains command to list all available domains.

Report a bug

4.4. Viewing a DomainRun the rhc domain show command to view information about a domain.

$ rhc domain showDomain automobile--------------- Created: Oct 01 7:28 PM Allowed Gear Sizes: small, medium

racer @ http://racer-automobile.example.com/ (uuid: 926056f8845b4e388b37f6735c89d0eb) ----------------------------------------------------------------------------- Domain: automobile Created: Oct 01 7:28 PM Gears: 2 (defaults to small) Git URL: ssh://[email protected]/~/git/racer.git/ SSH: [email protected]

php-5.3 (PHP 5.3) ----------------- Scaling: x2 (minimum: 2, maximum: 2) on small gears

You have 1 application in your domain.

If you have multiple domains, you can specify which domain you would like to view by adding the -n(namespace) option, followed by the name of the domain you would like to view.

$ rhc domain show -n automobile

Report a bug

4.5. Renaming a DomainBecause renaming a domain deletes the old domain and creates a new one, you must first ensure thedomain to be renamed does not contain any applications. When the domain is empty, run the rhc domain rename command to alter it.

Chapter 4. Domains

19

Page 23: OpenShift Online 2.0 User Guide en US

Procedure 4 .1. To Rename a Domain

1. Ensure the domain does not contain any applications.

$ rhc appsNo applications. Use 'rhc app create'.

If any applications are listed, use the rhc app delete command to remove them.

$ rhc app delete App_Name

Warning

Application removal is not reversible. All remote data associated with the application isdeleted and cannot be recovered.

2. Use the rhc domain rename command to alter the domain.

$ rhc domain rename Old_Domain_Name New_Domain_NamePassword: *******

Renaming domain 'Old_Domain_Name' to 'New_Domain_Name'... doneApplications in this domain will use the new name in their URL.

Report a bug

4.6. Deleting a DomainIf a particular domain is no longer needed, run the rhc domain delete command to delete it. Beforeyou can delete a domain, you need to ensure it does not contain any applications.

Procedure 4 .2. To Delete a Domain

1. Ensure the domain does not contain any applications.

$ rhc domain show Domain_Name

If any applications are listed, use the rhc app delete command to remove them.

$ rhc app delete App_Name

Warning

Application removal is not reversible. All remote data associated with the application isdeleted and cannot be recovered.

2. Use the rhc domain delete command to delete the domain.

OpenShift Online All Versions User Guide

20

Page 24: OpenShift Online 2.0 User Guide en US

$ rhc domain delete Domain_Name

Deleting domain 'Domain_Name' ... deleted

After you delete a domain, you must create a new one before creating any new applications.

Report a bug

4.7. Custom Domains and SSL CertificatesOpenShift Online enables you to designate custom domain aliases for applications to use your own DNSentries instead of using the domain generated for you by the system. For the alias to work correctly,ensure you have a CNAME record with your DNS provider.

For added security, you can use custom SSL certificates with domain aliases. Note that custom SSLcertificates are only available to users with upgraded OpenShift Online accounts.

Management Console

Click on an application name in the My Applications tab in the Management Console to view customdomain name and SSL certificate management options for the selected application.

Report a bug

4.7.1. Using Custom Domain Names

Adding a Custom Domain Name

Add domain name aliases to applications using the rhc alias add App_Name Alias command:

$ rhc alias add racer fast.cars.com

RESULT:Alias 'fast.cars.com' has been added.

Viewing Custom Domain Names

View domain name aliases and SSL Certificate status using the rhc alias list App_Namecommand:

$ rhc alias list racer

Alias Has Certificate? Certificate Added------------- ---------------- -----------------fast.cars.com yes 2013-08-05quick.cars.com no -

Removing a Custom Domain Name

Remove domain name aliases from applications using the rhc alias remove App_Name Aliascommand:

Chapter 4. Domains

21

Page 25: OpenShift Online 2.0 User Guide en US

$ rhc alias remove racer fast.cars.com

RESULT:Alias 'fast.cars.com' has been removed.

Report a bug

4.7.2. Using Custom SSL Certificates

Adding a Custom SSL Certificate

Add a custom SSL certificate to an alias using the rhc alias update-cert command. If the privatekey is encrypted, specify the passphrase with the --passphrase option.

$ rhc alias update-cert racer fast.cars.com --certificate Cert_File --private-key Key_File

RESULT:SSL certificate successfully added.

Viewing Custom SSL Certificate Status

View domain name aliases and SSL Certificate status using the rhc alias list App_Namecommand:

$ rhc alias list racer

Alias Has Certificate? Certificate Added------------- ---------------- -----------------fast.cars.com yes 2013-08-05quick.cars.com no -

Removing a Custom SSL Certificate

Remove a custom SSL certificate from an alias using the rhc alias delete-cert App_Name Aliascommand:

$ rhc alias delete-cert racer fast.cars.comThis is a non-reversible action! Your SSL certificate will be permanently deleted from application 'racer'.

Are you sure you want to delete the SSL certificate? (yes|no): yes

RESULT:SSL certificate successfully deleted.

Report a bug

OpenShift Online All Versions User Guide

22

Page 26: OpenShift Online 2.0 User Guide en US

Chapter 5. Members

5.1. About MembersDeveloper teams can work collaboratively on applications with domain memberships. There are threeroles available in domain membership:

ViewMember has read-only access to view information about the domain and its applications andcannot make any changes.

EditMember can create, update, and delete all applications in the domain, and has Git and SSHaccess.

AdministerMember has access to all features, but cannot change allowed gear sizes or edit the domainname.

Each member is given the edit role by default. Use the rhc member add command with the --roleoption to change the role of a member, and specify the desired role to change to.

Management Console

Click the Settings tab in the Management Console to view a list of available domains and managedomain members. Click on the desired domain to view applications, members, gears and allowed gearsizes, and the add-on cartridges of an application. From here you can manage membership options,such as adding a member, and editing a member's role.

Report a bug

5.2. Adding a MemberRun the rhc member add command to add a member to a domain, specifying the user login anddomain name:

$ rhc member add [email protected] -n automobileAdding 1 editor to domain ... done

The default role for the new member is edit. To update the role of the member, run the command withthe --role option, followed by either view, edit, or admin depending on the desired role.

Report a bug

5.3. Listing MembersRun the rhc member list command to list the existing members of a domain. You can specify thedesired domain name with the -n option, or the desired application with the -a option.

Chapter 5. Members

23

Page 28: OpenShift Online 2.0 User Guide en US

Chapter 6. Applications and Cartridges

6.1. About ApplicationsWhen an OpenShift Online application is created, a domain-namespace name that is a combination ofthe application name and the domain name is registered in DNS. A copy of the application code ischecked out locally in a folder with the same name as the application created. OpenShift Online runs thecomponents of the application on small virtual servers, referred to as "gears".

The table below describes each component that makes up an OpenShift Online application.

Table 6.1. Application Components

Component Description

Domain The domain provides a unique group identifier for all the applications of aspecific user. The domain is not directly related to DNS; instead, it isappended to the application name to form a final application URL of the formhttp://[APP_NAME]-[DOMAIN].example.com

Application Name The name of the application is selected by a user. The final URL to accessthe application is of the form http://[APP_NAME]-[DOMAIN].example.com

Alias DNS names can be provided for the application by registering an alias withOpenShift Online and pointing the DNS entry to the OpenShift Onlineservers.

Git repository Used to modify application code locally. Once the code is applied, the git push command is run to deploy the revised code.

OpenShift Online provides dedicated /var/tmp and /tmp directories for each user application. The /var/tmp directory is a symbolic link to /tmp. Each /tmp directory is completely isolated from the /tmp directories of all other applications. OpenShift Online deletes files in these directories that areuntouched for any 10-day period.

Report a bug

6.1.1. About Scaled ApplicationsApplication scaling enables the automatic allocation of resources based on demand. OpenShift Onlinemonitors the resource requirements of scaled applications, and increases or decreases availableresources accordingly. An application must be defined as scaled or non-scaled at the time of creation. Ascaled application cannot be converted to a non-scaled application. Likewise, a non-scaled applicationcannot be converted to a scaled application.

Report a bug

6.1.1.1. How Scaling WorksEach application created on OpenShift Online always has the web cartridge associated with it. The webcartridge can, for example, be a PHP cartridge. When an application is scaled, a second cartridge, calledHAProxy, is added to the application. The HAProxy cartridge listens to all incoming web page requestsfor an application and passes them on to the web cartridge, following defined guidelines for loadmonitoring.

As the number of web page requests to an application increase, the HAProxy will inform OpenShiftOnline when an overload of requests is detected. OpenShift Online will then create a copy of the existing

Chapter 6. Applications and Cartridges

25

Page 29: OpenShift Online 2.0 User Guide en US

web cartridge on a separate gear. In such a case, the web cartridge now has been scaled up two times.This process is repeated as more web page requests are detected by the HAProxy cartridge, and eachtime a copy of the web cartridge is created on a separate gear, the application scale factor increases byone.

If an application's ratio of total number of gears to HAProxy gears is ever greater than two, the HAProxycartridges' routing function is disabled to the web cartridges collocated on their gear. This allows fullgear resource usage for the HAProxy cartridges, which continue routing requests to other gears' webcartridges. If the ratio returns to two or below, routing to the HAProxy gears' web cartridges is re-enabled.

Figure 6.1. Cartridges on Gears in a Scaling Application

Report a bug

6.1.2. About Non-Scaled ApplicationsWhen a non-scaled application is created, it only consumes one of the default quota of gears assignedto users. That is, it only consumes one of the available three gears. On the other hand, a scaledapplication consumes two of the available gears; one for the high-availability proxy (HAProxy) itself, andone for the actual application. When MySQL is added to an application, it is installed in its own dedicatedgear.

Report a bug

6.1.3. Viewing Accessible ApplicationsRun the rhc apps command to display information about all the applications you have access to:

$ rhc appsracer @ http://racer-automobile.example.com/ (uuid: 926056f8845b4e388b37f6735c89d0eb)------------------------------------------------------------------------------------- Domain: automobile Created: Dec 19 10:20 PM Gears: 1 (defaults to small) Git URL: ssh://[email protected]/~/git/racer.git/ SSH: [email protected] Deployment: auto (on git push)

php-5.3 (PHP 5.3) ----------------- Gears: 1 small

OpenShift Online All Versions User Guide

26

Page 30: OpenShift Online 2.0 User Guide en US

Report a bug

6.2. About CartridgesCartridges are the components of an OpenShift Online application. They include databases, buildsystems, and have management capabilities. Adding a cartridge to an application provides the desiredcapability without having to administer or update the included feature.

To view a list of available cartridges, run the rhc cartridge list command.

Report a bug

6.2.1. Web CartridgesEvery OpenShift Online application created must have one web cartridge to serve web requests. Webcartridges can only be added to new applications and are available for a variety of programminglanguages and frameworks.

Run the rhc cartridge list command to view the current list of available web cartridges. Currently,there are a number of web cartridges available for OpenShift Online.

Scalable Web Cartridges

JBoss AS

JBoss EAP

Node.js

Perl

PHP

Python

Ruby

Tomcat (JBoss EWS)

Non-Scalable Web Cartridges

Zend Server

Jenkins Server

Do-It-Yourself (DIY)

Report a bug

6.2.2. Add-on CartridgesAfter an OpenShift Online application is created with the required web cartridge, a number of othercartridges can be added that provide capabilities such as databases, scheduled jobs, or continuousintegration. The table below describes the functionality of the different types of add-on cartridgesavailable with OpenShift Online.

Chapter 6. Applications and Cartridges

27

Page 31: OpenShift Online 2.0 User Guide en US

Table 6.2. Add-on Cartridge Functions

Function Description

Database Provide the application with one of several database back ends. Examplesinclude MySQL and PostgreSQL.

Database management Provide functionality for managing the application's database using third-party software. Examples include HAProxy.

Monitoring andManagement

Provide a range of options for managing and monitoring the application.Examples include the Cron task scheduler, and the Jenkins Client.

Run the rhc cartridge list command to view the current list of available add-on cartridges.Currently, the following add-on cartridges are available:

Database Cartridges

Scalable Database Cartridges

MySQL database is a multi-user, multi-threaded SQL database server.

MongoDB NoSQL database is a scalable, high-performance, open source NoSQL database.

PostgreSQL 8 database is an advanced object-relational database management system.

Management Cartridges

Scalable Management Cartridges

phpMyAdmin 3 is a web-based MySQL administration tool.

HAProxy 1 is a high performance TCP/HTTP load balancer.

Cron 1 is a daemon that runs specified programs at scheduled times.

SwitchYard 0 is a lightweight service delivery framework providing full lifecycle support fordeveloping, deploying, and managing service-oriented applications.

Non-Scalable Management Cartridges

RockMongo 1 is a web-based MongoDB administration tool.

Jenkins Client 1 is a client for managing Jenkins-enabled applications.

OpenShift Metrics 0 is an experimental cartridge for monitoring applications.

Report a bug

6.2.3. Downloadable CartridgesIn addition to the supported standard cartridges available in OpenShift Online, downloadable cartridgescan also be deployed into new or existing applications. Downloadable cartridges can be customcartridges created by a user or community cartridges found in the OpenShift community. By providing theURL to the hosted downloadable cartridge's manifest in the Management Console or client tools,OpenShift Online will download and install the cartridge to the application.

Usage steps for downloadable cartridges are provided in Section 6.3, “Creating an Application”. Seehttps://www.openshift.com/developers/download-cartridges for more community tips and solutionssurrounding downloadable cartridges.

Report a bug

OpenShift Online All Versions User Guide

28

Page 32: OpenShift Online 2.0 User Guide en US

6.3. Creating an ApplicationBefore creating an application, there are certain options to be considered. These options includewhether you wish to enable scaling and the type of web cartridge. For example, you will not be able toenable scaling or change the type of web cartridge after an application is created.

Management Console

Click on the Applications tab in the Management Console to show a list of your applications, andcreate new applications. From there, click on the Add Application button to start creating anapplication. If you have no applications, you will automatically be directed to the Create an Applicationpage.

After creating an application with the Management Console, run the rhc git-clone command to copythe application's remote repository into a local working directory.

$ rhc git-clone App_NameCloning into 'App_Name'...Your application Git repository has been cloned to '/home/apps/App_Name'

The rhc git-clone command copies the template application files from the remote repository into theworking directory. Edit the template application files to suit the application.

Client Tools

When creating applications with the client tools, the rhc app create command creates a newapplication by populating a remote Git repository with the selected cartridge and clones the repository tothe current directory on the local machine. The command also adds the host name and IP address of theapplication to the list of known hosts (~/.ssh/known_hosts).

The rhc app create command can be used with several optional parameters that customize theconfiguration of an application when it is created. Note that some of these options, such as ability toselect larger gear sizes for the cartridges, are only available to users with upgraded plans. See rhc app create --help for a complete list of options.

Prerequisites

Application creation requires a reliable network connection. The rhc app create command onlymakes a single attempt to create an application. OpenShift Online makes up to seven checks for theDNS entry to exist, and returns a failure message if not found.

The --timeout option on the command line is used to override the default values when there areconstant timeout issues. OpenShift Online uses two timeout parameters: a connection timeout, whichdetermines how long the client tries to connect to the server before timing out; and a read timeout, whichdetermines how long the client waits for a response from the server. The default connection timeoutvalue is 20 seconds. The default read timeout value is 120 seconds.

The --timeout option affects both timeout parameters, but it can only be used to increase values fromthe default. The timeout value cannot be set to be less than the default. For example, if --timeout 50is used, it sets the connection timeout value to 50 seconds, but does not affect the read timeout value.Similarly, if --timeout 150 is used, it sets both the connection and read timeout values to 150seconds.

Report a bug

Chapter 6. Applications and Cartridges

29

Page 33: OpenShift Online 2.0 User Guide en US

6.3.1. Creating Scaled ApplicationsScaled applications automatically allocate resources based on demand. Use the rhc app createcommand with the -s (or --scaling) option to create a scaled application. See Section 6.1.1, “AboutScaled Applications” for more information. Note that if a cartridge type is specified with multiple versions,the client tools prompt to specify the version to use. The following command will create a scaledapplication named hybrid.

$ rhc app create hybrid php-5.3 -sApplication Options------------------- Namespace: automobile Cartridges: php-5.3 Gear Size: default Scaling: yes

Creating application 'hybrid' ... done

Waiting for your DNS name to be available ... done

Cloning into 'hybrid' ...The authenticity of host 'hybrid-automobile.example.com (21.20.161.211)' can't be established.RSA key fingerprint is cf:eb:77:cb:0b:fc:02:d7:72:7b:ab:80:c0:90:88:b7.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'hybrid-automobile.example.com,21.20.161.211' (RSA) to the list of known hosts.

Your application 'hybrid' is now available.

URL: ssh://[email protected]/~/git/hybrid.git/SSH to: [email protected] remote: ssh://[email protected]/~/git/hybrid.git/Cloned to: /home/User/hybrid

Run 'rhc show-app hybrid' for more details about your app.

When a scaled application is created, the automatic scaling feature is enabled by default. However, anapplication can be manually scaled to control the number of gears being used.

If you have more than one domain, specify the domain in which you wish to create the application byusing the -n (namespace) option:

$ rhc app create hybrid php -n Domain_Name

Report a bug

6.3.2. Creating Single-Instance ApplicationsThe following example demonstrates the creation of a non-scaled PHP application called racer. Notethat if a cartridge type is specified with multiple versions, the client tools prompts to specify the versionto use.

OpenShift Online All Versions User Guide

30

Page 34: OpenShift Online 2.0 User Guide en US

$ rhc app create racer php-5.3Application Options------------------- Domain automobile Cartridges: php-5.3 Gear Size: default Scaling: no

Creating application 'racer' ... done

Waiting for your DNS name to be available ... done

Cloning into 'racer' ...The authenticity of host 'racer-automobile.example.com (21.26.220.40)' can't be established.RSA key fingerprint is bf:eb:77:cb:0b:fc:02:b7:72:7e:ab:80:c0:90:88:a7.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'racer-automobile.example.com,21.26.220.40' (RSA) to the list of known hosts.

Your application 'racer' is now available.

URL: ssh://[email protected]/~/git/racer.git/SSH to: [email protected] remote: ssh://[email protected]/~/git/racer.git/Cloned to: /home/User/racer

Run 'rhc show-app racer' for more details about your app.

If you have more than one domain, you can specify the domain in which you would like to create theapplication, by specifying the domain with the -n (namespace) option:

$ rhc app create racer php-5.3 -n automobile

As mentioned in Section 4.2, “Creating a Domain”, each domain can support multiple applications. Byrunning rhc app create hybrid php, for example, another application can be created in thedomain automobile. The application URLs would appear as follows:

http://racer-automobile.example.com

http://hybrid-automobile.example.com

Creating an Application Using a Downloadable Cartridge

Provide the URL of the hosted cartridge's manifest in place of the cartridge type to create an applicationusing a downloadable cartridge:

$ rhc app create [App_Name] https://www.example.com/manifest.yml

Creating an Empty Application

OpenShift Online can be used to create applications of no specific type, for build or other testingpurposes, using the DIY cartridge:

$ rhc app create [App_Name] diy

Chapter 6. Applications and Cartridges

31

Page 35: OpenShift Online 2.0 User Guide en US

The DIY cartridge creates an application that is not publicly available nor does it have anything running.Use git push and a .openshift/action_hooks/ script to start the application.

Report a bug

6.3.3. Manually Scaling an ApplicationThe following are cases where a scaled application must be manually scaled:

If a certain load is anticipated on an application and it must be scaled accordingly.

There are a fixed set of resources for an application.

The cost must be controlled manually.

Procedure 6.1. To Scale an Application Manually

1. Run rhc app show to view the cartridges in the scaled application. Locate the cartridges thatare indicated as scaling. In the following example, the php-5.3 cartridge is scaling:

$ rhc app show hybridhybrid @ http://hybrid-automobile.example.com/ (uuid: fjoe04cabdc4efa8f2513a21e2ed27d)----------------------------------------------------------------------------- Domain: automobile Created: 11:48 AM Gears: 1 (defaults to small) Git URL: ssh://[email protected]/~/git/hybrid.git/ SSH: [email protected] Deployment: auto (on git push)

php-5.3 (PHP 5.3) ----------------- Scaling: x1 (minimum: 1, maximum: available) on small gears

haproxy-1.4 (OpenShift Web Balancer) ------------------------------------ Gears: Located with php-5.3

2. For each scaling cartridge, run rhc cartridge scale command to set the minimum andmaximum gears the cartridge can use for scaling:

$ rhc cartridge scale php -a hybrid --min 1 --max 10Setting scale range for php ... done

php-5.3 (PHP 5.3)----------------- Scaling: x1 (minimum: 1, maximum: 10) on small gears

3. Set the minimum and maximum gears to 1 using the rhc cartridge scale command to stop acartridge from scaling:

OpenShift Online All Versions User Guide

32

Page 36: OpenShift Online 2.0 User Guide en US

$ rhc cartridge scale php -a hybrid --min 1 --max 1Setting scale range for php-5.3 ... done

php-5.3 (PHP 5.3)----------------- Scaling: x1 (minimum: 1, maximum: 1) on small gears

Report a bug

6.4. Adding and Managing CartridgesOpenShift Online supports a wide range of add-on cartridges. The OpenShift Online Client Toolsprovide a range of commands for managing cartridges.

View the cartridges associated with your applications by running the rhc apps command. Use the rhc app show AppName command to view information about an individual application. Installed cartridgesare listed under the Cartridge heading.

Note

An error message is displayed if any rhc command is used and the usage exceeds the node'sdisk quota limit.

Warning gear #{uuid} is using #{usage pct} of disk quotaWarning gear #{uuid} is using #{usage pct} of inodes allowed

Management Console

Click on the Applications tab in the Management Console, then click on the desired application toadd cartridges to your application. Note that some add-on cartridges are only available with the requiredweb cartridge. The available add-on cartridges are displayed under your application.

Report a bug

6.4.1. Adding CartridgesUse the rhc cartridge list command to view the current list of available cartridges. This commandlists all available cartridges, provides a brief description of each cartridge, and labels each cartridge as aweb cartridge or add-on cartridge. Most add-on cartridges can only be added after a prerequisite webcartridge is installed.

Procedure 6.2. To Add a Cartridge Using the CLI

Run the following command, replacing Cart_Type and App_Name with the application name and thedesired cartridge:

$ rhc cartridge add Cart_Type -a App_Name

Specifying Cartridge Gear Size

Use the -g, or --gear-size option with small, medium , or large when adding a cartridge to specifythe gear size. Note that this option is not available to non-scaled applications, as these run the web

Chapter 6. Applications and Cartridges

33

Page 37: OpenShift Online 2.0 User Guide en US

cartridge and any add-on cartridge on the same gear.

$ rhc cartridge add Cart_Name -a App_Name -g medium

This allows you to add an add-on cartridge on a medium gear to your application, which can be on agear of any size.

Note

Only silver plan users have access to medium and large gears. Free plan users are limited tosmall gears. Use the My Account tab in the Management Console and follow the directions toupgrade your account to a silver plan.

Report a bug

6.4.2. Managing CartridgesDifferent actions can be performed with the rhc cartridge command using the following syntax:

$ rhc cartridge Action Cart_Type -a App_Name

Table 6.3. Cartridge Management Actions

Action Details

list List supported cartridges.

add Add a cartridge.

remove Remove a cartridge.

stop Stop a cartridge.

start Start a cartridge.

restart Restart a cartridge.

status Return the current status of a cartridge.

reload Reload the configuration of a cartridge.

show Show information about a cartridge.

storage View and manipulate storage on a cartridge.

scale Set the scaling range of a cartridge.

Report a bug

6.4 .2.1. Cartridge Action HooksAction hooks are used to modify certain processes during an application's lifecycle. Cartridge actionhooks are specifically used to interact with cartridges. Each time OpenShift Online invokes one of thesecartridge actions, the action hooks directory is checked for an executable file. Create a file in the [App_Name]/.openshift/action_hooks directory with the same name as the desired event to usecartridge action hooks.

Use the following list for a reference to all possible action hooks associated with a cartridge controlaction.

OpenShift Online All Versions User Guide

34

Page 38: OpenShift Online 2.0 User Guide en US

Table 6.4 . Cartridge Action Hooks

Action Description Event specific examples

Start Start the software the cartridgecontrols.

pre_start_Cart-Name,post_start_Cart-Name

Stop Stop the software the cartridgecontrols.

pre_stop_Cart-Name,post_stop_Cart-Name

Reload The cartridge and the packagesoftware will re-read theconfiguration information.

pre_reload_Cart-Name,post_reload_Cart-Name

Restart Current cartridge process isstopped and started again.

pre_restart_Cart-Name,post_restart_Cart-Name

Tidy All unused resources arereleased.

pre_tidy_Cart-Name,post_tidy_Cart-Name

Cart_Name is a replaceable term used to represent the cartridge short-name. For example, for aJBossAS cartridge to be implemented during the pre-start process, create the file [App_Name]/.openshift/action_hooks/pre_start_jbossas and edit the file to contain thedesired information.

Report a bug

6.5. DeploymentThe application deployment process involves making any required changes to the application codebase, committing those changes to the local repository, and then updating the remote repository.Application files are stored in the local Git repository that was cloned as part of the application creationprocess.

The deployment process uses the application space as part of the build and test process, and requiresthe currently running application be shut down to use its memory. Therefore, the application will beunavailable for the duration of the build and all associated tasks, which are described below:

1. Pre-receive - This occurs when git push command is run, but before the push is fully committed.

2. Build - This builds an application, downloads required dependencies, executes the .openshift/action_hooks/build script and prepares everything for deployment.

3. Deploy - This performs any required tasks necessary to prepare the application for starting,including running the .openshift/action_hooks/deploy script. This step occursimmediately before the application is issued a start command.

4. Post-deploy - This step enables interaction with the running application, including running the .openshift/action_hooks/post_deploy script. This step occurs immediately after theapplication is restarted.

Report a bug

6.5.1. Build and Deployment Action HooksAction hooks are specific files created to modify the processes of an application's life cycle. With specificaction hooks, you can modify the build and deploy process.

The list of action hooks for build and deployment are:

Chapter 6. Applications and Cartridges

35

Page 39: OpenShift Online 2.0 User Guide en US

pre-build

build

deploy

post-deploy

Create a new file in the [App_Name]/.openshift/action_hooks directory to use the build anddeployment action hooks. For example, to implement an action hook for use during the build phase,create the file [App_Name]/.openshift/action_hooks/build, and edit the file to contain thedesired information.

Example 6.1. Adding an Action Hook to the Build Process

To download a file from another site during your application's build phase, create an [App_Name]/.openshift/action_hooks/build file, then add the following to the file's contents:

echo Downloading my.zip...curl -o $OPENSHIFT_DATA_DIR/my.zip http://myserver/my.zip

The file is downloaded during the git push process.

Report a bug

6.5.2. Preparing an Application for DeploymentThe rhc app create command creates a starting point to create and develop applications. Tosynchronize application files with the remote cloud repository, all files must be committed to theappropriate directories in the local Git repository, and then pushed to the remote repository. Forexample, for developing a PHP application and to add new files and directories to $_ENV['OPENSHIFT_APP_NAME']/php/ or other directories.

Procedure 6.3. To Prepare an Application for Deployment Using the Command Line

1. Use the following command to add each new file and directory to the Git index:

$ git add path/to/newfile

2. Use the following command to commit an application to the local repository:

$ git commit -m "commit message"

Report a bug

6.5.3. Deploying an ApplicationAfter adding application files to the local repository, push them to the remote repository. By default,OpenShift Online automatically stops, builds, and restarts the application with the committed changes.

Procedure 6.4 . Deploying an Application to the Cloud Using the Command Line

Use the following command to deploy the application to the remote repository:

$ git push

OpenShift Online All Versions User Guide

36

Page 40: OpenShift Online 2.0 User Guide en US

Report a bug

6.5.4. Configuring Application DeploymentWhen the git push command is run, the application data is sent to the remote repository and theapplication is deployed by default. However, using the rhc deployment commands to configure thedeployment process provides more options during the application deployment stage. Use the rhc configure-app commands to configure your application's deployment.

Configuring Auto-deploy

Use the --no-auto-deploy option to configure your application to not deploy automatically when yourdata is added to the remote repository with git push.

$ rhc configure-app -a App_Name --no-auto-deploy

Note that in this case, when the git push command is run the application data is pushed to the remoterepository, but the application is not deployed. If your application is set to --no-auto-deploy thenboth git push and git deploy must be run. Change back to deploying automatically using the --auto-deploy option.

Keeping Deployment Metadata

Use the --keep-deployment x option to set your application to record its deployments. This will helpin performing a rollback to a previous deployment. Replace x with any number to record that number ofdeployments in the application's history. Any older deployments after the set number will be deleted.

$ rhc configure-app -a App_Name --keep-deployments 10

Deploying From a Git Branch

Use the following command to choose the deployment branch to be from any branch of the Gitrepository.

$ rhc configure-app -a App_Name deployment-branch master

This example command deploys the master branch. Other Git references are supported, such as commitSHA, branch, or tag.

Listing Previous Deployments

Use the following command to view the list of previous deployments for an application, and the individualID of each deployment.

$ rhc deployments App_Name

Activating a Previous Deployment

Roll back to a previously deployed version of your application with the rhc deployments command toobtain the desired deployment's ID, then run the following command:

$ rhc activate-deployment deploy_ID -a App_Name

Report a bug

Chapter 6. Applications and Cartridges

37

Page 41: OpenShift Online 2.0 User Guide en US

6.5.4 .1. Deploying an Application From a SnapshotOpenShift Online supports deploying an application from a binary artifact.

Use the --deployment option when saving a snapshot of an application to build a deployable versionof your application.

$ rhc save-snapshot App_Name --deployment

Note

See Chapter 10, Backing Up and Restoring Application Data for full information on savingshapshots.

This command saves a .tar.gz snapshot of your application.

Next, configure your application to binary deployments:

$ rhc configure-app App_Name --deployment-type binary

This command changes your application's deployment procedure and disables the git push command,but enables your application to deploy binary artifacts. The rhc deploy command can then be used todeploy your application.

Use the following command to deploy a binary artifact:

$ rhc deploy ./app.tar.gz -a App_Name

Alternatively, you can also deploy from a URL using the command:

$ rhc deploy http://foo.com/path/to/file.tar.gz -a App_Name

Report a bug

6.5.5. About Hot DeploymentWhen the git push command is run to upload code modifications, OpenShift Online stops, builds,deploys and restarts an application. This entire process takes time to complete and is unnecessary formany types of code changes. Hot deploying an application enables the changes to take effect withoutrestarting the application cartridge, thus increasing deployment speed and minimizing applicationdowntime.

OpenShift Online provides support for hot deployment through a hot_deploy marker file. If the markeris present, supported application cartridges automatically hot deploy when the git push command isexecuted.

OpenShift Online All Versions User Guide

38

Page 42: OpenShift Online 2.0 User Guide en US

Table 6.5. Application Types That Can or Cannot Be Hot Deployed

Type of Application Hot Deploy

JBoss Application Server Yes

JBoss Enterprise Application Platform Yes

Tomcat 6 (JBoss Enterprise Web Server 1.0) Yes

Tomcat 7 (JBoss Enterprise Web Server 2.0) Yes

PHP Yes

Perl Yes

Ruby Yes

Python Yes

Node.js Yes

Zend Server Yes

Jenkins No

HAProxy No

DIY No

Report a bug

6.5.5.1. Hot Deployment Build Details

JBoss AS, JBoss EAP, Tomcat 6, and Tomcat 7

When JBoss AS, JBoss EAP, Tomcat 6, and Tomcat 7 applications are hot deployed, the Maven build isexecuted (either with Jenkins or without), but the server does not restart. Following the build, the JBossHDScanner notices any modifications and redeploys them. If previously deployed artifacts are removedas part of the update, they are undeployed automatically.

PHP, Zend Server, Perl, Python, and Node.js

When PHP, Zend Server, Perl, Python, and Node.js applications are hot deployed, the application code isbuilt (dependencies are processed and user build action_hooks are run) and deployed to the applicationserver. The server does not restart. This is true for both Jenkins and non-Jenkins enabled applications.For Jenkins enabled applications, the build is performed on a Jenkins slave instance and then synced tothe gear(s) where the application server is running.

Ruby

When a Ruby application is hot deployed, the Passenger restart.txt file is touched, causing theapplication server to serve the new code without the need for a full server restart. For further details onthis process, see the Passenger Documentation.

Report a bug

6.5.5.2. Enabling and Disabling Hot DeploymentProcedure 6.5. To Enable Hot Deployment

Open a terminal and run the command applicable to the operating system from the application's rootdirectory to create the hot_deploy marker file:

Windows

Chapter 6. Applications and Cartridges

39

Page 43: OpenShift Online 2.0 User Guide en US

C:\app_directory> copy NUL > .openshift\markers\hot_deploy

Linux and Mac

[user@user app_directory]$ touch .openshift/markers/hot_deploy

Procedure 6.6. To Disable Hot Deployment

Hot deployment is disabled by deleting the hot_deploy marker file. To delete this file, run thecommand applicable to the operating system from the application's root directory:

Windows

C:\app_directory> del .openshift\markers\hot_deploy

Linux and Mac

[user@user app_directory]$ rm .openshift/markers/hot_deploy

Report a bug

6.5.6. JBoss Application Deployment

6.5.6.1. Deploying on Java 6 or Java 7The JBoss AS 7 and JBoss EAP 6.0 applications can be run on either Java 6 or Java 7. The Javaversion is specified by a java7 marker file in the application's markers directory. By default, newJBoss applications have the java7 marker enabled. Applications without the java7 marker aredeployed using Java 6.

Procedure 6.7. To Use Java 7

Open a terminal and run the commands applicable to the operating system from the application's rootdirectory to create the java7 marker file and update the remote repository:

Windows

C:\app_directory> copy NUL > .openshift\markers\java7C:\app_directory> git add .openshift\markers\java7C:\app_directory> git commit -a -m "Add Java 7 marker"C:\app_directory> git push

Linux and Mac

[user@user app_directory]$ touch .openshift/markers/java7[user@user app_directory]$ git add .openshift/markers/java7[user@user app_directory]$ git commit -a -m "Add Java 7 marker"[user@user app_directory]$ git push

Procedure 6.8. To Use Java 6

Java 6 is enabled by deleting the java7 marker file. Run the commands applicable to the operatingsystem from the application's root directory to delete the java7 marker file and update the remoterepository:

OpenShift Online All Versions User Guide

40

Page 44: OpenShift Online 2.0 User Guide en US

Windows

C:\app_directory> del .openshift\markers\java7C:\app_directory> git commit -a -m "Remove Java 7 marker"C:\app_directory> git push

Linux and Mac

[user@user app_directory]$ rm .openshift/markers/java7[user@user app_directory]$ git commit -a -m "Remove Java 7 marker"[user@user app_directory]$ git push

Report a bug

6.5.6.2. Automatic DeploymentApplications are automatically deployed to the OpenShift Online server runtime by placing thedeployment content, for example, .war, .ear, .jar, and .sar files, in the JBoss Application Server(AS) or JBoss Enterprise Application Platform (EAP) deployments/ directory.

The file system deployment scanner in JBoss AS 7 and JBoss EAP 6.0 relies on a system of markerfiles. Add or remove various marker files and the scanner deploys, withdraws, or redeploys contentbased on the type of marker file.

These marker files always have the same name as the deployment content to which they relate, but withan additional file suffix to indicate the type of action to perform. For example, the marker file to indicatethat the example.war file is to be deployed is named example.war.dodeploy.

Option 1: Uploading Content in a Maven src Structure

Content can be uploaded in a Maven src structure similar to the example ROOT.war file. When a git push is performed, the application is built and deployed. This is the typical deployment option, andrequires that the pom.xml be stored at the root repository, and that the system has a maven-war-plugin similar to the one in the example file to move the output from the build to the deployments/directory.

By default, the warName is ROOT within the pom.xml file. This will render the webapp contents athttp://app_name-domain.example.com. If the warName is changed in pom.xml to app_name, then thebase URL would become http://app_name-domain.example.com/app_name.

Important

While building locally, add any output .war and .ear files in the deployments/ directory fromthe build to the .gitignore file.

Option 2: Uploading Prebuilt Content

git push can be used to push prebuilt .war files (with the corresponding .dodeploy file for exploded.war files) into the deployments/ directory.

Chapter 6. Applications and Cartridges

41

Page 45: OpenShift Online 2.0 User Guide en US

Important

While applying this method using the default repository, first run git rm -r src/ pom.xmlfrom the root directory of the repository. If the pom.xml file still exists, the build will run again andreplace any prebuilt content.

Report a bug

6.5.6.3. Types of Marker FilesDifferent marker file suffixes have different meanings. The relevant marker file types are as follows:

Table 6.6. Sample Table

Marker FileType

Description

.dodeploy Placed by the user to indicate that the given content is to be deployed into theruntime (or redeployed if already deployed in the runtime.)

.deploying Placed by the deployment scanner service to indicate that it has detected a .dodeploy file and is in the process of deploying the content. This marker file isdeleted when the deployment process completes.

.deployed Placed by the deployment scanner service to indicate that the given content hasbeen deployed to the runtime. If this file is deleted, the content will be withdrawn.

.faileddeploy Placed by the deployment scanner service to indicate that the given content failed todeploy to the runtime. The content of this file will include some information about thecause of the failure.

.undeploying Placed by the deployment scanner service to indicate that it has detected a .deployed file has been deleted and the content is being withdrawn. This markerfile is deleted when the withdrawal process completes.

.undeployed Placed by the deployment scanner service to indicate that the given content hasbeen withdrawn from the runtime. Deleting this file has no impact.

Report a bug

6.5.6.4 . Example JBoss Application Deployment WorkflowsThis section describes the basic workflows involved in deploying, withdrawing, and redeploying JBossprebuilt applications to OpenShift Online. After running the desired commands, run git commit and git push to deploy the changes to the application.

To Add New Zipped Content and Deploy It

Run the following command:

$ cp target/example.war deployments/

To Add New Unzipped Content and Deploy It

Run the following commands:

OpenShift Online All Versions User Guide

42

Page 46: OpenShift Online 2.0 User Guide en US

$ cp -r target/example.war/ deployments/$ touch deployments/example.war.dodeploy

To Withdraw Deployed Content

Run the following command:

$ git rm deployments/example.war.dodeploy deployments/example.war

To Replace Deployed Zipped Content with a New Version and Deploy It

Run the following command:

$ cp target/example.war deployments/

To Replace Deployed Unzipped Content with a New Version and Deploy It

Run the following commands:

$ git rm -rf deployments/example.war/$ cp -r target/example.war/ deployments/$ touch deployments/example.war.dodeploy

Report a bug

6.6. About Jenkins Online Build SystemJenkins integrates with other OpenShift Online applications. To start building with Jenkins, Jenkins Clientmust be added to an existing application. From then on, running a git push command initiates a buildprocess inside a Jenkins builder instead of inside the normal application compute space. For customapplications, or applications that have no upstream repositories, the build process can be initiateddirectly from the Jenkins web interface, without having to run the git push command.

Using the embedded Jenkins Client build system provides numerous benefits:

Archived build information

No application downtime during the build process

Failed builds do not get deployed (leaving the previous working version in place)

Jenkins builders have additional resources, for example memory and storage

A large community of Jenkins plug-ins

Report a bug

6.6.1. Configuring JenkinsThis section describes how to set up Jenkins to rebuild an application automatically when changes aremade to a local repository and then to push those changes to the remote repository.

Report a bug

6.6.1.1. Resource Requirements for JenkinsThe Jenkins application can be used to build any number of applications; this is limited only by thenumber of gears you have available. For example, if a PHP application is created and MySQL database

Chapter 6. Applications and Cartridges

43

Page 47: OpenShift Online 2.0 User Guide en US

is on the first gear, then Jenkins will be added to a separate gear. A third gear will be used for theJenkins builder. In other words, whenever the Jenkins builder is active, it occupies one of the availablegears.

Report a bug

6.6.2. Creating Jenkins-enabled ApplicationsJenkins can be enabled with new applications, either scaled or non-scaled. Use the rhc app createcommand to create a scaled or non-scaled application with an associated Jenkins application, and toadd the Jenkins client to your application.

Report a bug

6.6.2.1. Creating a Scaled Jenkins-Enabled ApplicationUse the rhc app create command with the -s (or --scaling) option to create a scaled application,and the --enable-jenkins option to add the Jenkins client to your application. If a cartridge type isspecified with multiple versions, the client tools will prompt you to specify the version to use.

$ rhc app create App_Name php --enable-jenkins -s

Important

Take note of the login credentials that this command outputs to the screen. These credentials willbe required to log in to the Jenkins home page.

Report a bug

6.6.2.2. Creating a Single-Instance Jenkins-Enabled ApplicationUse the rhc app create command to create a non-scaled application with an associated Jenkinsapplication, and to add the Jenkins client to the application. If a cartridge type is specified with multipleversions, the client tools will prompt to specify the version to use.

Take note of the login credentials that this command outputs to the screen. These credentials arerequired to log in to the Jenkins home page.

$ rhc app create App_Name php --enable-jenkins

Report a bug

6.6.2.3. Confirming that a Jenkins-Enabled Application is CreatedRun rhc apps to confirm that the Jenkins-enabled application has been created. This can also beverified by navigating to the public URL returned by the rhc app create command to view the Jenkinshome page.

OpenShift Online All Versions User Guide

44

Page 48: OpenShift Online 2.0 User Guide en US

Report a bug

6.6.3. Building Applications with JenkinsBuilding applications with Jenkins uses dedicated application space, which can be larger than theapplication runtime space. The Jenkins online build system monitors applications that have anembedded Jenkins Client, and automatically rebuilds and deploys those applications whenever changesto the Git repository are pushed to the remote server. No further interaction is required by the user. Theexisting application is not affected until a new, successful build has been created. Should the build fail,the existing application continues to run, although a failure in the deployment process (deploy - start -post_deploy) may leave the application partially deployed or inaccessible.

The actual build and deployment process that Jenkins executes involves numerous steps, as describedbelow.

1. The user issues a git push command, and Jenkins is notified that a new push is ready.

2. A dedicated Jenkins slave (a builder) is created. The rhc apps command can be used to displaythis slave information. The application name is the same as that of the originating application, butwith a "bldr" suffix.

Important

The first 28 characters of the application name must be unique, or builders will be sharedacross applications. This can lead to build issues.

3. Jenkins runs the build.

4. Content from the originating application is downloaded to the builder application using git (forsource code) and rsync (for existing libraries).

5. ci_build.sh is called from the Jenkins shell. This sets up the builder application for the Jenkinsenvironment and performs some built-in bundling steps (PHP pear processing, Python virtualenvironment, etc).

6. .openshift/action_hooks/build is executed on the Jenkins builder.

7. Any additional desired steps are executed from the Jenkins shell (Maven build, Gem install, testcases, etc).

8. Jenkins stops the currently running application, and runs rsync to synchronize all new contentover to the originating application.

9. .openshift/action_hooks/deploy is executed on the originating application.

10. Jenkins starts the originating application, and .openshift/action_hooks/post_deploy isexecuted on this application.

11. Jenkins archives all build artifacts for later reference.

12. After 15 minutes of idle time, the "build app" will be destroyed and will no longer appear in theoutput of the rhc apps command. The build artifacts, however, will still exist in Jenkins and canbe viewed there.

The build job can be monitored using the Jenkins interface. The interface provides an extensive rangeof information about the current build, build history, artifacts, as well as plug-ins to graph, track, run testsand perform other operations. The following is an example build history of an application built using theembedded Jenkins Client.

Logging for Jenkins-level errors (for example, DNS timeouts, builder configuration, etc.) is available in the

Chapter 6. Applications and Cartridges

45

Page 49: OpenShift Online 2.0 User Guide en US

Jenkins logs from the command line using the rhc tail command. Replace jenkins with the Jenkinsapplication name in the following, if different:

$ rhc tail jenkins

Logging for application-level errors (for example, compilation failures, test failures, etc.) is available viathe Jenkins web interface under the corresponding build history, while logging for deployment-levelerrors is available in the application's logs from the command line:

$ rhc tail App_Name

Report a bug

6.6.3.1. Building Custom ApplicationsBuild custom applications, or applications that have no upstream repositories, directly from the Jenkinsweb interface instead of using the git push command.

To build an application from the Jenkins web interface, click on the icon for the application to build,located on the right side of the interface.

The status of the build process can be viewed in the web interface under the section labeled BuildExecutor Status.

Report a bug

6.7. Deleting an Application

Warning

Application removal is irreversible. All remote data associated with the application will be removed.

If an application is no longer required, it can be deleted.

Management Console

Click on the Applications tab in the Management Console, then click on the desired application todelete it. Click on the Delete this application button and follow the instructions on the screen.

Client Tools

Run the following command to delete all the remote data for your application, typing yes when prompted:

$ rhc app delete App_Name

This process only deletes your remote application data. You must manually delete application datastored on your local machine.

Report a bug

6.7.1. Deleting Local Application Data

OpenShift Online All Versions User Guide

46

Page 50: OpenShift Online 2.0 User Guide en US

Warning

The following procedure deletes the selected directory and all the files it contains. Enter thecorrect directory and ensure the files it contains are no longer needed before running thiscommand.

Procedure 6.9. To Delete Local Application Data

Open a terminal and use the following command to delete the application data stored on the localmachine:

$ rm -rf ~/path/to/app_directory/

Report a bug

6.8. Gears and Storage ManagementAs an application is developed and the changes are pushed to the Git repository, the amount of diskspace that is available to run the application is slowly reduced. This is because Git stores all repositoryinformation, whether it is still required or not. Other aspects of developing and running applications alsoresult in wasted disk space, such as old log files and unused application libraries. In such cases eitheradditional storage is required, or the existing disk space is optimized to achieve the best possibleperformance of the applications. .

This section describes how to use the OpenShift Online client tools to add additional gear storage, andto manage the existing disk space to optimize application performance. Refer to rhc cartridge storage --help for a list of all available command options.

Note

Free plan users must upgrade their OpenShift Online subscription for additional gear storage.Log onto the Management Console, and click My Account to view upgrade options beforeattempting to increase the gear storage.

Management Console

Click the Applications tab in the Management Console, then click on the desired application tomanage its gear storage. Click on the current gear storage of the cartridge you wish to alter, thenchoose the new desired amount. Click Save to commit your changes.

Report a bug

6.8.1. Viewing Gear StorageUse the rhc cartridge storage command with the --show option to view the current gear storageallocation for each cartridge that exists in an application, as shown in the example below.

Chapter 6. Applications and Cartridges

47

Page 51: OpenShift Online 2.0 User Guide en US

$ rhc cartridge storage --show -a App_NameRESULT:

MySQL Database 5.1------------------ Base Gear Storage: 1GB Additional Gear Storage: 3GB

OpenShift Web Balancer---------------------- Base Gear Storage: 1GB Additional Gear Storage: None

PHP 5.3------- Base Gear Storage: 1GB Additional Gear Storage: None

Use the rhc cartridge storage command with the -c option to view gear storage for a specificcartridge that exists in an application, as shown in the example below.

$ rhc cartridge storage --show -a App_Name -c php-5RESULT:PHP 5.3------- Base Gear Storage: 1GB Additional Gear Storage: None

Report a bug

6.8.2. Adding Gear StorageUse the rhc cartridge storage command with the --add option to add a specified amount of gearstorage to your application.

$ rhc cartridge storage php-5.3 -a App_Name --add 3gbSet storage on cartridge ... set to 3GB

Storage Info------------ Base Gear Storage: 1GB Additional Gear Storage: 3GB

If the same command is used to add another 1GB of storage, there will be a total of 4GB of additionalgear storage.

Report a bug

6.8.3. Set Gear StorageUse the --set option with the rhc cartridge storage command to set the amount of gear storageof an application. This is different from the --add option in that you are specifying the amount of gearstorage rather than adding more.

OpenShift Online All Versions User Guide

48

Page 52: OpenShift Online 2.0 User Guide en US

$ rhc cartridge storage php-5 -a App_Name --set 5gbSet storage on cartridge ... set to 5GB

Storage Info------------ Base Gear Storage: 1GB Additional Gear Storage: 5GB

Report a bug

6.8.4. Removing Gear StorageUse the rhc cartridge storage command with the --remove option to remove a specified amountof gear storage.

$ rhc cartridge storage php-5 -a App_Name --remove 3gbSet storage on cartridge ... 2GB

Storage Info------------ Base Gear Storage: 1GB Additional Gear Storage: 2GB

Report a bug

6.8.5. Managing Application Disk SpaceOpenShift provides tools to optimize the disk space to help achieve the best possible performance ofthe applications.

Report a bug

6.8.5.1. Disk Space Cleanup ToolThe Disk Space Cleanup Tool can help manage an application disk space. This tool is part of the rhc app command suite, and performs the following functions:

Runs the git gc command on the application's Git repository on the server

Clears the application's /tmp and log file directories. These are specified by the application's OPENSHIFT_<cartridge>_LOG_DIR and OPENSHIFT_TMP_DIR environment variables.

Important

OpenShift Online does not automatically back up or rotate log files. The Disk Space CleanupTool runs the rm -rf command to clear the contents of these directories. To save theircontents, use the rhc snapshot save command first to create a snapshot of the system.

Clears unused application libraries. This means that any library files previously installed by a git push command are removed.

The Disk Space Cleanup Tool uses the following syntax:

$ rhc app tidy App_Name

Report a bug

Chapter 6. Applications and Cartridges

49

Page 53: OpenShift Online 2.0 User Guide en US

OpenShift Online All Versions User Guide

50

Page 54: OpenShift Online 2.0 User Guide en US

Chapter 7. Application Management

7.1. Application Management CommandsUse the rhc app command to manage your applications, view application status, and start, stop,restart, reload and delete applications. Run rhc app --help for more information and a full list of theavailable options.

$ rhc app action App_Name [Optional Arguments]

The following table describes the application management command options that you can use tomanage an existing application in the cloud.

Table 7.1. Application Management Command Argument Options

Option Details

start Start an application.

stop Stop an application.

force-stop Stops all application processes.

restart Restart an application.

reload Reload an application.

status Display the current status of an application.

show Show information about an application.

tidy Clean out the application's logs and tmp directories and tidy up the Git repoon the server.

create Create an application and add it to a domain.

git-clone Clone and configure an application's repository locally.

delete Remove an application.

Report a bug

7.2. Managing Applications in a Secure Shell EnvironmentManage your OpenShift Online applications in a shell environment to perform specialized operations andgeneral debugging. The shell access provides specialized tools for managing your applications. Usingthe shell environment to access your OpenShift Online applications is protected and restricted withSecurity-Enhanced Linux (SELinux) policies.

Important

Shell access is quite powerful and it is possible to accidentally damage an application. Thereforeit is recommended you only use shell access when necessary.

Report a bug

7.2.1. Accessing an ApplicationUse the rhc app ssh command to access an application in a secure shell environment. After you have

Chapter 7. Application Management

51

Page 55: OpenShift Online 2.0 User Guide en US

gained shell access, you can run the help command at the shell prompt to see the shell commandsavailable to you. You can also use general Linux commands to perform routine operations in the shellenvironment. The following example below shows a connection to the application racer.

$ rhc app ssh racerConnecting to [email protected] ...

*********************************************************************

You are accessing a service that is for use only by authorized users. If you do not have authorization, discontinue use at once. Any use of the services is subject to the applicable terms of the agreement which can be found at: https://www.openshift.com/legal

*********************************************************************

Welcome to OpenShift shell

This shell will assist you in managing OpenShift applications.

!!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! Shell access is quite powerful and it is possible for you to accidentally damage your application. Proceed with care! If worse comes to worst, destroy your application with 'rhc app delete' and recreate it !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!

Type "help" for more info.

[racer-automobile.example.com 517623ecdbd93cdffa000001]\>

Report a bug

7.2.2. Accessing a Specific GearThe rhc app ssh command opens a shell to the head gear of an application. This process can beused to debug a gear problem in a scaling application. To access a different gear you must firstdetermine a specific gear's ID and SSH URL:

$ rhc app show hybrid --gearsID State Cartridges Size SSH URL------------------------ ------- ------------------- ----- ----------------------------------------------------------------------------51774b712587c83ddb00009d started php-5.3 haproxy-1.4 small 51774b712587c83ddb00009d@hybrid-automobile.example.com519b0fd02587c84b860002d8 started php-5.3 haproxy-1.4 small 519b0fd02587c84b860002d8@519b0fd02587c84b860002d8-automobile.example.com519b1018dbd93c85180001fc started php-5.3 haproxy-1.4 small 519b1018dbd93c85180001fc@519b1018dbd93c85180001fc-automobile.example.com519b06ebdbd93cd439000027 started postgresql-9.2 small 519b06ebdbd93cd439000027@519b06ebdbd93cd439000027-automobile.example.com

For example, in the output above the ID of the first scaling gear is 519b0fd02587c84b860002d8 andits SSH URL is 519b0fd02587c84b860002d8@519b0fd02587c84b860002d8-automobile.example.com .

OpenShift Online All Versions User Guide

52

Page 56: OpenShift Online 2.0 User Guide en US

Use the ssh command with the SSH URL to open a secure shell to the desired gear:

$ ssh 519b0fd02587c84b860002d8@519b0fd02587c84b860002d8-automobile.example.com

Report a bug

7.2.3. Accessing a Database CartridgeThe integrity of a database can be verified by connecting to an application using SSH and running theshell for the database. A successful connection to the database shell indicates that the database hasbeen created correctly.

The shell for each database also offers a selection of commands that can be used to manage adatabase. See the selected database's documentation for more information on the database shellcommands available.

Important

Shell access is quite powerful and it is possible to damage an application accidentally. Thereforeit is recommended to use shell access only when necessary.

Procedure 7.1. To Manage a Database in a Shell Environment

1. Use the rhc app ssh command to access the desired application in a shell environment. Theexample below shows a connection to the application racer, which has a PostgreSQL database.After the shell access has been gained, run the help command at the shell prompt to see theshell commands available.

Chapter 7. Application Management

53

Page 57: OpenShift Online 2.0 User Guide en US

$ rhc app ssh racerPassword: **********

Connecting to [email protected] ...

*********************************************************************

You are accessing a service that is for use only by authorized users. If you do not have authorization, discontinue use at once. Any use of the services is subject to the applicable terms of the agreement which can be found at: https://www.openshift.com/legal

*********************************************************************

Welcome to OpenShift shell

This shell will assist you in managing OpenShift applications.

!!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! Shell access is quite powerful and it is possible for you to accidentally damage your application. Proceed with care! If worse comes to worst, destroy your application with 'rhc app delete' and recreate it !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!

Type "help" for more info.

[racer-automobile.example.com 517623ecdbd93cdffa000001]\>

2. Access the interactive database shell by running the appropriate command for the database:mysql: interactive MySql shell

psql: interactive PostgreSQL shell

mongo: interactive MongoDB shell

For example, to open the interactive PostgreSQL shell:

[racer-automobile.example.com 515e21acdbd93c051d000022]\> psqlpsql (8.4.13)Type "help" for help.

racer=#

Report a bug

7.3. Environment VariablesEnvironment variables are named values that change the way running processes behave in computingenvironments. They can be used to provide a variety of different environmental values: applicationnames, commonly accessed directory names, usernames, passwords, hostnames, and IP addresses.Your application reads the environment variables and uses the information to configure itself for theOpenShift environment.

OpenShift Online All Versions User Guide

54

Page 58: OpenShift Online 2.0 User Guide en US

The amount, values, and availability of variables can be different depending on which cartridges areenabled on your application. For example, the environment variables of a PostgreSQL database aredifferent to a MySQL database.

There are two ways to view the environment variables for an application:

1. Add an export statement to the App_Name/.openshift/action_hooks/build file, then run git push. The variables are listed in the Git output and start with remote: declare -x.

2. Use SSH to gain shell access to your application and run the env command at the shell prompt.

Report a bug

7.3.1. Informational Environment VariablesThese variables provide information about your application.

Table 7.2. Informational Environment Variables

Environment Variable Name Example Purpose

OPENSHIFT_APP_DNS App_Name-Domain.example.com

The application's fully-qualifieddomain namespace

OPENSHIFT_APP_NAME App_Name The application's name

OPENSHIFT_APP_UUID 0123456789abcdef0123456789abcdef

The UUID of the application (32hex characters)

OPENSHIFT_<cartridge>_IP

127.0.250.1 The IP address the applicationlistens on

OPENSHIFT_<cartridge>_PORT

8080 The port the applicationreceives requests from

OPENSHIFT_SECRET_TOKEN A 128 character string unique toan application that may be usedfor authentication, and can beoverridden with the rhc set-env command

Report a bug

7.3.2. Directory Environment VariablesThese variables return the directories where your application resides. Note that the only directory that isguaranteed never to be deleted is OPENSHIFT_DATA_DIR.

Chapter 7. Application Management

55

Page 59: OpenShift Online 2.0 User Guide en US

Table 7.3. Directory Environment Variables

Environment Variable Name Example Purpose

OPENSHIFT_HOMEDIR /var/lib/openshift/51774b763817c83ddb00009d/

The application's home directory

OPENSHIFT_DATA_DIR $OPENSHIFT_HOMEDIR/app-root/data/

A persistent data directory

OPENSHIFT_<cartridge>_LOG_DIR

$OPENSHIFT_HOMEDIR/<cartridge>/logs/

Where cartridge-specific logsare stored

OPENSHIFT_<database>_DB_LOG_DIR

$OPENSHIFT_HOMEDIR/<database>/logs/

Where database-specific logsare stored

OPENSHIFT_REPO_DIR $OPENSHIFT_HOMEDIR/app-root/runtime/repo/

Repository containing thecurrently deployed version ofthe application

OPENSHIFT_TMP_DIR /tmp/ A temporary directory you canuse; SELinux protects data inthis directory from other users

Report a bug

7.3.3. Database Environment VariablesThese variables pertain to your database (if you have one) and are used to connect your application toyour database. The exact variable names depend on the database type; the value of <database> isMONGODB, MYSQL, or POSTGRESQL as appropriate. Note these connections are only available toyour application internally; you cannot connect from an external source.

OpenShift Online does not currently support user changes to environment variables. This includeschanging the default MySQL admin password (even outside of phpMyAdmin). If you change yourpassword, ensure that the change takes effect correctly. Note that this restriction only applies to thedefault administrative user. You can add more users as required, and specify a password of your ownchoosing for these users.

Table 7.4 . Database Environment Variables

Environment Variable Name Example Purpose

OPENSHIFT_<database>_DB_HOST

127.0.250.1 The hostname or IP addressused to connect to the database

OPENSHIFT_<database>_DB_PORT

3306 The port the database server islistening on

OPENSHIFT_<database>_DB_USERNAME

admin The database administrativeusername

OPENSHIFT_<database>_DB_PASSWORD

8ddTnst22X3Y The database administrativeuser's password

OPENSHIFT_<database>_DB_SOCKET

$OPENSHIFT_HOMEDIR/mysql-5.1/socket/mysql.sock

An AF socket for connecting tothe database (for non-scaledapps only)

OPENSHIFT_<database>_DB_URL

mysql://admin:[email protected]:3306/

Database connection URL

OpenShift Online All Versions User Guide

56

Page 60: OpenShift Online 2.0 User Guide en US

Report a bug

7.3.4. Jenkins Environment VariablesIf your application includes Jenkins, you have access to the following variables.

Table 7.5. Jenkins Environment Variables

Environment Variable Name Example Purpose

JENKINS_USERNAME system_builder System builder account on theJenkins server

JENKINS_PASSWORD RnmXQlavsb4f Password for the system builderaccount on the Jenkins server

JENKINS_URL https://jenkins-domain.example.com/

DNS name for the associatedJenkins server where buildsoccur

Report a bug

7.3.5. Gear Environment VariablesThese variables apply to scaling applications.

Table 7.6. Gear Environment Variables

Environment Variable Name Example Purpose

OPENSHIFT_GEAR_DNS gearname-domain.example.com The gear's fully-qualified domainname

OPENSHIFT_GEAR_NAME gearname The gear's name

OPENSHIFT_GEAR_UUID 0123456789abcdef0123456789abcdef

The gear's UUID

Report a bug

7.3.6. JBoss Environment VariablesThe table below shows the environment variables pertaining to supported JBoss applications onOpenShift Online.

Table 7.7. JBoss Environment Variables

Environment Variable Name Purpose

JAVA_OPTS Controlled by the cartridge and used to specify additionalarguments to the JVM where JBoss application will run.

JAVA_OPTS_EXT Appended to the JAVA_OPTS environment variable before the JVMis invoked, and used to provide additional options to the JVMwithout rewriting the JAVA_OPTS environment variable. This allowsdevelopers to better support their application users.

JBoss environment variables are stored in the /App_Name/.openshift/config/standalone.xmlfile that is part of jbossas-7. The example code below shows the environment variables for a MySQLdatasource connection URL in the form jdbc:mysql://SERVER_NAME:PORT/DATABASE_NAME:

Chapter 7. Application Management

57

Page 61: OpenShift Online 2.0 User Guide en US

<connection-url>jdbc:mysql://${env.OPENSHIFT_MYSQL_DB_HOST}:${env.OPENSHIFT_MYSQL_DB_PORT}/${env.OPENSHIFT_APP_NAME}</connection-url>

The environment variables can be saved on the server so that sensitive information does not have to bepassed repeatedly to the command line.

Procedure 7.2. To Set Environment Variables on the Server

1. Open the App_Name/.openshift/config/standalone.xml file.

2. Specify the required values for any of your environment variables, then save and close the file.

3. Commit and push the changes to the server:

$ git commit -a -m "COMMIT MESSAGE"$ git push

Important

Sensitive information stored in your environment variables is visible if you use the rhc snapshot commands.

Report a bug

7.3.7. Custom Environment VariablesOpenShift Online enables you to set custom environment variables for your applications.

Setting Custom Environment Variables

Use the following command to set one or more environment variables for an application. Set multiplevariables by adding additional Variable=Value arguments separated by spaces:

$ rhc env set Variable=Value Variable2=Value2 -a App_Name

Viewing Custom Environment Variables

View the custom environment variables set for an application using the following command:

$ rhc env list -a App_Name

Viewing the Value of a Custom Environment Variable

Display the value of one or more custom environment variables using the following command:

$ rhc env show Variable Variable2 -a App_Name

Removing Custom Environment Variables

Remove a custom environment variable using the following command:

$ rhc env unset Variable -a App_Name

OpenShift Online All Versions User Guide

58

Page 62: OpenShift Online 2.0 User Guide en US

Report a bug

7.4. About Node.js ApplicationsThis section provides the basic information required for running Node.js applications on OpenShiftOnline.

Report a bug

7.4.1. Repository LayoutWhen you create a new Node.js application on OpenShift Online, the application directory is populatedwith several files. The following table displays this layout:

Table 7.8. Node.js Repository Layout

File Use

node_modules/ Node modules packaged with the application.

deplist.txt Deprecated list of npm modules to install with the application.

npm_global_module_list List of globally installed and available npm modules.

server.js OpenShift Online sample Node application.

package.json Package descriptor for npm.

README Information about using Node.js with OpenShift Online .

.openshift/ Location for OpenShift Online specific files.

.openshift/action_hooks/pre_build

Script that runs every git push, but before the build.

.openshift/action_hooks/build Script that runs every git push during the build process (on theCI system if available).

.openshift/action_hooks/deploy Script that runs every git push after the build, but before theapplication is restarted.

.openshift/action_hooks/post_deploy

Script that runs every git push, but after the application isrestarted.

You can create additional directories if needed, but do not delete the node_modules and .openshiftdirectories.

Note

When you git push, everything in your remote repository directory is recreated. Place items thatyou want to persist between pushes, such as a database, in the ../data directory on the gearwhere your OpenShift Online application is running.

Report a bug

7.4.2. Installing Node ModulesIf you want to install Node modules from the npm registry, you can specify the modules in the package.json file. Package.json describes how your package is structured and is used by npm toinstall and manage your application. The dependencies hash in the package.json file can be used tospecify the Node modules (and optionally the version) to install alongside your application ("locally") on

Chapter 7. Application Management

59

Page 63: OpenShift Online 2.0 User Guide en US

the OpenShift Online environment when you git push your application. For more information, seehttps://npmjs.org/doc/json.html.

Example package.json entry:

"dependencies": {

"coffee-script": "1.3.3",

"connect": "*",

"optimist": "<=0.3.4",

"socket.io": ""

},

Node modules not included in the npm registry can be installed by packaging them in the node_modules directory.

The npm_global_module_list file contains a list of globally installed modules. You can override aglobally available module by specifying it in package.json or by packaging it in the node_modulesdirectory. Node gives preference to the "locally" installed version of that module.

Report a bug

7.5. Scheduling Timed Jobs with CronUse the OpenShift Online cron scheduler to set up timed jobs for your applications. This consists ofadding the cron scheduler cartridge to your application, adding the required cron jobs to the appropriatedirectories, and then updating the remote Git repository. You can also use the rhc cartridgecommand to enable or disable your cron scripts.

The following example demonstrates how to create a new application and enable cron support. Note thatif you specify a cartridge type with multiple versions, the client tools prompt you to specify the version touse.

Procedure 7.3. To Create an Application and Enable Cron Support

1. Create a new application:

$ rhc app create holy php

2. Add the cron scheduler cartridge to your new application:

$ rhc cartridge add cron -a holy

3. Add the cron jobs to your application's .openshift/cron/{minutely,hourly,weekly,daily,monthly}/ directories.

For example:

$ mkdir -p .openshift/cron/minutely$ echo 'date >> $OPENSHIFT_REPO_DIR/php/date.txt' > .openshift/cron/minutely/date.sh

OpenShift Online All Versions User Guide

60

Page 64: OpenShift Online 2.0 User Guide en US

4. Commit your changes and push them to the remote repository.

$ git add .openshift/cron/$ git commit -m "configuring cron jobs"$ git push

This example appends a new line of date information to the $OPENSHIFT_REPO_DIR/php/date.txtfile every minute.

Use the curl command to verify the operation of this script:

$ curl http://holy-roller.example.com/date.txt

Thu Feb 2 01:02:01 EST 2012Thu Feb 2 01:03:01 EST 2012Thu Feb 2 01:04:01 EST 2012

The scripts that you place in the /cron subdirectories are executed at the respective frequencies.Scripts in each subdirectory are executed sequentially, in alphabetical order. Scripts in the /cron/hourly directory are executed on the first minute of every hour. You can use the rhc cartridge command to enable or disable your cron scripts. For example, to disable all of your scripts:

$ rhc cartridge stop cron -a holy

To enable all of your scripts:

$ rhc cartridge start cron -a holy

Note

The cron commands affect all cron jobs. You cannot disable or enable individual cron jobs.

Report a bug

7.6. Available Ports for Binding ApplicationsAll ports less than 1024 are reserved for OpenShift Online operations. Developers will not be able tobind to these ports. However, ports greater than 1024 are available for binding. The following tabledisplays the commonly used ports for binding.

Important

While the following ports are suggestions for available applications or gears, ports 2303-2308 arereserved for OpenShift SNI Implementation, and port 10050 is reserved for the OpenShiftOpenShift Online Zabbix agent. You will not be able to bind to these ports.

Chapter 7. Application Management

61

Page 65: OpenShift Online 2.0 User Guide en US

Table 7.9. Common Ports and Their Usage

Application Name Port Number Description

Kerberos 4444 Kerberos is used for userauthentication identifying with anode.

Git 9418 Git is used for version control.

MySQLd 3306, 63132-63164 My Structured Query Language(MySQL) acts as a serverproviding access to databases.

Mongod 27017 MongoDB acts as a serverproviding access to databases.

PostgreSQL 5432 PostgreSQL acts as a serverproviding access to databases.

MS SQL 1433-1434 MS SQL acts as a serverproviding access to databases.

Oracle 1521, 2483, 2484 Oracle acts as a serverproviding access to databases.

HTTP/HTTPS 8008, 8009, 8443 Hypertext Transfer ProtocolSecure (HTTPS) is used forsecure communication over aserver.

HTTP cache 8080, 8118, 8123, 10001-10010

HTTP cache is used for thetemporary storage ofdocuments.

memcache 11211 memcache is a memory cachingsystem.

jacORB 3528, 3529 JacORB is a Java requestbroker.

JBoss Debug 8787 A debug program for JBossapplications.

JBoss Management 4712, 4447, 7600, 9123, 9990,9999, 18001

A management program forJBoss applications.

AMQP 5671-5672 Advanced Message QueuingProtocol (AMQP) is used totransfer messages betweenapplications.

PulseAudio 4713 PulseAudio is a server thatmanages the use of audiodevices.

Flash 1935 Flash is a multimedia platform.

Munin 4949 Munin is a network monitoringapplication.

Virt Migration 49152-49216 Virt migration is the copying ofone machine's data and movingit to another.

OCSP 9080 Online Certificate ServiceProtocol (OCSP) is a protocolused for obtaining the status of

OpenShift Online All Versions User Guide

62

Page 66: OpenShift Online 2.0 User Guide en US

a certificate.

You can also bind to the internal IP through ports 15000-35530, which are not externally addressable.You can also bind to $OPENSHIFT_CartridgeShortName_PORT (8080) for http connectivity, which willreroute externally through port 80.

Report a bug

7.6.1. WebSocket Port ConfigurationIn its current form on OpenShift Online, WebSocket can be used by connecting to specific ports on anapplication, as the main routing layer is still Apache-based. WebSocket connections are supported withbrowser-based applications on OpenShift Online, allowing bi-directional communication without requiringmultiple, open HTTP connections. The TCP-based protocol uses HTTP as an initiation handshake,which is treated as an upgrade request. If successful, the connection remains open and switches to theWebSocket protocol.

For plain WebSocket connections (ws://), requests should be directed to port 8000, while WebSocketSecure connections (wss://) should use port 8443. For example:

http://example.example.com:8000

https://example.example.com:8443

Report a bug

7.6.2. Email Port ConfigurationOpenShift Online provides support for connecting to externally hosted email services (POP, IMAP, andSMTP). For developers, this means that you can establish a connection from your application to yourown email server, or to one of the popular public email services, such as Gmail or YahooMail. If you aredeploying popular blogging or wiki software on OpenShift Online, such as Drupal, Joomla, MediaWiki, orWordPress, you can also take advantage of this feature by altering the email settings of the software topoint to the appropriate email service.

The following ports are the suggested options for email support:

SMTP/submission: 25, 465, 587

IMAP: 143, 220, 993

POP: 109, 110, 995

Communication occurs at a limited rate. Port 587 (submission) is restricted to a maximum rate of 256Kbps. Ports 25 (SMTP) and 465 (SMTPS) are restricted to a maximum rate of 24 Kbps. Both willconsume an extremely small share of the available bandwidth if congestion exists.

Important

Be aware that access to email servers from cloud providers may be blocked by RealtimeBlackhole Lists (RBLs). This may affect your ability to connect to some email servers. If you areunable to make a connection to one of these services, make sure that your email provider allowsauthenticated connections from Amazon AWS EC2 hosts.

Report a bug

Chapter 7. Application Management

63

Page 67: OpenShift Online 2.0 User Guide en US

Chapter 8. Authentication and SSH KeysOpenShift Online uses the Secure Shell (SSH) network protocol to authenticate account credentials tothe OpenShift Online servers for secure communication, and supports both RSA and DSA keys for SSHauthentication. This section describes how OpenShift Online authentication works, and providesinformation on how to manage SSH keys for OpenShift Online user accounts.

For successful authentication, the public SSH key on your computer must match the public key that hasbeen uploaded to the OpenShift Online server. When you perform the initial configuration of theOpenShift Online client tools, the interactive setup wizard generates a new pair of SSH keys in thedefault .ssh folder of your home directory. The SSH key pair consists of the public key, id_rsa.pub,and the private key, id_rsa. As part of the initial configuration, you have the option of automaticallyuploading the public key, id_rsa.pub, to the OpenShift Online server. See the Client Tools InstallationGuide for more information about client tools configuration.

Management Console

Click the Settings tab in the Management Console to view SSH key management options. From there,you can add or revoke authorization tokens.

Report a bug

8.1. Viewing All Public KeysThe rhc sshkey list command displays all public keys that have been added to the OpenShiftOnline server for your user account:

$ rhc sshkey listlibra (type: ssh-rsa)--------------------- Fingerprint: 43:f5:29:ad:9f:b8:b3:a6:e7:88:c9:7f:4c:a9:0c:ad

winKey (type: ssh-rsa)---------------------- Fingerprint: 0c:16:81:e3:51:eb:12:90:f6:03:80:g2:a2:10:78:14

default (type: ssh-rsa)----------------------- Fingerprint: 43:f8:93:re:9f:a3:a8:f4:f3:34:g8:3d:1g:d8:3c:as Available: true

You have 3 SSH keys associated with your account.

Report a bug

8.2. Viewing a Specific Public KeyThe rhc sshkey show command displays details of the key specified:

$ rhc sshkey show KeyNameKeyName (type: ssh-rsa)----------------------- Fingerprint: d2:0f:1b:8d:3e:07:0b:5a:14:df:2a:44:15:f0:e7:fc

Report a bug

OpenShift Online All Versions User Guide

64

Page 68: OpenShift Online 2.0 User Guide en US

8.3. Generating Keys ManuallyThe ssh-keygen command generates a new pair of RSA or DSA keys as specified.

Procedure 8.1. Generating SSH Keys Manually

1. Run the ssh-keygen command, replacing KeyType with the type of key you want to generate,either dsa or rsa:

$ ssh-keygen -t KeyType

2. When prompted for the file in which to save the key, press Enter to save the key in the defaultlocation (/home/username/.ssh/) with the default name:

...Generating public/private rsa key pair.Enter file in which to save the key (/home/username/.ssh/id_rsa): /home/username/.ssh/id_rsa

Note

It is recommended to save all SSH keys in the default location. If id_rsa exists, rename thenew SSH key to avoid overwriting existing keys. For example:

Enter file in which to save the key (/home/username/.ssh/id_rsa): /home/username/.ssh/My_rsa

3. When prompted for a passphrase, enter a passphrase or leave blank for no passphrase thenpress Enter:

Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /home/username/.ssh/id_rsaYour public key has been saved in /home/username/.ssh/id_rsa.pub....

Report a bug

8.4. Adding a KeyThe rhc sshkey add command uploads the specified public key to the OpenShift Online server.Replace KeyName and KeyPath with the name and path of the key you want to upload:

$ rhc sshkey add KeyName KeyPath

Report a bug

8.4.1. Creating a Specific SSH Key TypeUse the --type and --content options to create a specific type of SSH key. This allows you to

Chapter 8. Authentication and SSH Keys

65

Page 69: OpenShift Online 2.0 User Guide en US

specify more information about the SSH key directly, rather than uploading the key file.

$ rhc sshkey add KeyName KeyPath --type KeyType --content KeyContent

Report a bug

8.4.2. Removing a KeyThe rhc sshkey remove command deletes an existing public key for your account from the OpenShiftOnline server:

$ rhc sshkey remove KeyName

Report a bug

8.5. Resolving Authentication IssuesOccasionally your local public key may not match the public key for your account on the OpenShift Onlineserver, or your key may not be found on the local file system. This can cause connection issues, or theSSH key authentication process can fail, in which case a new pair of SSH keys must be generated. If youare having problems authenticating, there are two ways you can generate a new pair of SSH keys:

Use the interactive setup wizard (recommended)

Manually generate and add SSH keys

Report a bug

8.5.1. Resolving Issues with Interactive Setup WizardThe recommended method of resolving authentication issues is to use the interactive setup wizard togenerate a new pair of SSH keys. The interactive setup wizard also provides the option of automaticallyuploading your new public key to the OpenShift Online server. Use the rhc setup command to launchthe setup wizard, then follow the onscreen instructions.

See the Client Tools Installation Guide for more information about the OpenShift Online client toolsinteractive setup wizard.

Report a bug

OpenShift Online All Versions User Guide

66

Page 70: OpenShift Online 2.0 User Guide en US

Chapter 9. Monitoring and Troubleshooting

9.1. Monitoring Application ResourcesAs described in Section 6.1.1, “About Scaled Applications”, scaled applications are automaticallyallocated additional resources based on demand. The amount of resources consumed by an applicationcan be monitored and viewed from the OpenShift Online Management Console. Follow the instructionsbelow to monitor and view application resources. The instructions below assume that a scaledapplication has already been created.

Procedure 9.1. To Monitor Application Resources

1. Access the OpenShift Online Management Console.

2. Click on the My Applications tab to view all of your applications and click on the name of thescaled application you want to examine.

3. The OpenShift Online Management Console displays the number of gears, along with the size ofthe gears, used by the selected application.

4. Hover over the gear size information with your mouse to display a popup message with moredetailed information.

5. Scaling is performed by the HAProxy cartridge. Click See HAProxy status page to getinformation about testing the scaling function of your application.

Note

At the time of this writing, the scaling function cannot be disabled from an application. Theonly way to disable scaling is to remove the scaled application, and create a newapplication without the scaling option.

Report a bug

9.2. MongoDB Monitoring Service (MMS)The MongoDB Monitoring Service (MMS) is a cloud-based monitoring service, designed by 10gen, tomonitor the health of MongoDB deployments. MMS provides an agent that runs on MongoDB servers,and this agent reports information such as opcounters, memory information, number of connections,network I/O, database storage size, and more. All of this information is available in customizable chartsthat are displayed in your web browser.

OpenShift Online provides built-in support for MMS; you can add the MMS agent to your applicationusing the same commands as for other cartridges. The only prerequisite for using MMS is that you havean account with 10gen; you can sign up for a free MMS account at https://mms.10gen.com/.

Report a bug

9.2.1. Configuring an Application with MMSThe following procedure describes how to configure your application to take advantage of the servicesprovided by MMS. This procedure assumes that you have successfully created an application andadded the MongoDB cartridge.

Procedure 9.2. How to set up your application to use MMS

Chapter 9. Monitoring and Troubleshooting

67

Page 71: OpenShift Online 2.0 User Guide en US

1. Download the agent from https://mms.10gen.com/.

When you log into MMS, you will see a Download the Monitoring Agent link on the Hostspage. Click this link to download an agent preconfigured with your group credentials.

2. Create a directory named mms in your application's .openshift directory with the followingcommand, replacing app_directory with the root directory for your application:

$ mkdir ~/app_directory/.openshift/mms

3. Add the settings.py file to the mms directory:

$ cp ~/mms-agent/settings.py ~/app_directory/.openshift/mms/

Important

The settings.py file contains the MMS agent settings that contain the API keys forconnecting to your MMS account and updating the monitoring metrics. The MMS agent willnot function without this file.

4. Use Git to add and commit the mms directory to your local repository, then push it to your remoterepository:

$ cd app_directory/$ git add .openshift/mms/$ git commit -m "mms settings" -a$ git push

5. Use the following command to add the agent to your application:

$ rhc cartridge add 10gen-mms-agent-0 -a App_Name

After successfully completing this procedure, navigate to the https://mms.10gen.com/ page, enter yourhost's details and start monitoring your application.

Report a bug

9.2.2. Monitoring Applications with MMS

Report a bug

9.2.2.1. Adding Hosts to MMSAfter you have created an application and added the MMS agent, you can add the host to the Hostspage on https://mms.10gen.com/. To add a new host, you need the hostname, port number, and logincredentials that were provided when you added MongoDB to your application. If you no longer have thisinformation, you can retrieve it directly from your application, as follows:

1. Use SSH to connect to your application:

$ ssh UUID@App_Name-Domain.example.com

where UUID is the UUID of your application. You can retrieve this using the rhc apps command.Replace App_Name and Domain with your application name and domain, respectively.

OpenShift Online All Versions User Guide

68

Page 72: OpenShift Online 2.0 User Guide en US

2. Run the following command to retrieve all the necessary connection and credential information foryour application:

> echo $OPENSHIFT_MONGODB_DB_URL

Procedure 9.3. How to add hosts to MMS

1. Navigate to https://mms.10gen.com/ and login to your account.

2. Click the Hosts + button at the top of the page to display the New Host dialog box.

3. Enter the required details and then click Add. This adds the host details to the agent, whichimmediately starts collecting and storing data.

Report a bug

9.2.2.2. MMS Monitoring with a BrowserAfter adding the MMS agent to your application and your host details to MMS, use the web interface tomonitor your application's performance.

Procedure 9.4 . How to monitor your applications with MMS

1. Navigate to https://mms.10gen.com/, login to your account, and click the Hosts tab.

2. Click the name of the host that you want to monitor to view the available data collection streams.You can customize this page to suit your own requirements. See the 10gen documentation for fulldetails.

Report a bug

9.3. Troubleshooting JBoss ApplicationsOpenShift Online provides some basic tools to help you troubleshoot your JBoss applications shouldproblems arise. This includes the ability to inspect the log files and also to trigger a thread dump forJBoss applications.

Report a bug

9.3.1. Debugging with Thread DumpsThread dumps are a useful debugging tool. If an application appears to have stalled or is running out ofresources, a thread dump can help to reveal the state of the server, to identify what might be causingany issues and ultimately to resolve the problem. You can use the rhc threaddump command totrigger a thread dump for a JBoss application.

The following example demonstrates the use of this command:

Note

This example assumes that you have a valid account and have already created a domain andJBoss application called "myJBoss".

Chapter 9. Monitoring and Troubleshooting

69

Page 73: OpenShift Online 2.0 User Guide en US

$ rhc threaddump myJBossPassword: **********

Application event 'thread-dump' successfulSuccess

The thread dump file will be available via: rhc tail myJBoss -f /tmp/jbossas.log -o '-n 250'

Now use the rhc tail command to inspect the resultant thread dump:

$ rhc tail myJBoss -f /tmp/jbossas.log -o '-n 250'Password: **********

<sample output>

Heap def new generation total 18240K, used 4240K [0xdd580000, 0xde940000, 0xe2ad0000) eden space 16256K, 24% used [0xdd580000, 0xdd956930, 0xde560000) from space 1984K, 15% used [0xde750000, 0xde79d9a0, 0xde940000)

<output truncated>

Report a bug

9.3.2. Inspecting Server, Boot and Other Log FilesThe rhc tail command inspects other JBoss application log files. By including the application nameas the only argument, this command tails the contents of all the files in the cartridge/logs/ directory.The example below shows abbreviated output from this command.

$ rhc tail myJBossPassword: **********

==> jbosseap-6/logs/server.log <==2013/01/02 02:06:37,144 INFO [org.jboss.as.osgi] (MSC service thread 1-1) JBAS011907: Register module: Module "deployment.ROOT.war:main" from Service Module Loader

==> jbosseap-6/logs/boot.log <== user.name = 1ca72484953b4701a4d32be920bcefc1 user.timezone = America/New_York02:06:29,566 DEBUG [org.jboss.as.config] VM Arguments: -D[Standalone] -Xmx256m -XX:MaxPermSize=128m -XX:+AggressiveOpts -Dorg.apache.tomcat.util.LOW_MEMORY=true -Dorg.jboss.resolver.warning=true

<output truncated>

The rhc tail command provides the same output as if you directly log into an application instanceand run the rhc tail_all command. It shows the services running on the application's behalf in realtime.

Tailing Specific Gears

Inspecting application log files on specific gears is helpful for diagnosing problems on secondary gears;for example in scaled applications.

OpenShift Online All Versions User Guide

70

Page 74: OpenShift Online 2.0 User Guide en US

In order to inspect the application logs on a specific gear, first determine the gear's ID. See Section 7.2.2,“Accessing a Specific Gear” for details on how to find a specific gear's ID.

Run the following command to tail the logs of the specified gear:

$ rhc tail App-Name -g gear_ID

The log displays on the command screen, and updates every few seconds.

Report a bug

9.4. Performing Application Maintenance from Workstation

9.4.1. Port ForwardingPorts on a remote server can be forwarded to your workstation, making it easy to manage services suchas MySQL. The rhc port-forward command provides a wrapper for the ssh command, anddetermines which remote ports to forward to your workstation.

Note

Ensure that your application is running before attempting to configure port forwarding.

The example below shows remote ports for the App_Name application being forwarded locally:

$ rhc port-forward App_NameChecking available ports ... doneForwarding ports ...Address already in use - bind(2) while forwarding port 8080. Trying local port 8081Address already in use - bind(2) while forwarding port 8080. Trying local port 8081Address already in use - bind(2) while forwarding port 8081. Trying local port 8082

To connect to a service running on OpenShift, use the Local address

Service Local OpenShift------- --------------- ---- -------------------------------------------------------haproxy 127.0.0.1:8080 => 127.9.159.130:8080haproxy 127.0.0.1:8081 => 127.9.159.131:8080httpd 127.0.0.1:8082 => 127.9.159.129:8080mysql 127.0.0.1:50226 => 52347a1d2587c86695111697-mydomain.rhcloud.com:50226

Press CTRL-C to terminate port forwarding

In this example, you could now open a browser and connect to your remote application using the localports.

The current implementation of the rhc port-forward command forwards all open ports on a runningapplication to your local workstation. If an application contains multiple cartridges, the command output

Chapter 9. Monitoring and Troubleshooting

71

Page 75: OpenShift Online 2.0 User Guide en US

shows which remote services are being bound to local ports.

For forwarding specific ports, use the ssh command with the -L option. This specifies the local port youwish to forward to the remote port. For example:

$ ssh -L 8080:localhost:8080

This command allocates a socket to listen to the local port host 8080 (the first number). When aconnection to this port is made, a secure channel forwards the connection to the remote host port 8080(the second number).

Port Forwarding Specific Gears

Port forwarding specific gears to diagnose problems on secondary gears makes examining problemswith scaled applications easier.

In order to port forward specific gears, first determine the gear's ID. See Section 7.2.2, “Accessing aSpecific Gear” for details on how to determine a specific gear's ID.

Run the following command to port forward a specific gear, replacing App_Name with the name of yourapplication, and gear_ID with the gear's ID:

$ rhc port-forward App_Name -g gear_ID

Example 9.1. Port Forwarding a Specific Gear

$ rhc port-forward App_Name -g 522d59745973caccab0000c1Checking available ports ... doneForwarding ports ...

To connect to a service running on OpenShift, use the Local address

Service Local OpenShift------- -------------- ---- -------------------httpd 127.0.0.1:8080 => 127.12.166.129:8080

Press CTRL-C to terminate port forwarding

Report a bug

9.4 .1.1. Port Forwarding on Mac OS XCurrently, out of the box, Mac OS X only provides the following interfaces for loopback addresses:

localhost

127.0.0.1

Therefore, you may experience error messages similar to those shown below when attempting toconfigure port forwarding using the IP address for your OpenShift Online application.

$ rhc port-forward App_NameChecking available ports...Error trying to forward ports. You can try to forward manually by running:ssh -N [email protected]

OpenShift Online All Versions User Guide

72

Page 76: OpenShift Online 2.0 User Guide en US

The current workaround to enable port forwarding on Mac OS X is to configure an alias manually usingthe ifconfig command for each IP address used by your application, using the command as shownbelow:

$ sudo ifconfig lo0 alias application_IP_address

For example, if the IP address used by your application is 127.10.51.129, run the command as shownbelow:

$ sudo ifconfig lo0 alias 127.10.51.129

If your application uses multiple IP addresses, as shown in the example above, you must configure analias for each IP address. For example, suppose you have a PHP application with both MySQL andphpMyAdmin cartridges added, and it uses the IP addresses 127.11.25.1 and 127.11.25.2. To correctlyenable port forwarding, you must configure an alias for each IP address, as shown in the example below.

$ sudo ifconfig lo0 alias 127.11.25.1$ sudo ifconfig lo0 alias 127.11.25.2

Note

The ifconfig command on Mac OS X requires root/administrative privileges to execute.

You can now use the rhc port-forward command to enable port forwarding.

Important

The IP address alias you configure for your OpenShift Online application is not persistent throughsystem reboots. If you reboot your computer, you must repeat these steps to correctly enable portforwarding on Mac OS X.

Report a bug

Chapter 9. Monitoring and Troubleshooting

73

Page 77: OpenShift Online 2.0 User Guide en US

Chapter 10. Backing Up and Restoring Application DataUse the rhc snapshot save command to create backups of your OpenShift Online applications, andalso to restore those backups to the server. As a back-up tool, this command creates a tar.gz file notonly of your application but also of any locally-created log and other files, which is then downloaded toyour local machine. The directory structure that exists on the server is maintained in the tar file.

Important

OpenShift Online does not maintain backups of your applications or user data on the OpenShiftOnline servers. The files created by this process are always downloaded to your local machine.

Report a bug

10.1. Creating Application SnapshotsUse the rhc snapshot save command to create a snapshot. The command will prompt for anymissing information, such as your rhlogin and password. The default filename for the snapshot is $App_Name.tar.gz. You can override this path and filename with the --filepath option.

$ rhc snapshot save App_NamePulling down a snapshot to App_Name.tar.gz...Creating and sending tar.gz

RESULT:Success

Report a bug

10.2. Restoring Application SnapshotsUse the rhc snapshot restore command to restore snapshots to the server. This restores the Gitrepository, the application data directories and the log files found in the specified archive. When therestoration is complete, OpenShift Online runs the deployment script on the newly-restored repository,which completes the deployment process in the same way as if you had run git push.

Warning

The rhc snapshot restore command overwrites the remote Git repository. Any changes youmay have made since taking the snapshot will be lost. Importing snapshot data into a localenvironment may delete local content, for example a user table in your database. If you areunsure what effect a snapshot import may have on your local data, use SSH to access yourapplication and make the backup directly.

OpenShift Online All Versions User Guide

74

Page 78: OpenShift Online 2.0 User Guide en US

$ rhc snapshot restore App_NameRestoring from snapshot App_Name.tar.gz...Removing old git repo: ~/git/App_Name.git/Removing old data dir: ~/app-root/data/*Restoring ~/git/App_Name.git and ~/app-root/dataActivation status: success

RESULT:Success

If you used the override process to save your application under a different filename, as outlined inSection 10.1, “Creating Application Snapshots”, you can restore this snapshot version of yourapplication. The following command shows how to restore an application named App_Name, but savedunder the filepath Renamed_App:

$ rhc snapshot restore App_Name --filepath Renamed_App

Report a bug

10.3. Migrating an Application to Another GearAn application can be migrated to another gear with the OpenShift Online client tools. One scenariowhere this may be necessary is when a free plan is upgraded to a paid plan. In this case, an applicationcreated with the free plan exists on a small gear, but with an upgraded plan that application can bemigrated to a medium gear.

Procedure 10.1. Migrate an Application to Another Gear

1. Create a snapshot of your existing application.

$ rhc snapshot save App_Name

The rhc snapshot save command saves the App_Name.tar.gz file in the current workingdirectory. Verify that your application snapshot has been saved.

2. After confirming your application snapshot is saved, delete the existing application.

$ rhc app delete App_Name

3. Create a new application of the same type with the correct gear size, and add any additionalcartridges that existed in the original application. Use the following example to create anapplication on a medium gear, with no additional cartridges because the original application did nothave any.

$ rhc app create App_Name php-5.3 -g medium

However, if the original application contained, for example, the MySQL and phpMyAdmin cartridges,run the following command:

$ rhc app create App_Name php-5.3 mysql-5 phpmyadmin-3 -g medium

4. Finally, restore the earlier saved application snapshot to the newly created application. Be sure tospecify the correct path to the saved application snapshot.

Chapter 10. Backing Up and Restoring Application Data

75

Page 80: OpenShift Online 2.0 User Guide en US

Revision HistoryRevision 1.0.36-0.4 05 Thu Nov 28 2013 Rüdiger Landmann

Rebuild with Publican 4.0.0

Revision 1.0.36-0 Tue Nov 26 2013 Bilhar AulakhAdded information on specifying the size of cartridges.Added information to clarify action_hooks.

Revision 1.0.35-0 Thu Nov 7 2013 Bilhar AulakhAdded two new topics about action hooks for cartridges and during the build process.Added information on configuring application deployment.Added information on adding specific SSH key types.Added information on managing domain membership with client tools.Added information on disabling local gears with multiple HA proxies.Added information on making deployment and rollback changes to applications.Updated port information for binding applications.

Revision 1.0.34 -0 Tue Oct 15 2013 Bilhar AulakhAdded information on configuring application deployment.Added support for PostgreSQL 9.2 from SCL.Added SECRET_TOKEN environment variable.Added Members section for domain membership.Added support for multiple domains.Added table and information about ports available for binding.

Revision 1.0.33-0 Wed Sep 18 2013 Bilhar AulakhAdded information on port forwarding with individual gears.Updated cartridge version numbers.Added Custom Environment Variables section.

Revision History

77