Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and manage MongoDB using the m tool

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you how to use the m tool to install and manage MongoDB. I hope you will get something after reading this article. Let's discuss it together.

M is a tool for managing MongoDB versions. To put it simply, it can help you install the specified version of MongoDB.

Install m:

[root@test /] # npm install-g m

Npm http GET https://registry.npmjs.org/m

Npm http GET https://registry.npmjs.org/m

Npm http GET https://registry.npmjs.org/m

Npm ERR! Network connect ETIMEDOUT

Npm ERR! Network This is most likely not a problem with npm itself

Npm ERR! Network and is related to network connectivity.

Npm ERR! Network In most cases you are behind a proxy or have bad network settings.

Npm ERR! Network

Npm ERR! Network If you are behind a proxy, please make sure that the

Npm ERR! Network 'proxy' config is set properly. See: 'npm help config'

Npm ERR! System Linux 2.6.32-696.el6.x86_64

Npm ERR! Command "node" / usr/bin/npm "" install ""-g "" m "

Npm ERR! Cwd / root/20180713/sharding

Npm ERR! Node-v v0.10.48

Npm ERR! Npm-v 1.3.6

Npm ERR! Syscall connect

Npm ERR! Code ETIMEDOUT

Npm ERR! Errno ETIMEDOUT

Npm ERR!

Npm ERR! Additional logging details can be found in:

Npm ERR! / root/20180713/sharding/npm-debug.log

Npm ERR! Not ok code 0

An error was reported. Please cancel the proxy server configuration:

[root@test /] # npm config set strict-ssl false

Run again:

[root@test /] # npm install-g m

Npm http GET https://registry.npmjs.org/m

Npm http GET https://registry.npmjs.org/m

Npm http GET https://registry.npmjs.org/m

Npm http 200 https://registry.npmjs.org/m

Npm http GET https://registry.npmjs.org/m/-/m-1.4.1.tgz

Npm http 200 https://registry.npmjs.org/m/-/m-1.4.1.tgz

/ usr/bin/m-> / usr/lib/node_modules/m/bin/m

Npm WARN unmet dependency / usr/lib/node_modules/block-stream requires inherits@'~2.0.0' but will load

Npm WARN unmet dependency undefined

Npm WARN unmet dependency which is version undefined

Npm WARN unmet dependency / usr/lib/node_modules/fstream requires inherits@'~2.0.0' but will load

Npm WARN unmet dependency undefined

Npm WARN unmet dependency which is version undefined

Npm WARN unmet dependency / usr/lib/node_modules/fstream-ignore requires inherits@'2' but will load

Npm WARN unmet dependency undefined

Npm WARN unmet dependency which is version undefined

Npm WARN unmet dependency / usr/lib/node_modules/fstream-npm requires inherits@'2' but will load

Npm WARN unmet dependency undefined

Npm WARN unmet dependency which is version undefined

Npm WARN unmet dependency / usr/lib/node_modules/glob requires inherits@'2' but will load

Npm WARN unmet dependency undefined

Npm WARN unmet dependency which is version undefined

Npm WARN unmet dependency / usr/lib/node_modules/npmconf requires inherits@'~2.0.0' but will load

Npm WARN unmet dependency undefined

Npm WARN unmet dependency which is version undefined

Npm WARN unmet dependency / usr/lib/node_modules/tar requires inherits@'2' but will load

Npm WARN unmet dependency undefined

Npm WARN unmet dependency which is version undefined

Masks 1.4.1 / usr/lib/node_modules/m

The installation is successful, check the help:

[root@test /] # 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 [config...] Install and/or use MongoDB

M custom [config...] Install custom MongoDB with [args...]

M use [args...] Execute mongod with [args...]

M shard [args...] Execute mongos with [args...]

M shell [args...] Open a mongo shell with [args...]

M bin Output bin path for

M rm 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 Output the url for source used for the given

(useful if installed from source)

M pre [script] Declare one or list scripts to execute before

(scripts must use absolute paths)

M post [script] Declare one or list scripts to execute after

(scripts must use absolute paths)

M pre rm [script] Remove pre script

M post rm [script] Remove post script

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:

Which bin

Use as, mongod

Shard sd, mongos

List ls

