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

Press linux and press mongodb

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The previous article introduced the installation of mongoDB under windows. This article will focus on how to install and run mongoDB under Linux (centOS). To change the topic here, because the size of mongoDB database exceeds 2G on 32-bit machines, it will make errors (2G does not refer to the capacity of a single database, but the sum of all the capacity of the entire mongoDB), so choose CentOS 64bit as its running carrier.

1. Download mongoDB

Go to the mongoDB download page (http://www.mongodb.org/downloads) to get the latest version of Linux 64-bit mongoDB download URL, and then download:

View plain copy# wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.4.tgz

2. Decompress and rename

View plain copy# tar-zxvf mongodb-linux-x86_64-2.0.4.tgz # mv mongodb-linux-x86_64-2.0.4 mongodb-2.0.4

3. Create data storage directory and log files

View plain copy# mkdir-p mongodb-2.0.4/data # touch mongodb-2.0.4/logs

4. Start the service

View plain copymongodb-2.0.4/bin/mongod-dbpath=/mongoDB/mongodb-2.0.4/data-logpath=/mongoDB/mongodb-2.0.4/logs

5. Add mongoDB service to random startup

Edit the / etc/rc.local file and add a line

View plain copy/mongoDB/mongodb-2.0.4/bin/mongod-dbpath=/mongoDB/mongodb-2.0.4/data-logpath=/mongoDB/mongodb-2.0.4/logs-logappend

6. Connect mongoDB

The connection command is: mongo database name

View plain copy# mongodb-2.0.4/bin/mongo test MongoDB shell version: 2.0.4 connecting to: test > show dbs local (empty) >

At this point, the installation of mongoDB under Linux has been completed, and the local connection to mongoDB has been successful, so we have to consider another problem: how does the local area network connect to mongoDB? How can a windows machine in a local area network connect to the mongoDB in a Linux machine?

In fact, the practice is also very simple, the syntax is:

View plain copybin/mongo IP address / database name

Finally, take a look at the settings of the firewall:

Database connection port of mongoDB (default): 27017

MongoDB Web Management connection Port (default): 28017

So we need to open access to the above two ports on the firewall.

View plain copy# iptables-I INPUT-p tcp-- dport 27017-j ACCEPT # iptables-I INPUT-p tcp-- dport 28017-j ACCEPT

Save and restart the firewall service

View plain copy# service iptables save # service iptables restart

OK, now you can let your application access and use mongoDB.

Zz from http://www.sunchis.com/html/db/mongodb/2012/0415/397.html

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