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