Giter Club home page Giter Club logo

openshift-cartridge-mongodb's Introduction

Custom MongoDB cartridge for OpenShift

mongodb-openshift

This is a custom OpenShift cartridge providing MongoDB 3.4.x + WiredTiger storage engine.

Why

Because the standard OpenShift MongoDB cartridge is stuck at 2.4.

When to use

When you need a quick and unsofisticated solution to run your application with the latest MongoDB version.

How to

Open your application in the web console, go to "See the list of cartridges you can add", paste the URL below in "Install your own cartridge" textbox at the bottom of the page and click "Next".

https://raw.githubusercontent.com/icflorescu/openshift-cartridge-mongodb/master/metadata/manifest.yml

Then you can use MONGODB_URL environment variable to connect from an application running in the main web cartridge.

To keep things flexible, the connection string stored in MONGODB_URL ends with / and does not include a database name. Use your application logic to name/create your database(s) as needed.

For instance, here's how you'd do it in a Node.js application using Mongoose ODM:

var mongoose = require('mongoose');
...
// Mongoose will create database_name if necessary
mongoose.connect(process.env.MONGODB_URL + 'database_name', { db: { nativeParser: true } });

Using the command line

Make sure you have rhc installed (see here).

If you want to add a MongoDB instance based on this cartridge to an existing application:

rhc cartridge-add https://raw.githubusercontent.com/icflorescu/openshift-cartridge-mongodb/master/metadata/manifest.yml \
  --app appname

...where appname is the name of your application.

To create an app based on the standard Node.js v0.10 cartridge and this one, run:

rhc app create appname \
  nodejs-0.10 \
  https://raw.githubusercontent.com/icflorescu/openshift-cartridge-mongodb/master/metadata/manifest.yml

If you want to use the latest Node.js version, you'll have to use a custom Node.js cartridge as well:

rhc app create appname \
  https://raw.githubusercontent.com/icflorescu/openshift-cartridge-nodejs/master/metadata/manifest.yml \
  https://raw.githubusercontent.com/icflorescu/openshift-cartridge-mongodb/master/metadata/manifest.yml

Notes

  • Using this cartridge to host your data does provide a cheap solution, but please understand that you'll be using it on your own responsibility. WiredTiger engine is a memory-hungry beast and you could eventually run into problems. Use a specialized Database-as-a Service provider for critical data (mLab, Compose, etc.).
  • This is a lean cartridge. To save space, just mongod is installed. No client libraries, no mongo console. If you need external access to your data, use rhc port-forward.
  • By default, the underlying MongoDB instance will accept unauthenticated access, which should be fine for most typical usage scenarios. See the discussion here for more info.
  • Can't think of a safe way to make this cartridge auto-updatable. For now we'll just have to use mongodump, destroy the cartridge, install the new version, then do a mongorestore.
  • Don't hesitate to make a pull-request with an updated version in this file if you notice this cartridge version is behind the latest stable official MongoDB linux binary.

FAQ

Q: I'm getting the error Cannot download, must be smaller than 20480 bytes while trying to deploy the cartridge to OpenShift. What am I doing wrong?

A: You're probably trying to use the URL https://github.com/icflorescu/openshift-cartridge-mongodb instead of https://raw.githubusercontent.com/icflorescu/openshift-cartridge-mongodb/master/metadata/manifest.yml. A common mistake for people not paying sufficient attention while trying to use a custom cartridge for the first time.


Q: How do I change the default mongod options?

A: ssh to the MongoDB gear, edit the control script with nano mongodb/bin/control and make sure to restart afterwards.


Q: How can I ssh to a MongoDB cartridge running in a secondary application gear?

A: You can discover the secondary gear URL by running rhc app show appname --gears.

Related

Since you're here, chances are you might also be interested in this custom Node.js cartridge.

Credits

See contributors here.

If you find this repo useful, don't hesitate to give it a star and spread the word.

Before raising issues

I'm getting lots of questions from people just learning to do web development or simply looking to solve a very specific problem they're dealing with. While I will answer some of them for the benefit of the community, please understand that open-source is a shared effort and it's definitely not about piggybacking on other people's work. On places like GitHub, that means raising issues is encouraged, but coming up with useful PRs is a lot better. If I'm willing to share some of my code for free, I'm doing it for a number of reasons: my own intellectual challenges, pride, arrogance, stubbornness to believe I'm bringing a contribution to common progress and freedom, etc. Your particular well-being is probably not one of those reasons. I'm not in the business of providing free consultancy, so if you need my help to solve your specific problem, there's a fee for that.

