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

Installation, configuration and startup of MongoDB

2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

An overview

MongoDB is written in C++ language and is an open source database system based on distributed file storage.

In the case of high load, adding more nodes can ensure server performance.

MongoDB aims to provide scalable, high-performance data storage solutions for WEB applications.

MongoDB stores the data as a document, and the data structure consists of key-value (key= > value) pairs. MongoDB documents are similar to JSON objects. Field values can contain other documents, arrays, and document arrays.

The main feature of MongoDB is a database for document storage, which is relatively simple and easy to operate. You can set the index of any property in the MongoDB record (such as FirstName= "Sameer", Address= "8 Gandhi Road") to achieve faster sorting. You can create data mirrors locally or on the network, which makes MongoDB more scalable. If the load increases (more storage space and stronger processing power are needed), it can be distributed among other nodes in the computer network. This is called fragmentation. 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 uses the update () command to replace the completed document (data) or some specified data fields. Map/reduce in Mongodb is mainly used for batch processing and aggregation of data. Map and Reduce. The Map function calls emit (key,value) to traverse all the records in the collection, passing key and value to the Reduce function for processing. The Map and Reduce functions are written in Javascript, and you can perform MapReduce operations through db.runCommand or mapreduce commands. GridFS is a built-in feature in MongoDB that can be used to store a large number of small files. MongoDB allows scripts to be executed on the server. You can write a function in Javascript and execute it directly on the server, or you can store the definition of the function on the server and call it directly next time. MongoDB supports a variety of programming languages, such as RUBY,PYTHON,JAVA,C++,PHP,C#. MongoDB is easy to install. Applicable field

MongoDB can provide scalable high-performance data storage solutions for Web applications. MongoDB is mainly applicable to website data, distributed scenarios, data caching and JSON file format storage. It is suitable for Internet applications with large amount of data, high concurrency and transactions. its built-in horizontal scaling mechanism provides data processing capacity from millions to billions, which can well meet the data storage requirements of Web2.0 and mobile Internet applications.

System environment operating system: CentOs 7.3.Software package: mongodb-linux-x86_64-rhel70-4.0.0.tgz password: hc17 off firewall and Selinux deployment installation 1. Install the support package yum-y install openssl-devel libcurl2. Extract the MongoDB software package tar zxvf mongodb-linux-x86_64-rhel70-4.0.0.tgz-C / opt3. Rename and move the directory to / usr/local/ directory mv / opt/mongodb-linux-x86_64-rhel70-4.0.0 / usr/local/mongodb4. Create the MongoDB data storage directory, log storage directory and log file mkdir-p / data/mongodb/mongodb1mkdir-p / data/conf/mkdir-p / data/logs/touch / data/logs/mongodb1.logchmod-R 777 / data/logs/mongodb1.log5. Adjust the settings of shell resources to prevent errors caused by frequent access to MongoDB that result in failure to connect to MongoDB instance ulimit-n 25000 # maximum number of files opened at a time ulimit-u 25000 # maximum number of programs opened at a time 6. Create a configuration file (startup parameter) vim / data/conf/mongodb1.conf#mongod.conf#for documentation of all options Log file path of see:# http://docs.mongodb.org/manual/reference/configuration-options/#where to write logging data.systemLog: destination: file logAppend: true path: / data/logs/mongodb1.log / / mongodb1 # Where and how to store data.storage: dbPath: / data/mongodb/mongodb1/ mongodb1 data file path journal: enabled: true#engine:#mmapv1:#wiredTiger:#how the process runsprocessManagement : fork: true # fork and run in background pidFilePath: / data/mongodb/mongodb1/mongod.pid # location of pidfile timeZoneInfo: / usr/share/zoneinfo#network interfacesnet: port: 27017 / / mongodb1 process number bindIp: 0.0.0.0 # Listen to local interface only Comment to listen on all interfaces.#security:#operationProfiling:replication: / / Delete "#" Enable replication set function replSetName: test-rc / / name is test-rc#sharding:##Enterprise-Only Options#auditLog:#snmp:7. Set kernel parameters (when one node runs out of available memory, the system allocates memory from other nodes)

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 executable file for 8.MongoDB is located in the bin directory, so you can add it to the PATH path: vim / etc/profile

# append the following statement to the end of the file

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

9. Reload the environment variable source / etc/profile10. Set MongoDB boot self-boot vim / etc/rc.local

Rm-rf / data/mongodb/mongodb1/mongod.lock

/ usr/local/mongodb/bin/mongod-f / data/conf/mongodb1.conf / / start the instance

11. Start the MongoDB database mongod-f / data/conf/mongodb1.conf

twelve。 Check the MongoDB process netstat-tunlp | grep mongod

13. Stop MongoDB database mongod-f / data/conf/mongodb1.conf-- shutdown

14. Local client connects and accesses MongoDB database (default port: 27017) mongo

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