Linux Platform Installation MongoDB 4.0 (latest version)

Source: Internet
Author: User
Tags install openssl mongodb


MongoDB is written by the C + + language and is an open source database system based on distributed file storage.
In the case of high load, adding more nodes can guarantee the performance of the server.
MongoDB is designed to provide scalable, high-performance data storage solutions for Web applications.
MongoDB stores data as a document and data structures consist of key-value (key=>value) pairs. A MongoDB document is similar to a JSON object. Field values can contain other documents, arrays, and array of documents.

Key Features
  • MongoDB is a document-oriented database that is simple and easy to operate.
  • You can set the index of any property in the MongoDB record (for example: Firstname= "Sameer", address= "8 Gandhi Road") for faster sorting.
  • You can create data mirroring either locally or on the network, which makes MongoDB more extensible.
  • If the load increases (requiring more storage space and greater processing power), it can be distributed across other nodes in the computer network which is called a shard.
  • The MONGO supports rich query expressions. Query directives use a JSON-style tag to easily query objects and arrays embedded in the document.
  • MongoDb uses the update () command to implement a replacement of the completed document (data) or some specified data fields.
  • The map/reduce in MongoDB is primarily used for batch processing and aggregation of data.
  • Map and reduce. The map function calls emit (Key,value) to traverse all records in the collection, passing key and value to the reduce function for processing.
  • The map function and the reduce function are written in JavaScript and can be executed with the Db.runcommand or MapReduce command.
  • Gridfs is a built-in feature in MongoDB that can be used to store a large number of small files.
  • MongoDB allows you to execute scripts on the server, write a function in JavaScript, execute directly on the server, or store the definition of the function on the server, next time you call it directly.
  • MongoDB supports a variety of programming languages: ruby,python,java,c++,php,c# and many more languages.
  • MongoDB installation is simple.
Applicable fields

MongoDB can provide scalable, high-performance data storage solutions for Web applications. MongoDB's main areas of application are Web site data, distributed scenarios, data caches, and JSON file format storage. With large data volumes, high concurrency, and transactional Internet applications, its built-in horizontal scaling mechanism provides data processing capabilities from millions of to 1 billion levels, which can be well suited to Web2.0 and mobile Internet application storage requirements.

System environment
    • Operating system: CentOs 7.3
    • Package: mongodb-linux-x86_64-rhel70-4.0.0.tgz Password: HC17
    • Shutting down firewalls and SELinux
Deploying the installation 1. Install the support package
yum -y install openssl-devel libcurl
2. Unzip the MONGDB package
tar zxvf mongodb-linux-x86_64-rhel70-4.0.0.tgz -C /opt
3. Rename and move the directory to the/usr/local/directory
mv /opt/mongodb-linux-x86_64-rhel70-4.0.0 /usr/local/mongodb
4. Create a MongoDB data store directory, log storage directory, and log files
mkdir -p /data/mongodb1mkdir -p /data/logs/mongodbtouch /data/logs/mongodb/mongodb1.logchmod -R 777 /data/logs/mongodb/mongodb1.log
5. Adjust the shell resource settings to prevent frequent access to MongoDB resulting in an error that cannot connect to the MONGDB instance
ulimit -n 25000    #同一时刻最多开启文件数ulimit -u 25000     #同一时刻最多开启程序数
6. Create a configuration file (startup parameters)
vim /usr/local/mongodb/bin/mongodb1.conf


7. Set kernel parameters (the system allocates memory from other nodes when there is not enough memory available for a node)

echo 0 >/proc/sys/vm/zone_reclaim_mode
Sysctl-w vm.zone_reclaim_mode=0
echo Never >/sys/kernel/mm/transparent_hugepage/enabled
echo Never >/sys/kernel/mm/transparent_hugepage/defrag

The 8.MongoDB executable file is located in the bin directory, so you can add it to your path path:
vim /etc/profile

Export Path=/usr/local/mongodb/bin: $PATH \

9. Reload Environment variables
source /etc/profile
10. Setting up MongoDB boot from boot
vim /etc/rc.local

/usr/local/mongodb/bin/mongod-f/usr/local/mongodb/bin/mongodb1.conf #启动

11. Start MongoDB


12. Check MongoDB process
netstat -tunlp | grep mongod

Stop Momngodb
mongod -f /usr/local/mongodb/bin/mongodb1.conf --shutdown

13. Connect and access the MongoDB database

Linux Platform Installation MongoDB 4.0 (latest version)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.