Recently, I was sorting out all kinds of things on my private server, so I just recorded in detail the steps of reinstalling after cleaning up. Today, I will first write some database content, about installing and configuring MongoDB in Linux

To be honest, why do I install MongoDB? Because the company needs to do some Nodejs middleware before, I casually play MongoDB CRUD, document database is quite interesting

Installation environment

CentOS7 + MongoDB4.4

Downloading the Installation package

Mongodb – version 4.4.4 download

steps

  1. Upload using xFtpmongodb.gzPackage to the installation directory, mine is/usr/soft/sort
  2. Decompress the installation package to the specified directory. Mine is the install folder in the same directory

    Tar -zxvf /usr/sof/sort /mongodb-linux-x86_64-rhel70-4.4.4. TGZ -c /usr/sof/install /

  3. Configuring environment Variables

    vim /etc/profile

  4. Add the following to the last line of the file

    As I started to modify (note s will delete the currently selected characters) export PATH = $PATH: / usr/soft/install/mongo – Linux – x86_64 rhel70-4.4.4 / bin press esc to stop editing, according to: $PATH = ‘$PATH’; $PATH = ‘$PATH’; $PATH = ‘$PATH

  5. The inputsource /etc/profile, effective immediately if no error is reported
  6. Create a data store folder and a logging folder for later configuration files

    Create /data/db in the home directory to store data. Create logs in the home directory to store logs

  7. Create a configuration file to use at run time

    Go to the bin directory in your home directory. CD /bin Create the configuration file vim mongodb. The results when I start has been submitted to the configuration errors) dbpath = / usr/soft/install/mongo – Linux – x86_64 rhel70-4.4.4 / data/db logpath = # data file storage directory / usr/soft/install/mongo – Linux – x86_64 rhel70-4.4.4 # / logs log file directory contains the port = = true # 27017 # port fork in the form of a daemon is enabled, Bind_ip = 0.0.0.0 # to allow remote access, or to allow direct access to MongoDB. 127.0.0.1 Yes Allows only local access notice You can directly connect to the database if you do not create an account, but you cannot directly connect to the database after you create an account. You must use the account password to connect to the database. For example, the following mongo: / / root: * * * * * * @ XXX. XXX. XXX. XXX: 27017 / test? AuthSource =admin&readPreference=primary&ssl=false Note: there must be a space between the comment # and data

  8. Tests run and close the database

    Go to the bin directory in your home directory CD /bin start./mongod -f mongodb.conf disable pkill mongod. Now I only this one command successful) check to see if the port has been occupied netstat NLTP | grep or top 27017

  9. Related error messages

    Fault Information such as child process failed,existed with error number 1 This error is reported because the relative address is not the full address. Mongodb enable authentication is not successfully run. If the permission is enabled or the account password is created, you need to use the username and password to log in

Resources 1 ———— Linux Installing and Running MongoDB 2 ———— Procedure for configuring the MongoDB environment on a Linux server 3 ———— ERROR: child process failed, exited with error number 1

I’m FX67ll.com. If you find anything wrong with this article, please comment on it in the comments section. Thank you for reading! If you like this article, welcome to visit my github warehouse address, for me to click a Star, Thanks~ 🙂 forward please note the reference article address, very thank you!!