Ubuntu Knowledge Supplement:
Chown-r: The same permission changes are made to all files and subdirectories in the current directory (that is, to be changed one at a time in a recursive manner)
Nohup command: If you are running a process and you feel that the process will not end when you exit the account, you can use the Nohup command. This command can continue to run the process after you exit the account/close the terminal. Nohup means not to hang (no hang up).
The MongoDB server can run on Linux, Windows, or OS X platforms, supporting 32-bit and 64-bit applications with a default port of 27017. It is recommended to run on a 64-bit platform because the maximum file size supported by MongoDB in 32-bit mode is 2GB.
MongoDB stores the data in a file (the default path is:/data/db) and manages it with a memory-mapped file for increased efficiency.
Step1: Download Binary Package
Step2: Decompression
Tar zxvf mongodb-linux-x86_64-2.2.0.tgz
Copy the unpacked folder to the USR directory
sudo mv mongodb-linux-x86_64-2.2.0 MongoDB
Step3: Create a directory of data and logs that the MongoDB requires:
Enter the following command in the current directory to create the user:
Add a MongoDB User:
sudo adduser mongodb
set Password:
sudo passwd mongodb
sudo mkdir-p/data/db
To convert the owner of "/data/db/" into a MongoDB user
$ sudo chown mongodb/data/db/
$ sudo chown-r mongodb:mongodb/data
Of course, you can specify MONGODB to store the data in a different directory through the –dbpath command.
MongoDB The default data directory is/data/db/. If modified to a different path, start at the –dbpath point. You can also indicate in the main configuration file
You need to install the MONGO shell before you run the following statement or you will receive a prompt: The program "MONGO" has not been installed.
$ apt-get Install mongodb-clients
P4: Start the MongoDB service
$./mongodb/bin/mongod
I can't start here, Error:couldn ' t connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
After a variety of access to data, most of the solution is to delete the lock file under the/data/db/, but the blogger did not find this file, I ask you to delete the yarn, the moment of the circle, after several twists and turns, found that the wrong message is not the right to create lock files, instant without words.
sudo./mongodb/bin/mongod
Easy, CTRL + C terminate the service
Another terminal, input,./mongodb/bin/mongo
Log in to the MongoDB shell
recommend two more detailed blog
http://blog.csdn.net/csfreebird/article/details/6737127
Http://blog.sina.com.cn/s/blog_788e5b7a01018bs5.html
Http://www.cnblogs.com/xiaogangqq123/archive/2011/04/26/2029426.html
Http://www.cnblogs.com/xiaogangqq123/archive/2011/04/26/2029426.html
Exit: >exit
Install the PIP and use this to install the Pymongo–python MongoDB driver
Step1:
Http://pypi.python.org/packages/source/p/pip/pip-1.0.2.tar.gz#md5=47ec6ff3f6d962696fe08d4c8264ad49
Step2: Decompression Installation
TAR-XVF pip-1.0.2.tar.gz
CD pip-1.0.2
Python setup.py Install
Step3: Install the python for MONGO driver
sudo pip install Pymongo
You can update Pymongo directly from the PIP later.
Pip–upgrade Pymongo
Direct Installation
The simple use of sudo apt-get install Python-pymongo in python
First Open MONGO service
#-*-coding:utf-8-*-Import Pymongo Import JSON #connect to database connection runs on the local machine on the default port (27017) on the MONGODB server conn = Pymongo. Connection ("localhost", 27017) #通过对象属性或像字典一样使用对象来获得代表一个特定数据库的对象. If the database does not exist, it is automatically created db = Conn[' example '] #db = conn.example # When the first document is inserted, MongoDB automatically creates the collection widgets = db[' Widgets '] #widgets = Db.wi The Dgets # Insert method specifies a Python dictionary to insert the document Widgets.insert ({"Name": "Flibnip", "description": "Grade-a Industrial Flibnip", "Quan Tity ': 3}] # Call the Collection_names method on the database object to get the list of collections in the database print "The list of collections:\n", Db.collection_names () # Take out the document, Doc ' S type is Dict doc=widgets.find_one ({"Name": "Flibnip"}) Print doc print doc[' name '] # The JSON module does not know how to convert the MongoDB objectid type to JSON, processing: Remove the _id key del doc["_id"] Jdoc=json.dumps (DOC) print "JSON format:\" before serialization N ", Jdoc Widgets.insert ({" Name ":" Smorkeg "," description ":" For external with only "," Quantity ": 4}) Widgets.insert ({" Name ":" Clobbasker "," description ":" Properties available on request "," Quantity ": 2}) # Call the Find method of the collection to get the list of all documents in the collection print ' lists Of all doCuments: "For Doc in Widgets.find (): Print Doc # get a subset of the document print" The list of the documents whose quantity is 4: "For Doc in Widgets.find ({"Quantity": 4}): Print Doc # Delete document Widgets.remove with value of all name keys Flipnip ({"Name": "Flibnip"})
More MongoDB use:
http://www.cnblogs.com/TankMa/archive/2011/06/08/2074947.html
Draw from:
http:// www.cnblogs.com/myblog-lyc/p/4331756.html