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

Detailed explanation of mongodb Construction

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

Share

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

Operating system environment:

Installation and use of mongodb

Official installation documentation:

Https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/

MongoDB provides officially supported packages in its own library, including:

Mongodb-org a package that automatically installs the four component packages listed below.

Mongodb-org-server contains the mongod daemon, associated init scripts, and configuration files (/ etc/mongod.conf)

Mongodb-org-mongos contains mongos daemon

Mongodb-org-shell contains mongo shell

Mongodb-org-tools includes the following MongoDB tools: mongoimport bsondump, mongodump, mongoexport, mongofiles, mongorestore, mongostat and mongotop

1. Install mongodb from yum source

Configure the yum installation source

Cat / etc/yum.repos.d/mongodb-org-4.2.repo

[mongodb-org-4.2]

Name=MongoDB Repository

Baseurl= https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/

Gpgcheck=1

Enabled=1

Gpgkey= https://www.mongodb.org/static/pgp/server-4.2.asc

EOF

Install mongodb packages

To install the latest stable version of MongoDB, run the following command:

Yum install-y mongodb-org

To install a specific version of MongoDB, specify each package separately and append the version number to the package name, as follows:

Yum install-y mongodb-org-4.2.0 mongodb-org-server-4.2.0 mongodb-org-shell-4.2.0 mongodb-org-mongos-4.2.0 mongodb-org-tools-4.2.0

(note: each version of the .repo file can be found in the repository. Odd releases (such as 3.5) are development versions and are not suitable for production use. )

If the installation is successful, you will see the installed package, as follows:

two。 Install mongodb using the Tar package

MongoDB .tar.gz tarballs requires the following dependencies to be installed:

Yum install libcurl openssl

Download the MongoDB .tar.gz tarball link:

Https://www.mongodb.com/download-center/community?jmp=docs

Select the appropriate version, os, and the package type is shown below:

Extract the package to / usr/local

Tar xf mongodb-linux-x86_64-rhel70-4.2.0.tgz-C / usr/local/

Renamed to mongodb

Mv mongodb-linux-x86_64-rhel70-4.2.0 / usr/local/mongodb

The executable file for MongoDB is located in the bin directory and added to the PATH path:

Export PATH=/bin:$PATH

The installation path for your MongoDB. Mine is / usr/local/mongodb

[root@localhost local] # echo 'export PATH=/usr/local/mongodb/bin:$PATH' > > ~ / .bashrc

[root@localhost local] # source ~ / .bashrc

Create a data directory for mongodb:

MongoDB's data is stored in the db directory of the data directory, but this directory is not automatically created during installation, so you need to manually create the data directory and create the db directory in the data directory. (otherwise an error will be reported at startup)

Note: / data/db is the default startup database path for MongoDB. If you want to modify it, you need to specify the option-dbpath at startup. To see more options, execute mongod-help.

[root@localhost local] # mkdir-p / data/db

Run the mongodb service in the background and specify the log path:

[root@localhost~] # mongod-- fork-- logpath / data/mongodb/logs/mongodb.log

MongoDB backend management Shell:

MongoDB Shell is an interactive Javascript shell that comes with MongoDB, which is used to operate and manage MongoDB.

[root@localhost ~] # mongo

It was built successfully. (use kill-2 to close when closing, otherwise it will cause database corruption or lock release failure)

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