Giter Site home page Giter Site logo

m's Introduction

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 https://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 6.0.14
$ m 7.0.6

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

$ m 6.0
$ m 7.0

List installed binaries:

$ m

  6.0.14
* 7.0.6

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 7.0

Check what the current stable release is:

$ m --stable
$ m --stable 7.0

Download an Enterprise release:

$ m 7.0-ent

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

$ yes | m 7.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.9.4

Removing Binaries

Remove some previously installed versions:

$  m rm 6.0.13 7.0.5

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 7.0.6
/Users/bobbytables/.local/m/versions/7.0.6/bin

Start up mongod 6.0.13 regardless of the active version:

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

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. 7.0)
    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. 7.0)
    m --latest                   Output the latest MongoDB version available (including dev & RCs)
    m --latest X.Y                .. for release series X.Y (eg. 7.0)
    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 ~/.local/m/versions in subdirectories named after the release version (6.0.14, 7.0.6, ...). MongoDB Database Tools binaries are downloaded to ~/.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 ~/.local/bin. 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.

m's People

Contributors

aheckmann avatar alcaeus avatar alexbevi avatar boutell avatar charlievieth avatar dabz avatar devkev avatar dgomezferro avatar gianpaj avatar jameskovacs avatar kallimachos avatar kevinadi avatar mbroadst avatar mpobrien avatar p avatar sindbach avatar stennie avatar tfogo avatar victordenisov avatar vmenajr avatar

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

m's Issues

Add option to download MongoDB tools

As of the MongoDB 4.4 RCs, database tools like mongodump, mongorestore, etc are now separately distributed and versioned from the core server so the tarball downloads only include mongod, mongos, and mongo.

MongoDB Database Tools version 100 supports 3.6 through 4.4. It would be helpful for m to have a shortcut to download the latest tools. The tool binaries should probably be saved in a separate directory from the server versions.

Warning being shown when running the tool

When I run m, I get some warning about using egrep:

$ m
egrep: warning: egrep is obsolescent; using ggrep -E
egrep: warning: egrep is obsolescent; using ggrep -E

I'm running macOS 12.6.1.

`m latest` outputs 226.0.1

I noticed that the latest command referred to in the README gives unexpected output.

emily.pakulski@M-V036M19369:~/mms (master %) $ m latest                                                         
MongoDB version 226.0.1 is not installed.

m installs release candidates by default

Fresh install of m, I wanted to install 4.0:

debian-8% sudo ~/bin/m 4.0              
Checking for latest release of MongoDB 4.0
MongoDB version 4.0.4-rc0 is not installed.
Installation may take a while. Would you like to proceed? [Y/n] 

By default I expected to get a GA version rather than an RC one.

install bug

> m 2.3.2
MongoDB version 2.3.2 is not installed.
Installation may take a while. Would you like to proceed? [y/n] Y
Installing binary...
######################################################################## 100.0%
... removing source
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

Issue with installing any version on KDE Neon

Hello

