Ali cloud Centos 7 install MongoDB 4.2.0

Background: Recently the company projects need to optimize the interface back to within 100ms. It is necessary to do processing on the interface logic, optimization data,

   Just to use Redis cache, mysql, mongoDB optimization, today installed mongoDB4.2 on the record about Ali cloud centos;

   Time will have time to look at the overall record of the background to optimize the interface ideas

 

1. The configuration of yum source MongoDB

 Yum create source files :

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

 Add the following :

 [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
 

 

2. Install MongoDB

yum -y install mongodb-org
 
 

3, verify whether the installation was successful mongodb

 mongo --version 
 

 

 4, the relevant files to view mongodb installation directory

  whereis mongo

  

  The default MongoDB data files are stored in / var / lib / mongo directory, the log files are stored in / var / log / mongodb directory, and run as mongod user.

  You can specify the data file directory and log file directories by modifying the /etc/mongod.conf file.

  For more information about log path and data storage path refer to  https://docs.mongodb.com/manual/reference/configuration-options/#systemLog.path 

                      And  https://docs.mongodb.com/manual/reference/configuration-options/#storage.dbPath  .

If you change the user runs MongoDB, you must modify the / var / lib / mongo and / var / log / mongodb permission, so that the corresponding user can access modify permissions to run.

 

5、Centos7中启动mongo

  systemctl start mongod.service

  After you start to view the log cat /var/log/mongodb/mongod.log 

 

 See the log as shown below was found, i.e. start successfully

 

6. Set the boot

systemctl enable mongod.service

7. Stop MongoDB

systemctl stop mongod.service

8. Restart MongoDB

systemctl restart mongod.service

9.mongodb remote connection configuration is as follows:

 1. Modify the configuration file mongodb.conf

  Command: vim /etc/mongod.conf

  The bindIp = 127.0.0.1 this line is commented out or modified bindIp = 0.0.0.0

 2. Restart mongodb Service

  命令:systemctl restart mongod.service

 3. Open a firewall port 27017

  命令:iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 27017 -j ACCEPT

 4. Remote Connection

  To connect the IP: 121.199.56.177

  Command: mongo 121.199.56.177:27017

  This may be connected to the 121.199.56.177 mongodb / test database

  The new version of Navicat has support mongoDB  

  

 

  perfect!!!

Reference: https: //www.cnblogs.com/jinxiao-pu/p/7121307.html

   https://zhuanlan.zhihu.com/p/34526844

        https://blog.csdn.net/zqx1205/article/details/75314266

 

Guess you like

Origin www.cnblogs.com/SnowBaby/p/11569541.html