Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install MongoDB manually by Ubuntu16.04

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces Ubuntu16.04 how to manually install MongoDB, the article is very detailed, has a certain reference value, interested friends must read it!

Download Ubuntu 16.04 Linux 64-bit x64 with your own Firefox browser

1. Address: http://www.mongodb.org/downloads

2. Select the linux tab, and then select Ubuntu 16.04 Linux 64-bit x64 in the drop-down box

3. Click the Download button (the download radio box that pops up in the browser, select Save, confirm), and wait for the download to finish (saved in the user's Downloads folder by default)

Copy the extracted files to / usr/local/mongodb (you need to create this directory manually)

1. First open the terminal (Ctrl+Alt+T) and enter sudo mkdir / usr/local/mongodb to create / usr/local/mongodb

2. Extract the tar package you just downloaded (right-click the tar package file: extract it here, and then you will see a folder with the same name, as shown in the figure)

3. Copy (or move) the "in folder" files extracted in the previous step to / usr/local/mongodb/ through the terminal command.

Add the bin directory of mongodb to PATH

I chose to modify the / etc/profile file so that all users can use it

1. Open the terminal and enter sudo gedit / etc/profile

2. At this point, an editing window for the file will pop up. At the bottom of the file, add export PATH=$PATH:/usr/local/mongodb/bin and save (Ctrl+S or save button in the upper right corner) to close the file

3. Go back to the terminal and enter the source / etc/profile command to make the changes take effect at present.

4. Edit mongod.conf

1. Create and edit mongod.conf

(1) sudo gedit / etc/mongod.conf

(2) enter the following, and then save exit:

# detailed record output verbose = true# specifies the service port number, default port 27017port = 270 specifies the MongoDB log file Note that the specified file is not a directory logpath = / var/log/mongodb/logs/mongodb.log# writes the log logappend = true# specifies the database path dbpath = / data/db/# setting each database will be saved in a separate directory directoryperdb = true# enable authentication auth = false# run MongoDB as a daemon, create server process fork = true# quiet output quiet = true

2. Create the database directory, log directory, and log file mentioned in the configuration file to save files:

(1) sudo mkdir-p / data/db/

(2) sudo mkdir-p / var/log/mongodb/logs/

(3) sudo touch / var/log/mongodb/logs/mongodb.log

Fifth, write a script, register and start up

1. Create a / etc/init.d/mongodb file and enter the contents of the script:

(1) sudo gedit / etc/init.d/mongodb

(2) write the following in the pop-up editing window and save it, exit

#! / bin/sh### BEGIN INIT INFO# Provides: mongodb# Required-Start:# Required-Stop:# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: mongodb# Description: mongodb server### END INIT INFO. / lib/lsb/init-functionsPROGRAM=/usr/local/mongodb/bin/mongodMONGOPID= `ps-ef | grep 'mongod' | grep-v grep | awk' {print $2} '`test-x $PROGRAM | | exit 0case "$1" in start) ulimit-n 3000 log_begin_msg "Starting MongoDB server" $PROGRAM-f / etc/mongod.conf log_end_msg 0;; stop) log_begin_msg "Stopping MongoDB server" if [!-z "$MONGOPID"]; then kill-15$ MONGOPID fi log_end_msg 0;; status) *) log_success_msg "Usage: / etc/init.d/mongodb {start | stop | status}" exit 1esacexit 0

2. Go back to the terminal and modify the file permissions to make the script executable

Sudo chmod + x / etc/init.d/mongodb

3. Register the boot script

Sudo update-rc.d mongodb defaults (remove with update-rc.d-f mongodb remove)

4. Open the service and test the connection:

Sudo service mongodb start (sudo service mongodb stop for stop service)

Sudo mongo

The above is all the contents of the article "how to install MongoDB manually by Ubuntu16.04". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report