Ubuntu virtual machine MongoDB boot and port mapping

Source: Internet
Author: User
Tags iptables

Environment:

Ubuntu 14.04.1

MongoDB v3.4.1

Virtual Machine Connection mode is a NAT connection

First, MongoDB startup problem

After updating the kernel, when running MongoDB, the Data directory/data/db not found. Error, the time is long not remember installed configuration Orz

Looked up some information, this is because MongoDB default dbpath is/data/db, this directory can only be created with the root user, after the creation of the permissions are also more trouble, so the use of

sudo mongod--dbpath/var/lib/mongodb/data/db, start with parameters, set DBPath to other directories

If startup failure could be a. lock file under/var/lib/mongodb/or/var/lib/mongodb/data/db/, delete it with the root user

Startup success can be seen in the process

Second, port mapping

When MongoDB starts successfully, it runs the node project with Port 3003

Port mapping using the iptables command

sudo iptables-t nat-a prerouting-p tcp--dport 80-j REDIRECT--to-port 3003

-T: Select the table to manipulate

-A: Add rule name, prerouting for destination address translation

-P: Specifies the type of packet to match

--dport: Requested port

-j: Action, redirect indicates redirection, mapping, transparent proxy

--to-port: The port to go to

Add success after using sudo iptables-t nat-l view

My local host is Win7, add a parse in the Hosts file (directly with IP can also access

Browser input www.ubuntu.ameng.com can be accessed

Ubuntu virtual machine MongoDB boot and port mapping

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.