In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Brief introduction of MongoDB installation and Multi-instance Startup 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, in the case of high load, adding more nodes can ensure the performance of the server.
In the era of big data, the processing of a large amount of data has become one of the most important reasons for considering a database. One of the main goals of MongoDB is to maintain excellent database performance as much as possible, which largely determines the design of MongoDB. MongoDB chooses to maximize the use of memory resources as a cache in exchange for excellent performance, and automatically selects the fastest index for query. MongoDB simplifies the database as much as possible, leaving as much operation to the client as possible, which is one of the reasons why MongoDB can maintain excellent performance.
MongoDB is the most feature-rich and most like relational database in non-relational databases (NoSQL). Instead of adopting the relational model for better extensibility, MongoDB no longer has the concept of "row" and its operation is mainly based on two concepts: collection and document.
Characteristics of MongoDB
Mongo is a high-performance, open source, schemalless document database that can be used to replace traditional relational databases or key / value storage in many scenarios.
1. Collection-oriented storage: suitable for storing objects and data in JSON form.
2. MongoDB is easy to install, provides document-oriented storage function, and is easy to operate.
3. MongoDB provides replication, high availability and automatic sharding functions. 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.
4. MongoDB supports rich query expressions.
5. Efficient traditional storage: support binary data and large objects (such as photos or pictures).
Application area of MongoDB
1. 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 document format storage. It is suitable for Internet applications with large amount of data, high concurrency and weak 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.
MongoDB installation 1, download and install MongoDB and supporting software.
We chose to download the package directly, and since the virtual machine I used was CentOS7 and 64-bit version, we chose the corresponding RedHat7 version 64-bit. After downloading, you can use it directly after configuration. Since the package has enabled SSL security encryption, we need to install openssl-related dependent packages.
[root@promote ~] # wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.0.0.tgz # you can download [root@promote ~] # yum install openssl openssl-devel-y # installation dependent package [root@promote ~] # tar xvfz mongodb-linux-x86_64-rhel70-4.0.0.tgz-C / usr/local/# to extract the package to the specified directory [root@promote ~] # mv / usr/local/mongodb-linux-x86_64-rhel70-4.0.0 / / usr/local/mongodb# renaming package Convenient for later use 2. Create data storage directory, log storage directory and log files
Since we downloaded the compiled software package, we need to create our own data storage directory, log storage log and log files.
[root@promote ~] # mkdir-p / data/mongodb1# create data storage directory [root@promote ~] # mkdir-p / data/logs/mongodb# create log storage directory [root@promote ~] # touch / data/logs/mongodb/mongodb1.log# create log file [root@promote ~] # chmod-R 777 / data/logs/mongodb/mongodb1.log# modify log file permissions to facilitate the following operations
When MongoDB is frequently accessed, if the resource used by shell to start the process is set too low, an error will occur that the MongoDB cannot be connected at that time.
[root@promote ~] # ulimit-n 2500 # modify the maximum number of processes that can be enabled by shell [root@promote ~] # ulimit-u 2500 # modify the maximum number of files that shell can open 3, create MongoDB configuration files and configure startup parameters
The downloaded package does not have a configuration file, so we need to create it ourselves.
[root@promote ~] # cd / usr/local/mongodb/bin/ [root@promote bin] # vim mongodb1.confport=27017 # default server port number dbpath=/data/mongodb1 # data storage directory It is the logpath=/data/logs/mongodb/mongodb1.log # log file logappend=true # created in the previous step that uses append logging fork=true # background running maxConns=5000 # maximum number of connections 4, starting and stopping MongoDB
MongoDB services that can be started after installation and configuration
[root@promote bin] # export PATH=$PATH:/usr/local/mongodb/bin/# can add the path of MongoDB to the environment variable, so you can directly use the MongoDB command [root@promote bin] # mongod-f / usr/local/mongodb/bin/mongodb1.conf # mongod to start the service process. -f followed by the configuration file path of the service [root@promote bin] # netstat-ntap | grep mongod # can view the process startup status of MongoDB tcp 0 0127.0.0.1 ntap 27017 0.0.0.0 * LISTEN 78984/mongo [root@promote bin] # mongo # you can enter [root@promote bin] # mongod-f / usr/local/ in the database Mongodb/bin/mongodb1.conf-- shutdown#--shutdown means to shut down the MongoDB service process 2018-07-16T21:22:05.828+0800 I CONTROL [main] Automatically disabling TLS 1.0 To force-enable TLS 1.0specify-- sslDisabledProtocols' none'killing process with pid: 78984 [root@promote bin] # netstat-ntap | grep mongod # starts multiple instances of MongoDB without a MongoDB process
In cases where a single server has sufficient resources, multiple instances can be used to make full use of the server resources. The steps are the same as above, and then create a set of data storage directories, log files, and configuration files.
[root@promote bin] # mkdir-p / data/mongodb2# create a new data storage directory [root@promote bin] # touch / data/logs/mongodb/mongodb2.log # create a new log file [root@promote bin] # chmod-R 777 / data/logs/mongodb/mongodb2.log # give corresponding permissions to log files [root@promote bin] # chmod-R 777 / data/logs/mongodb/mongodb2.log [root@promote bin] # cp / usr/local/mongodb/ Bin/mongodb1.conf / usr/local/mongodb/bin/mongodb2.conf # copy a new configuration file Then modify the corresponding parameter port=27018 # set a new port number dbpath=/data/mongodb2 # set a new data storage directory logpath=/data/logs/mongodb/mongodb2.log # set a new log file logappend=truefork=truemaxConns=5000 [root@promote bin] # mongod-f / usr/local/mongodb/bin/mongodb2.conf # start a new instance [root@promote Bin] # mongod-f / usr/local/mongodb/bin/mongodb1.conf 2018-07-16T21:31:16.103+0800 I CONTROL [main] Automatically disabling TLS 1.0 To force-enable TLS 1.0 specify-sslDisabledProtocols' none'about to fork child process, waiting until server is ready for connections.forked process: 79334child process started successfully Parent exiting [root@promote bin] # netstat-ntap | grep mongotcp 0 0127.0.0.1 netstat 27017 0.0.0.0 netstat * LISTEN 79334/mongod tcp 0 0127.0.0.1 netstat 27018 0.0.0.0 grep mongotcp # you can see that two instances are enabled
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.