License

The ISC License.

openshift-cartridge-mongodb's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openshift-cartridge-mongodb's Issues

$MONGODB_URL

in fact i can not find $MONGODB_URL how i can find it

Please help ,Thanks

Filed to connect to mongodb

By following this repository, I create an application in openshift.

2016-10-04 9 48 38

I click the url, the parse page loaded successfully. But when I tried to access dashboard, the page never stop loading...

And when I check the log, it shows:

parse-server-example running on port 8080.
info: Parse LiveQuery Server starts running
warn: Unable to ensure uniqueness for usernames:  MongoError: failed to connect to server [localhost:43016] on first connect
    at Pool.<anonymous> (/var/lib/openshift/57f3a8d22d5271067700004b/app-root/runtime/repo/node_modules/mongodb-core/lib/topologies/server.js:313:35)
    at emitOne (events.js:96:13)
    at Pool.emit (events.js:188:7)
    at Connection.<anonymous> (/var/lib/openshift/57f3a8d22d5271067700004b/app-root/runtime/repo/node_modules/mongodb-core/lib/connection/pool.js:260:12)
    at Connection.g (events.js:291:16)
    at emitTwo (events.js:106:13)
    at Connection.emit (events.js:191:7)
    at Socket.<anonymous> (/var/lib/openshift/57f3a8d22d5271067700004b/app-root/runtime/repo/node_modules/mongodb-core/lib/connection/connection.js:162:49)
    at Socket.g (events.js:291:16)
    at emitOne (events.js:96:13)
warn: Unable to ensure uniqueness for user email addresses:  MongoError: failed to connect to server [localhost:43016] on first connect
    at Pool.<anonymous> (/var/lib/openshift/57f3a8d22d5271067700004b/app-root/runtime/repo/node_modules/mongodb-core/lib/topologies/server.js:313:35)
    at emitOne (events.js:96:13)
    at Pool.emit (events.js:188:7)
    at Connection.<anonymous> (/var/lib/openshift/57f3a8d22d5271067700004b/app-root/runtime/repo/node_modules/mongodb-core/lib/connection/pool.js:260:12)
    at Connection.g (events.js:291:16)
    at emitTwo (events.js:106:13)
    at Connection.emit (events.js:191:7)
    at Socket.<anonymous> (/var/lib/openshift/57f3a8d22d5271067700004b/app-root/runtime/repo/node_modules/mongodb-core/lib/connection/connection.js:162:49)
    at Socket.g (events.js:291:16)
    at emitOne (events.js:96:13)
(node:470919) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): MongoError: failed to connect to server [localhost:43016] on first connect
(node:470919) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): MongoError: failed to connect to server [localhost:43016] on first connect

I got the port number by:

rhc port-forward -a {myapp}

It seems I need the username and password for mongodb. I'd like to create in my db. Then when I ssh to my mongodb gear. I enter mongo, then got:

bash: mongo: command not found

What should I do? Thanks

Upgrade

Hi,

I'm using an older version of this cartridge. Is it possible to upgrade easily to the latest version now without losing the previous data?

Cheers!

mongodb.config

Hi, where can I find the mongodb.config file?