Installed lls

Custom c

Shell s, sh, mongo

Execute the m command:

[root@test /] # m

No installed versions

Prompt that no version is installed:

Install version 3.4:

[root@test /] # m 3.4

Checking for latest release of MongoDB 3.4

MongoDB version 3.4.16 is not installed.

Installation may take a while. Would you like to proceed? [Y/n] y

... Installing binary

# 100.0%

/ root/20180713/sharding

... Removing source

Activating 3.4.16

... Installation complete

Get the directory where 3.4.16 is installed:

[root@test ~ /] # m bin 3.4.16

/ usr/local/m/versions/3.4.16/bin

Enter the directory:

[root@test /] # cd / usr/local/m/versions/3.4.16/bin

[root@test / usr/local/m/versions/3.4.16/bin] # ll

Total 231684

-rwxr-xr-x 1 root root 4630751 Jul 10 14:08 bsondump

-rwxr-xr-x 1 root root 29471624 Jul 10 14:19 mongo

-rwxr-xr-x 1 root root 54088464 Jul 10 14:19 mongod

-rwxr-xr-x 1 root root 8344535 Jul 10 14:08 mongodump

-rwxr-xr-x 1 root root 6340189 Jul 10 14:08 mongoexport

-rwxr-xr-x 1 root root 6204308 Jul 10 14:08 mongofiles

-rwxr-xr-x 1 root root 6485366 Jul 10 14:08 mongoimport

-rwxr-xr-x 1 root root 5984601 Jul 10 14:08 mongooplog

-rwxr-xr-x 1 root root 53464744 Jul 10 14:19 mongoperf

-rwxr-xr-x 1 root root 9177984 Jul 10 14:09 mongoreplay

-rwxr-xr-x 1 root root 9506704 Jul 10 14:08 mongorestore

-rwxr-xr-x 1 root root 30763024 Jul 10 14:19 mongos

-rwxr-xr-x 1 root root 6560233 Jul 10 14:08 mongostat

-rwxr-xr-x 1 root root 6193511 Jul 10 14:08 mongotop

Run mongodb:

[root@test / usr/local/m/versions/3.4.16/bin] #. / mongo

MongoDB shell version v3.4.16

Connecting to: mongodb://127.0.0.1:27017

MongoDB server version: 3.4.13

Server has startup warnings:

2018-06-05T16:45:25.725+0800 I STORAGE [initandlisten]

2018-06-05T16:45:25.725+0800 I STORAGE [initandlisten] * * WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine

2018-06-05T16:45:25.725+0800 I STORAGE [initandlisten] * * See http://dochub.mongodb.org/core/prodnotes-filesystem

2018-06-05T16:45:26.786+0800 I CONTROL [initandlisten]

2018-06-05T16:45:26.786+0800 I CONTROL [initandlisten] * * WARNING: Access control is not enabled for the database.

2018-06-05T16:45:26.786+0800 I CONTROL [initandlisten] * * Read and write access to data and configuration is unrestricted.

2018-06-05T16:45:26.786+0800 I CONTROL [initandlisten] * * WARNING: You are running this process as the root user, which is not recommended.

2018-06-05T16:45:26.786+0800 I CONTROL [initandlisten]

2018-06-05T16:45:26.786+0800 I CONTROL [initandlisten]

2018-06-05T16:45:26.786+0800 I CONTROL [initandlisten] * * WARNING: / sys/kernel/mm/transparent_hugepage/enabled is' always'.

2018-06-05T16:45:26.787+0800 I CONTROL [initandlisten] * * We suggest setting it to 'never'

2018-06-05T16:45:26.787+0800 I CONTROL [initandlisten]

2018-06-05T16:45:26.787+0800 I CONTROL [initandlisten] * * WARNING: / sys/kernel/mm/transparent_hugepage/defrag is' always'.

2018-06-05T16:45:26.787+0800 I CONTROL [initandlisten] * * We suggest setting it to 'never'

2018-06-05T16:45:26.787+0800 I CONTROL [initandlisten]

> show dbs

Chenfeng 0.003GB

Local 0.000GB

Test 0.003GB

After reading this article, I believe you have a certain understanding of "how to use m tools to install and manage MongoDB". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report