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

Install MongoDB 4.0in Centos 7 [3.2.1]

2025-03-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

= introduction to MongoDB =

MongODB is a cross-platform, document-oriented database. Can achieve high performance, high availability, and

Can be easily expanded. Is an open source database system based on distributed file storage, under high load

Add more nodes to ensure server performance.

MongoDB is also a product between relational database and non-relational database, which is a non-relational database.

Among them, it is the most functional and most like a relational database. The main reason for not adopting the relational model is to achieve better scalability.

MongoDB no longer has the concept of "row", and its operation is mainly based on two concepts: collection

And documentation (document).

= characteristics of MongoDB =

The characteristics of MongODB include set-oriented storage, free mode, rich query statements and multi-level index, replication set mechanism, easy horizontal expansion, pluggable storage engine, cross-platform and multi-language support and so on.

MongoDB is easy to install, provides document-oriented storage function, and is easy to operate.

MongoDB provides replication, high availability, and automatic sharding. If the load increases (more storage space and more processing power are needed), it can be distributed among other nodes in the computer network, which is called sharding.

Mongo supports a rich set of query expressions. Query instructions use tags in the form of JSON to easily query objects and arrays embedded in a document.

MongoDB supports a variety of programming languages: Ruby, Python, Java, C++, PHP, C # and other languages.

= installation of MongoDB 4.0 =

Source package of MongoDB:

Two versions of MongoDB are available here.

Baidu network disk link: https://pan.baidu.com/s/1k3k539fEhZFXqXEAsUdHqg password: ljxr

1. First mount the source code package

[root@localhost MongoDB] # ls

Mongodb-linux-x86_64- 3.2.1.tgz mongodb-linux-x86_64-rhel70-4.0.0.tgz

# this article explains the process of manually compiling and installing Mongo4.0 version under centos 7

two。 Create a new file MongoDB and extract it to the specified file / opt

Cd / opt/

Mkdir mongodb

Tar zxvf mongodb-linux-x86_64-rhel70-4.0.0.tgz-C / opt/mongodb

3. Create files and move files to / usr/local/mongodb for easy management

Cd / usr/local/

Mkdir mongodb

Mv / opt/mongodb/mongodb-linux-x86_64-rhel70-4.0.0 / / usr/local/mongodb

4. Create a data file directory create a log file directory

[root@localhost local] # cd mongodb/mongodb-linux-x86_64-rhel70-4.0.0 /

[root@localhost mongodb-linux-x86_64-rhel70-4.0.0] # mkdir data logs

5. Create the data file directory mongodb1 under the data directory, and create the log file mongodb1.log under the logs directory, and upgrade the permissions to 777

[root@localhost mongodb-linux-x86_64-rhel70-4.0.0] # mkdir-p data/mongodb1

[root@localhost mongodb-linux-x86_64-rhel70-4.0.0] # cd logs/

[root@localhost logs] # mkdir mongodb

[root@localhost logs] # cd mongodb/

[root@localhost mongodb] # touch mongodb1.log

[root@localhost mongodb] # chmod-R 777 mongodb1.log

6. Generate and set up the configuration file for MongoDB

Vim / usr/local/mongodb/mongodb-linux-x86_64-rhel70-4.0.0/bin/mongodb1.conf

# the configuration is as follows:

Dbpath=/usr/local/mongodb/mongodb-linux-x86_64-rhel70-4.0.0/data/mongodb1

Logpath=/usr/local/mongodb/mongodb-linux-x86_64-rhel70-4.0.0/logs/mongodb/mongodb1.log

Port=27017

Logappend=true

Fork=true

MaxConns=5000

StorageEngine=mmapv1

Detailed explanation:

Dbpath= # data store directory path

Logpath= # Log File path

Port=27017 # default server port

Logappend=true # writes logs by appending

Fork=true # running in the background

MaxConns=5000 # maximum number of simultaneous connections. Default is 2000

StorageEngine=mmapv1 # specifies the storage engine as a memory-mapped file

7. Set kernel parameters

Sysctl-w vm.zone_reclaim_mode=0 # permanent setting

8. Set environment variables for ease of use:

Echo 'export MONGODB_HOME=/usr/local/mongodb/mongodb-linux-x86_64-rhel70-4.0.0' > > / etc/profile

Echo 'export PATH=$PATH:$MONGODB_HOME/bin' > > / etc/profile

Source / etc/profile

9. Start mongodb

/ usr/local/mongodb/mongodb-linux-x86_64-rhel70-4.0.0/bin/mongod-f / usr/local/mongodb/mongodb-linux-x86_64-rhel70-4.0.0/bin/mongodb1.conf

# check the port of mongodb service

Netstat-natp | grep mongod

10. Enter the mongo command to log in to MongoDB

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: 240

*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