CentOS 7 server configuration-install MongoDB, centosmongodb
# Download the MongoDB source file: wget unzip-zxvf mongodb-linux-x86_64-rhel70-3.4.7.tgz # rename the decompressed file mv mongodb-linux-x86_64-rhel70-3.4.7 mongodb # create the mongodb data file and log file directory mkdir-p/data/dbmkdir-p/data/logs note: the file directory created here is under the root directory # enter the mongodb bin directory cd mongodb/bin # create the mongodb configuration file vi. /mongodb. conf # Add the following information: dbpath =/data/db # data file storage directory logpath =/data/logs/mongodb. log # log file storage directory port = 27017 # port fork = true # enabled as a daemon, that is, run nohttpinterface = true # Save in the background and start Mongodb. /mongod -- config mongodb. conf: Set MongoDB startup # create a mongodb instance in the/lib/systemd/system folder. service file vi/lib/systemd/system/mongodb. service # Add the following content [Unit] Description = mongodb afterappsnetwork.tar get remote-fs.target nss-lookup.target [Service] Type = forking ExecStart =/home/mongodb/bin/mongod -- config/home/mongodb/bin/ mongodb. conf ExecReload =/bin/kill-s HUP $ MAINPID ExecStop =/home/mongodb/bin/mongod -- shutdown -- config/home/mongodb/bin/mongodb. conf PrivateTmp = true [Install] wantedby=multi user.tar get # Is mongodb. service permission chmod 754 mongodb. service # Set systemctl enable mongodb to start at startup. service # enable systemctl restart mongodb. service Note: After Mongodb is installed, if it has been started, an error may occur when starting the service here, because port 27017 is occupied. In this case, you only need to restart the server, and the mongodb service will automatically start.