There's one in /var/mongodb.conf but I can't edit it (permission denied, can't sudo).

I'd like to add smallfiles=true and noprealloc=true to preserve disk space in my gear.

Thank you!!

Looking for a maintainer

Hi everyone,

Thank you for using this cartridge since the beginning of 2015.

I'm not using OpenShift in my projects anymore, which means there's now little reason for me to maintain this repository as well as it probably deserves.

So, if anyone is willing and ready to step up and become a maintainer, please don't hesitate to drop me a line!

Can't see MONGODB_URL (one app, separate gears) ?

I'm sorry if this is stupid, but I'm running official Go cartridge as one gear and this one as second. My first 'Go' gear doesn't see MONGODB_URL environment variable, is this ok ?

If you want to see it for yourself, add these lines to 'hello' function of brand new web.go:

fmt.Fprintln(res, "List of environment variables:")
fmt.Fprintln(res, "------------------------------")
ev := os.Environ()
for _, e := range ev { fmt.Fprintln(res, e)}

Support for username and password

Hi. I am very new to OpenShift and was getting errors in their mongodb-2.4 cartridge so I am trying your 2.6 cartridge. It fixed my site so now it works. Thanks!

But, the default OpenShift mongodb cartridge sets itself up with a username and password by default which are populated in environment variables.

Is there a way to get a username and password on the database, and have it set up by default?

Or is a password unnecessary because of how OpenShift sandboxes gears?

The cartridge manifest could not be downloaded. The cartridge manifest must be smaller thatn 20480 bytes

I just tried to make a new Openshift app using your Mongodb 3.2 cartridge. When trying to add your custom cartridge to my new app it gave me the below error. It has always worked before. Is this an Openshift issue? Any ideas on how to solve the problem?

The cartridge manifest at 'https://github.com/icflorescu/openshift-cartridge-mongodb' could not be downloaded: The cartridge manifest at 'https://github.com/icflorescu/openshift-cartridge-mongodb' must be smaller than 20480 bytes.

help!Couldn't connect to mongodb

mongodb.log

2015-07-04T12:00:44.901-0400 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=7G,session_max=20000,eviction=(threads_max=4),statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2015-07-04T12:00:45.390-0400 I CONTROL  [initandlisten] MongoDB starting : pid=196522 port=27017 dbpath=/var/lib/openshift/557e86a4500446e106000178/app-root/data/.mongodb/data 64-bit host=ex-std-node631.prod.rhcloud.com
2015-07-04T12:00:45.391-0400 I CONTROL  [initandlisten] 
2015-07-04T12:00:45.391-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-07-04T12:00:45.391-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-07-04T12:00:45.391-0400 I CONTROL  [initandlisten] 
2015-07-04T12:00:45.391-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-07-04T12:00:45.391-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-07-04T12:00:45.391-0400 I CONTROL  [initandlisten] 
2015-07-04T12:00:45.391-0400 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 250 processes, 1024 files. Number of processes should be at least 512 : 0.5 times number of files.
2015-07-04T12:00:45.391-0400 I CONTROL  [initandlisten] 
2015-07-04T12:00:45.391-0400 I CONTROL  [initandlisten] db version v3.0.3
2015-07-04T12:00:45.391-0400 I CONTROL  [initandlisten] git version: b40106b36eecd1b4407eb1ad1af6bc60593c6105
2015-07-04T12:00:45.391-0400 I CONTROL  [initandlisten] build info: Linux build14.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2015-07-04T12:00:45.391-0400 I CONTROL  [initandlisten] allocator: tcmalloc
2015-07-04T12:00:45.391-0400 I CONTROL  [initandlisten] options: { net: { bindIp: "127.5.252.2", unixDomainSocket: { enabled: false } }, storage: { dbPath: "/var/lib/openshift/557e86a4500446e106000178/app-root/data/.mongodb/data", engine: "wiredTiger" }, systemLog: { logAppend: true, logRotate: "reopen", quiet: true } }
2015-07-04T12:00:45.473-0400 I NETWORK  [initandlisten] waiting for connections on port 27017

nodejs.log

/var/lib/openshift/557e86a4500446e106000178/app-root/runtime/repo/node_modules/connect-mongo/node_modules/mongodb/lib/server.js:228
        process.nextTick(function() { throw err; })
                                            ^
Error: connect ECONNREFUSED
    at errnoException (net.js:901:11)
    at Object.afterConnect [as oncomplete] (net.js:892:19)

crashes: Cannot allocate memory

2016-05-21T22:31:48.042-0400 E STORAGE  [thread1] WiredTiger (12) [1463884307:558146][277593:0x7faf94a62700], file:collection-2--8597162973160007227.wt, WT_SESSION.checkpoint: collection-2--8597162973160007227.wt write error: failed to write 8192 bytes at offset 140288000: Cannot allocate memory
2016-05-21T22:31:48.048-0400 E STORAGE  [thread1] WiredTiger (12) [1463884308:48790][277593:0x7faf94a62700], checkpoint-server: checkpoint server error: Cannot allocate memory
2016-05-21T22:31:48.048-0400 E STORAGE  [thread1] WiredTiger (-31804) [1463884308:48832][277593:0x7faf94a62700], checkpoint-server: the process must exit and restart: WT_PANIC: WiredTiger library panic
2016-05-21T22:31:48.048-0400 I -        [thread1] Fatal Assertion 28558
2016-05-21T22:31:48.048-0400 I -        [thread1] 
***aborting after fassert() failure
2016-05-21T22:31:48.053-0400 I -        [WTJournalFlusher] Fatal Assertion 28559
2016-05-21T22:31:48.053-0400 I -        [WTJournalFlusher] 
***aborting after fassert() failure
2016-05-21T22:31:48.085-0400 I -        [conn12] Fatal Assertion 28559
2016-05-21T22:31:48.085-0400 I -        [conn12] 
***aborting after fassert() failure
2016-05-21T22:31:48.246-0400 F -        [thread1] Got signal: 6 (Aborted).
 0x12d6632 0x12d5559 0x12d5d62 0x3000c0f7e0 0x3000432625 0x3000433e05 0x126cb32 0x1063543 0x1a2935c 0x1a294fd 0x1a298e4 0x19b2a4b 0x3000c07aa1 0x30004e893d
----- BEGIN BACKTRACE -----
{"backtrace":[{"b":"400000","o":"ED6632","s":"_ZN5mongo15printStackTraceERSo"},{"b":"400000","o":"ED5559"},{"b":"400000","o":"ED5D62"},{"b":"3000C00000","o":"F7E0"},{"b":"3000400000","o":"32625","s":"gsignal"},{"b":"3000400000","o":"33E05","s":"abort"},{"b":"400000","o":"E6CB32","s":"_ZN5mongo13fassertFailedEi"},{"b":"400000","o":"C63543"},{"b":"400000","o":"162935C","s":"__wt_eventv"},{"b":"400000","o":"16294FD","s":"__wt_err"},{"b":"400000","o":"16298E4","s":"__wt_panic"},{"b":"400000","o":"15B2A4B"},{"b":"3000C00000","o":"7AA1"},{"b":"3000400000","o":"E893D","s":"clone"}],"processInfo":{ "mongodbVersion" : "3.2.3", "gitVersion" : "b326ba837cf6f49d65c2f85e1b70f6f31ece7937", "compiledModules" : [], "uname" : { "sysname" : "Linux", "release" : "2.6.32-573.12.1.el6.x86_64", "version" : "#1 SMP Mon Nov 23 12:55:32 EST 2015", "machine" : "x86_64" }, "somap" : [ { "elfType" : 2, "b" : "400000" }, { "b" : "7FFEE26DF000", "elfType" : 3 }, { "path" : "/lib64/librt.so.1", "elfType" : 3 }, { "path" : "/lib64/libdl.so.2", "elfType" : 3 }, { "path" : "/usr/lib64/libstdc++.so.6", "elfType" : 3 }, { "path" : "/lib64/libm.so.6", "elfType" : 3 }, { "path" : "/lib64/libgcc_s.so.1", "elfType" : 3 }, { "path" : "/lib64/libpthread.so.0", "elfType" : 3 }, { "path" : "/lib64/libc.so.6", "elfType" : 3 }, { "path" : "/lib64/ld-linux-x86-64.so.2", "elfType" : 3 } ] }}
 mongod(_ZN5mongo15printStackTraceERSo+0x32) [0x12d6632]
 mongod(+0xED5559) [0x12d5559]
 mongod(+0xED5D62) [0x12d5d62]
 libpthread.so.0(+0xF7E0) [0x3000c0f7e0]
 libc.so.6(gsignal+0x35) [0x3000432625]
 libc.so.6(abort+0x175) [0x3000433e05]
 mongod(_ZN5mongo13fassertFailedEi+0x82) [0x126cb32]
 mongod(+0xC63543) [0x1063543]
 mongod(__wt_eventv+0x40C) [0x1a2935c]
 mongod(__wt_err+0x8D) [0x1a294fd]
 mongod(__wt_panic+0x24) [0x1a298e4]
 mongod(+0x15B2A4B) [0x19b2a4b]
 libpthread.so.0(+0x7AA1) [0x3000c07aa1]
 libc.so.6(clone+0x6D) [0x30004e893d]
-----  END BACKTRACE  -----

Missing features (for production)

Hi! Congrats for the great cartridge.

You are very clear stating that this code is not production ready. Is there any special reason to say that? Some topic that you could use some help?

Like performance, security, reliability...

Thanks

Can't connect to mongodb

Hi!

I setup your cartridge on my openshift account by i can't connect to mongodb.
When i check the "MONGODB_URL" environment variable it seems to be set to my public adress:
mongodb://****.rhcloud.com
Shouldnt this be the local adress to the cartridge as i dont want it to be accessible from outside?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.