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 MongoDB single Node under linux system

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to install MongoDB single node under the linux system. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Installation package

Download address: (https://www.mongodb.com/download-center))

User permissions / Directory

1. Create a dbuser user

Groupadd dbgroup useradd dbuser-m-d / home/dbuser-g dbgroup

2. Deployment directory

Mkdir-p / opt/localchown-R dbuser:dbgroup / opt/localcd / opt/local

3. Extract the installation package

Tar-xzvf mongodb-linux-x86_64-enterprise-suse11-3.2.7.tgzmv mongodb-linux-x86_64-enterprise-suse11-3.2.7 mongodbcd mongodbmkdir conf data log

Conf as configuration file directory data as data file directory log as log file directory

Configuration file

Vim conf/mongo.conf

Storage: dbPath: "/ opt/local/mongodb/data/" engine: wiredTiger# directoryPerDB: true journal: enabled: destination: file path: "/ opt/local/mongodb/log/mongodb.log" logAppend: true# timeStampFormat: iso8601-utcoperationProfiling: slowOpThresholdMs: 10000replication: oplogSizeMB: 700processManagement: fork: true pidFilePath: "/ opt/local/mongodb/mongod.pid" net: port: 27017 http: enabled: false unixDomainSocket: enabled: false

The startup port is 27017, which closes the http management interface. SlowOpThredsholdMs is the threshold for slow operation detection, which can be adjusted as needed.

Initialization

1. Start mongod, which can be accessed anonymously by default

. / bin/mongod-f conf/mongodb.conf

2. Connect mongo

. / bin/mongo-- port 27017

3. Initialize the administrator

Use admindb.createUser ({user:'admin',pwd:'admin@2016',roles: [{role:'clusterAdmin',db:'admin'}, {role:'userAdminAnyDatabase',db:'admin'}]}) use appdbdb.createUser ({user:'appuser',pwd:'appuser@2016',roles: [{role:'dbOwner',db:'appdb'}]})

4. The administrator user and the application account are created respectively, and then the

Restart mongo to enable authentication

Pkill mongod./bin/mongod-f conf/mongodb.conf-auth

After that, you need to provide identity authentication to connect to the mongo.

Common command

Start command

. / bin/mongod-f conf/mongodb.conf

Stop command

Kill-2 `cat Mongod.pid`rm mongod.pid

Detection port

Netstat-nlp | grep 27071

View the log

Tail-n200-f log/mongodb.log

Connection port

. / bin/mongo-- port 10001-u admin-p admin@2016-- authenticationDatabase=admin

Monitoring command

. / bin/mongostat-- port 27071-u admin-p admin@2016-- authenticationDatabase=admin-- discover-n 303 this is the end of the article on "how to install MongoDB single node under linux system". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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

Servers

Wechat

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

12
Report