• Stars
    star
    267
  • Rank 153,621 (Top 4 %)
  • Language
    Shell
  • License
    MIT License
  • Created about 12 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

mongodb version management

m - MongoDB Version Manager

m helps you download, use, and manage multiple versions of the MongoDB server and command-line tools.

This can be useful for development & testing environments. For example, testing release upgrades/downgrades or potential behavior differences between versions.

Where possible m will try to download the distro-specific binaries for your O/S and version. If a binary appears to be unavailable, m will ask if you want to try building from source.

NOTE: Building MongoDB from source requires you to preinstall all of the relevant dependencies & toolchain to build the desired version of MongoDB. Installing those is outside the scope of what m does.

Prerequisites

To install binary packages m requires a 64-bit O/S which:

Environments that should work include:

  • Linux (RHEL/CentOS, Debian/Ubuntu, Amazon Linux)
  • macOS 10.14 (Mojave) and later
  • Windows 10 with Ubuntu on Windows
  • Docker using a supported Linux distro

Installation

m is a bash script which can be installed & updated via npm for convenience:

$ npm install -g m

or installed by cloning the GitHub repo and running make install:

$ git clone git://github.com/aheckmann/m.git && cd m && make install

or fetched via wget and copied to a location of your choice:

$ wget https://raw.githubusercontent.com/aheckmann/m/master/bin/m && chmod +x ./m

Downloading MongoDB Binaries

Specify a MongoDB server version to try download a binary package (if available for your current O/S) or switch to a previously downloaded copy. After m successfully downloads or switches to a specified version of MongoDB, those binaries will become the default in the install path (typically $HOME/.local/bin/; see Details below for more information).

$ m 4.4.15
$ m 5.0.9

You can also specify a release series to download the latest available revision:

$ m 4.4
$ m 5.0

List installed binaries:

$ m

  4.2.21
  4.4.15
* 5.0.9
  6.0.0

Use or download the latest official release:

$ m latest

Use or download the stable official release:

$ m stable

Check what the latest available release is:

$ m --latest
$ m --latest 6.0

Check what the current stable release is:

$ m --stable
$ m --stable 6.0

Download an Enterprise release:

$ m 6.0-ent

Select a MongoDB version without prompting for confirmation if a download is required:

$ yes | m 6.0

Downloading MongoDB Database Tools

The Database Tools (mongodump, mongorestore, etc.) are now released separately from the server. You can use m to manage your MongoDB Database Tools version independently of your MongoDB server and shell versions.

List available Database Tools versions:

$ m tools ls

List installed Database Tools versions:

$ m tools installed

Use or download the latest stable release of the Database Tools:

$ m tools stable

Use or download a specific version of the Database Tools:

$ m tools 100.0.0

Removing Binaries

Remove some previously installed versions:

$  m rm 4.4.10 4.4.13

Binary Usage

Multiple versions of MongoDB can be downloaded and targeted directly.

Ask m for the binary path for a specific version that has already been downloaded:

$ m bin 4.4.15
/Users/bobbytables/.local/m/versions/4.4.15/bin

Ask m for the binary path for the latest revision of a release already downloaded:

$ m bin 4.4
/Users/bobbytables/.local/m/versions/4.4.15/bin

Start up mongod 5.0 regardless of the active version:

$ m use 5.0 --port 29000 --dbpath ./data/

Execute a script with the 5.0 mongo shell regardless of the active version:

$ m shell 5.0 some.js

Execute a script with a 5.0.9 mongo shell and some additional flags:

$ m shell 5.0.9 --port 29000 --norc

When installing or changing the active version you might want to run custom scripts:

$ m pre install /path/to/my/script
$ m post install /path/to/script
$ m pre change /path/to/my/script
$ m post change /path/to/script

Multiple scripts may be added for any event. To add two pre change scripts:

$ m pre change /path/to/script1
$ m pre change /path/to/script2

Scripts are executed in the order they were added.

List all pre change hooks:

$ m pre change

/path/to/script1
/path/to/script2

List all post install hooks:

$ m post install

/path/to/scriptA
/path/to/scriptB
/path/to/scriptC

To remove a post install hook:

$ m post install rm /path/to/scriptB

To remove all post install hooks:

$ m post install rm

Usage

Output from m --help:

  Usage: m [options] [COMMAND] [config]

  Commands:

    m                            Output versions installed
    m stable [config ...]        Install or activate the latest stable MongoDB release
    m latest [config ...]        Install or activate the latest MongoDB release (including dev & RCs)
    m X.Y                        Install or activate the latest patch release for MongoDB X.Y (eg. 3.6)
    m <version> [config ...]     Install and/or use MongoDB <version>
    m <version> --legacy         Install generic Linux version (does not include SSL)
    m use <version> [args ...]   Execute mongod <version> with [args ...]
    m shard <version> [args ...] Execute mongos <version> with [args ...]
    m shell <version> [args ...] Open a mongo shell <version> with [args ...]
    m bin <version>              Output bin path for <version>
    m rm <version ...>           Remove the given version(s)
    m --stable                   Output the latest stable MongoDB version available
    m --stable X.Y                .. for release series X.Y (eg. 3.6)
    m --latest                   Output the latest MongoDB version available (including dev & RCs)
    m --latest X.Y                .. for release series X.Y (eg. 3.6)
    m ls                         Output the versions of MongoDB available
    m installed [--json]         Output installed versions available (optionally, in JSON format)
    m src <version>              Output the url for source used for the given <version>
                                   (useful if installed from source)
    m pre <event> [script]       Declare one or list scripts to execute before <event>
                                   (scripts must use absolute paths)
    m post <event> [script]      Declare one or list scripts to execute after <event>
                                   (scripts must use absolute paths)
    m pre <event> rm [script]    Remove pre <event> script
    m post <event> rm [script]   Remove post <event> script
    m tools stable               Install or activate the latest stable Database Tools release
    m tools X.Y.Z                Install or activate the Database Tools X.Y.Z 
    m tools ls                   Output the versions of the Database Tools available
    m tools installed [--json]   Output installed versions of the Database Tools available

  Events:

    change   Occurs when switching MongoDB versions
    install  Occurs when installing a previously uninstalled MongoDB version

  Options:

    -V, --version   Output current version of m
    -h, --help      Display help information

  Aliases:

    installed  lls
    shard      sd, mongos
    shell      s, sh, mongo
    list       ls, available, avail
    use        as, mongod
    which      bin

