A recent project required MongoDB to be installed as the easy-mock database, so this is recorded for future reference.

1, install,

Official website download address: www.mongodb.com/download-ce…

To download and install the dependent environment, run the following command:

$wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.0.tgz $yum install Cyrus sasl - Cyrus sasl -- gssapi cyrus-sasl-plain krb5-libs libcurl libpcap lm_sensors-libs net-snmp net-snmp-agent-libs openldap openssl rpm-libs tcp_wrappers-libsCopy the code

To configure environment variables, run the following command:

    $ vim /etc/profile
Copy the code

Added the following:

MongoDB_HOME export MongoDB_HOME=/opt/ mongodb-linux-x86_64-4.0.0 export PATH=$MongoDB_HOME/bin:$PATHCopy the code

To configure a data store directory, run the following command:

$ mkdir -p /data/db
Copy the code

2. Start the service

To start and configure the installed service, run the following command:

$ sudo systemctl start mongod
$ sudo systemctl enable mongod
Copy the code

To restart and stop, run the following command:

$ sudo systemctl restart mongod
$ sudo systemctl stop mongod
Copy the code

This section describes how to install MongoDB in Centos7.