Right now I have 3.7.9 installed using m
Somehow I can't install a single version using m - all of them return Prebuilt binaries for linux-x86_64 6.0.11 do not appear to be available.. Tried 4.0, 5.0, 6.0 and 7.0.
It might be an issue after my KDE neon updated to 22.04 base (as in #90). But solution there seems to be returning same do not appear to be available.
Not sure if KDE has changed how distro is detected and its no longer seen as Ubuntu 22.04.
Considering it used to work for 3.7.9 but stopped working now - can you suggest any way for me work around it?
Using m is quite indispensible for development so can`t imagine myself not using it.

MongoDB 4.0.0-rc# macOS binaries not found

$ m 4.0.0-rc1
MongoDB version 4.0.0-rc1 is not installed.
Installation may take a while. Would you like to proceed? [y/n] y
Binary for "Darwin 4.0.0-rc1" not supported. Attempting to install from source.
Installation may take a while. Would you like to proceed? [y/n]

hooks

pre/post version change, install
store in config

4.0 and 4.2 incorrectly identified as enterprise, $active includes "-ent"

M-C02F13KPMD6M:~ frank.snow$ mongod --version
db version v4.2.24
git version: 5e4ec1d24431fcdd28b579a024c5c801b8cde4e2
allocator: system
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64

M-C02F13KPMD6M:~ frank.snow$     active=`mongod --version | grep "version\s*v[0-9]" | egrep -o '[0-9]+\.[0-9]+\.[0-9]+([-_\.][a-zA-Z0-9]+)?' | head -1`

M-C02F13KPMD6M:~ frank.snow$     ent=`mongod --version | egrep "(modules:\s*)|\"enterprise\"?" | wc -l`

M-C02F13KPMD6M:~ frank.snow$ echo $active
4.2.24
M-C02F13KPMD6M:~ frank.snow$ echo $ent
1

M-C02F13KPMD6M:~ frank.snow$     if [[ $ent == *1 ]]; then
>       active="$active-ent"
>     fi
M-C02F13KPMD6M:~ frank.snow$ echo $active
4.2.24-ent

M-C02F13KPMD6M:~ frank.snow$ m
    4.0.28 
    4.2.24 
    4.4.19 
    5.0.15 
    6.0.4 

Does not show active version with asterisk because $active ends with -ent.

Does not work with Ubuntu 22.04

First: thanks so much for your work on m!

In Ubuntu 22.04, the following error comes up for mongodb 5.0, 6.0 and 7.0 (I didn't try anything older, but presumably the same):

ubuntu@ip-172-26-6-41:~$ npm install -g m
added 1 package, and audited 2 packages in 559ms
...
ubuntu@ip-172-26-6-41:~$ m 5.0
>> Checking for stable release of MongoDB 5.0
MongoDB version 5.0.21 is not installed.
Installation may take a while. Would you like to proceed? [y/N] y
...
Activating: MongoDB Server 5.0.21, MongoDB Database Tools 
ubuntu@ip-172-26-6-41:~$ mkdir -p ~/mongodb-data/5.0
ubuntu@ip-172-26-6-41:~$ mongod --dbpath=/home/apostrophe/mongodb-data/5.0
mongod: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory

I do have the right folder in my PATH:

ubuntu@ip-172-26-6-41:~$ which mongod
/home/ubuntu/.local/bin/mongod

Ubuntu 22.04 moved to openssl 3. But mongod community edition works fine on Ubuntu 22.04. It sounds like m is probably downloading the wrong binaries.

Any suggestions?

Thanks!

m latest thinks RCs are newer then final releases

$ m latest
....
2.4.0
2.4.0-rc0
2.4.0-rc1
2.4.0-rc2
2.4.0-rc3
2.4.1
2.4.2
2.4.2-rc0
2.4.3
2.4.3-rc0

$ m latest
/usr/local/bin/m: line 121: mongod: command not found
MongoDB version 2.4.3-rc0 is not installed.
Installation may take a while. Would you like to proceed? [y/n] y
... installing binary

7.1%^C

bjori@anden:~/Sources/m (master) $ m 2.4.3
/usr/local/bin/m: line 121: mongod: command not found
MongoDB version 2.4.3 is not installed.
Installation may take a while. Would you like to proceed? [y/n] y
... installing binary

################################################################## 100.0%

... removing source
/usr/local/bin/m: line 121: mongod: command not found
... installation complete

(I'm assuming those commands not found are due to the fact I don't have any mongod in my global path)

RFE: Install mongosh

I expected this tool to install mongosh along with mongod & mongos, but that’s not what happens. The tools also don’t include the shell.

I can install it via other ways, but it’d be nice if this tool offered it, too.

Thanks for considering!

Syntax error: "|" unexpected

Just installed it and tried running:

$ sudo make install 
cp bin/m /usr/local/bin/m
$ sudo m
/usr/local/bin/m: 2: Syntax error: "|" unexpected

m wont run without sudo

I just did a fresh install of npm via brew - all done without sudo. But running m gives as my user gives

mkdir: /usr/local/m/versions: Permission denied
Error: Failed to create versions directory (/usr/local/m/versions), do you have permissions to do this?

but sudo m is happy. Is this an issue installing via npm? How do I fix this correctly so that I don't have to sudo to use m ?

Add version-based support for native arm64 binaries on macOS when available

Waiting on resolution of upstream tickets in order to set a version check for m to try downloading arm64 binaries on macOS:

In the interim. Intel binaries will be installed on Apple Silicon per #67 (m 1.7.0) for use with Rosetta 2.

Note: if you only need to install a single version of MongoDB server on macOS, I recommend following the instructions for Installation via brew in the MongoDB Documentation.

Insecure temporary file use

m hardcodes /tmp/m.log as its log path and writes to that file even if it exists. An unprivileged user can set up a symlink from this path to anywhere on the system, and if m is invoked as, say, root this can allow unprivileged users to overwrite arbitrary files on the system causing a denial of service.

Using mktemp should be an improvement over the current situation.

`m ls` error : command not found

Using m 1.8.2:

╰─ m ls                                                                                                                                                                                                                                                                                                                                                                  ─╯
/usr/local/bin//m: line 1318: {: command not found
Error: Could not find any releases for the requested version

Update M_PREFIX behaviour to default to a writeable directory

To simplify installation, the M_PREFIX environment variable should default to the user's home directory instead of /usr/local/. The /usr/local default originates from npm install -g.

Expected behaviour variation for npm installation:

Expected behaviour for install via wget:

  • if M_PREFIX is not set but /usr/local/m exists and is writeable, use /usr/local/m
  • if M_PREFIX is not set but /usr/local/m exists and is not writeable, exit with message recommending sudo chown -R $(whoami) /usr/local/m
  • if M_PREFIX is not set and /usr/local/m doesn't exist, use ~/m

General behaviour:

  • if M_PREFIX is set, use this base path
  • if M_PREFIX is set but the path isn't writeable, exit with message recommending sudo chown -R $(whoami) $M_PREFIX

Problem setting up on Amazon Linux 1

I’m trying to install m on Amazon Linux 1, with the following steps

  1. npm install -g m --build-from-source
  2. m 4.0.10

but then launching mongo gives:
mongo: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by mongo)

amzn1 seems to be shopping with glibc 2.17 only.

Can I force m to compile mongo rather than just install the binary?

Sort ordering broke latest version feature

It looks like this commit introduced some change that makes output of:

m list

Look like

    7972:0.0.4_rc1
    7979:0.0.4_rc1
    7982:0.0.4_rc1
    7989:0.0.3
    7992:0.0.3
    7999:0.0.3
    8002:0.0.3
    8009:0.9.1
    8012:0.9.1
    8019:0.9.1
    8022:0.9.1

Which breaks

m --latest

command.

config

for platform info, hooks, etc

m 4.2.0 isn't finding 4.2.0-rc0

m 4.2.0
MongoDB version 4.2.0 is not installed.
Installation may take a while. Would you like to proceed? [Y/n] y
Binary not available with SSL support. Checking url for generic (non-SSL) binaries.
Binary for "Darwin 4.2.0" not supported. Attempting to install from source.

`m ls` throws warning

Hi there,

Just a heads-up since it works correctly, but when I run m ls I get the following warnings before the list of possible versions:

/usr/local/bin/m: command substitution: line 469: syntax error near unexpected token `|'
/usr/local/bin/m: command substitution: line 469: `    | awk '{ print "  " $1 }''

This is on Mac OS X 10.10.1, with m v1.0.0

Prebuilt binaries for linux-x86_64 4.2.0 do not appear to be available for Ubuntu 22

After updating to m 1.8.8 I am able to install all 3.x versions and all 4.4 versions. But all 4.2 versions give same error about not having prebuilt binaries. It would be understandble if 4.x versions were unavailable at all because of Ubuntu 22.04. So far 3.x, 4.4 and 5.3 versions work just fine and only 4.2 versions seem to beinconsistent.Whichisboth wierdand bad since there is no mongo upgrade path from 3.x without 4.2.
m --version 1.8.8
cat /etc/lsb-release
DISTRIB_ID=neon DISTRIB_RELEASE=22.04 DISTRIB_CODENAME=jammy DISTRIB_DESCRIPTION="KDE neon 5.27"

Originally posted by @venorme in #92 (comment)

src

print full source url for given version

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.