MongoDB is a scalable, high-performance, open-source, free-mode, and document-oriented database. It is not a commonly used RDBMS and is a popular one recently. quot; NoSqlqu
MongoDB is a scalable, high-performance, open-source, free-mode, and document-oriented database. It is not a commonly used RDBMS and is a popular one recently. quot; NoSqlqu
MongoDB is a scalable, high-performance, open-source, free-mode, document-oriented database.
It is not a commonly used RDBMS and belongs to the database category of the popular NoSql database.
It is not the same as a general key-value-based db because it has powerful functions.
It has implemented many functions similar to SQL, such as index, limit, skip, group ....
When the application data volume reaches the sea level, the traditional Mysql and Oracle cannot meet our performance requirements.
If you still need to query data, consider using MongoDB.
Installation is simple:
Wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-1.2.4.tgz"
Tar zxvf mongodb-linux-x86_64-1.2.4.tz
Ln-s/opt/mongodb-linux-x86_64-1.2.4 // usr/local/mongodb
Mkdir/opt/mongodb_data
MongoDB has 2 versions, the official recommendation of the use of mongodb-linux-x86_64-1.2.4.tgz, only in linux is the old system, mongodb can not be started, the use of "legacy static" version
MongoDB provides a simple Auth function. To enable authentication, you must first add users
/Usr/local/mongodb/bin/mongo admin
Db. addUser ('admin', 'manager ')
Db. auth ('admin', 'manager ')
Show dbs
Use address
Db. addUser ('mongodb ', 'test ')
Here, admin is a special database. Only after db. auth is passed on admin can you add permissions to other databases.
As shown above, we added a mongodb user to the address database.
In addition, if we want to enable the Master/Slave Mode and enable the Auth function, we need to add a repl user to the local database on the Master and Slave at the same time.
Use local
Db. addUser ('repl', 'replicase ')
Otherwise, when we start slave, an error is reported:
Replauthenticate: no user in local. system. users to use for authentication
Replauthenticate: can't authenticate to master server, user: repl
Then, we can start the Master and Slave respectively using the following script. Note that the-oplogSize option specifies the maximum size of log storage updated when the master synchronizes data to the slave. The default value is 64-bit, 1G max. If it is too small and slave does not keep up with it in time, data may be inconsistent.
-OplogSize = 10000 M-Logappend-auth-master &
In python, you can use the pymongo module.
Db = connection. mail_addr
......
Db. address. save (user_addr, safe =True)
Use save to save a record. If we have used find () to investigate a record, you can use save to update the record after modification.
If you want to implement insert if a record does not exist and update if it exists, you can use
MongoDB has powerful functions. It can create indexes like Mysql, and supports multi-field indexes and unique indexes...