Details

By default m downloads MongoDB binaries to /usr/local/m/versions in subdirectories named after the release version (3.2.16, 3.4.9, ...). MongoDB Database Tools binaries are downloaded to /usr/local/m/tools/versions in subdirectories named after the release version (100.0.0, 100.0.1, ...). Activated MongoDB binaries are symlinked into the bin directory in /usr/local. To alter where m operates, export the M_PREFIX environment variable with your preferred path prefix.

Previously downloaded versions of MongoDB can be activated using m <version> or selected using of the variations in the Binary Usage section above.

License

MIT

Inspiration

Yes tj, this is nearly identical to n. Huge thanks!

Disclaimer

This software is not supported by MongoDB, Inc. under any of their commercial support subscriptions or otherwise. Any usage of m is at your own risk. Bug reports, feature suggestions, and questions can be posted in the Issues section on GitHub.

More Repositories

1

gm

GraphicsMagick for node
JavaScript
6,950
star
2

gridfs-stream

Easily stream files to and from MongoDB
JavaScript
615
star
3

node-ses

DEPRECATED
JavaScript
200
star
4

observed

ES6 Object.observe with nested object support - the way I want it (DEPRECATED)
JavaScript
159
star
5

sliced

A faster JavaScript alternative to [].slice.call(arguments)
JavaScript
95
star
6

mpromise

Promises/A+ conformant implementation
JavaScript
86
star
7

node-email

DEPRECATED
JavaScript
84
star
8

greadme

Locally preview your markdown, Github style
JavaScript
76
star
9

gleak

Global variable leak detection for Node.js
JavaScript
70
star
10

gridform

Stream formidable uploads into MongoDB GridFS
JavaScript
59
star
11

muri

Muri is your friendly neighborhood MongoDB URI parser for Node.js
JavaScript
32
star
12

jquery.hook

Enables hooking into any jQuery method
31
star
13

js-styleguide

A javascript style guide.
27
star
14

mongooser

Mongoose REPL
JavaScript
23
star
15

connect-multipart-gridform

Connect multipart middleware configured to use MongoDB GridFS for file storage.
JavaScript
18
star
16

gm-demo

image manipulation demo on heroku
JavaScript
16
star
17

Nodal-Kombat

Multiplayer realtime fighting game
JavaScript
16
star
18

koa-mongodb-session

MongoDB backed session middleware for koa.js
JavaScript
15
star
19

graceful-shutdown

Shuts down a server gracefully upon the first specified signal received
JavaScript
13
star
20

mongodb-schema-miner

Generate schemata from MongoDB collections
JavaScript
12
star
21

jQuery.use

jQuery.use provides you on demand asynchronously loaded jQuery plugins at your fingertips.
JavaScript
11
star
22

regexp-clone

Clones RegExps with flag and lastIndex preservation
JavaScript
9
star
23

channel9

channel9 demo of nodejs + mongodb + graphicsmagick
JavaScript
8
star
24

gomon

MongoDB shell written in Node.js
JavaScript
8
star
25

.vim

vim
Vim Script
8
star
26

koa-session-mongodb

MongoDB backed session middleware for Koa
JavaScript
8
star
27

mongorc.js

.mongorc.js helpers
JavaScript
8
star
28

node-gameroom

My basic starter kit for creating realtime web-based games with nodejs.
JavaScript
8
star
29

once-upon

Executes a callback at most once upon the first of any number of events
JavaScript
7
star
30

express-custom-errors

What if you want to serve customized views for 403, 502, etc? That's what this plugin is for.
JavaScript
3
star
31

jquery-ui-lasso

A simple mouse lasso for jQuery ui
3
star
32

npm-downloads

Prints the number of downloads for a given npm package and the packages that directly depend on it
JavaScript
3
star
33

mongo-replset-test

Quickly set up a mongodb replica set test with authentication enabled
JavaScript
3
star
34

groups-of

Divides arrays into groups of a specified cardinality.
JavaScript
2
star
35

node-gmp

gmp for node
JavaScript
2
star
36

tic-tac-node

A silly demo of node and express
JavaScript
1
star
37

nproj

bare bones node project generator
Shell
1
star
38

talks

My talks
JavaScript
1
star
39

workshop-04-2013

JavaScript
1
star
40

npm-update-test

Test repo for https://github.com/npm/npm/issues/19107
1
star