0. Install MongoDB:
1) Curl-o http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.4.tgz
2) TAR-ZXVF mongodb-linux-x86_64-2.6.4.tgz
3) Mkdir-p MongoDB
Cp-r Mongodb-linux-x86_64-2.6.4/mongodb
4) Export Path=<mongodb-install-directory>/bin: $PATH
Mongod--dbpath=/home/app/mongodb/mongodbdata/--Logpath=/home/app/mongodb/log/mongodb.log--logappend&
2.mongo
3.use Admin
4.db.adduser (' Mongouser ', ' 123456! ');
5.kill
6.mongod--auth--dbpath=/home/app/mongodb/mongodbdata/--
Logpath=/home/app/mongodb/log/mongodb.log--logappend&
7. Create a database Operationlog, create a collections
Operationlog,
Oparticlelog,
Optopiclog,
Oploginlog
8. Create an index:
Db.operationlog.ensureIndex ({"UserId": 1, "UpdateTime":-1},{"name": "Oplog_userid_index"});
Db.oparticlelog.ensureIndex ({"UserId": 1, "UpdateTime":-1},{"name": "Opdoclog_userid_index"});
Db.oparticlelog.ensureIndex ({"ArticleID": 1, "UpdateTime":-1},{"name": "Opdoclog_docid_index"});
Db.oploginlog.ensureIndex ({"UserId": 1, "UpdateTime":-1},{"name": "Oploginlog_userid_index"});
Db.optopiclog.ensureIndex ({"UserId": 1, "UpdateTime":-1},{"name": "Optopicid_userid_index"});
Db.optopiclog.ensureIndex ({"TopicID": 1, "UpdateTime":-1},{"name": "Optopicidlog_topicid_index"});
9. Add users to Operationlog,
1) MONGO
2) Use admin;
3) Db.auth (' Mongouser ', ' 123456! ');
4) Use Operationlog
5) Db.adduser (' Mongouser ', ' 123456! ');
10. Other Commands:
Mongo
Use Operationlog;
Db.auth (' Mongouser ', ' 123456! ');
Show DBS: Display Database list
Show Collections: Displays a collection in the current database (similar to a table in a relational database)
Show Users: Show user
Db.optopiclog.count (); View Collection Total data volume
Exit Exit
11. View the Delete log feature:
Mongo
Use Operationlog;
Db.auth (' Mongouser ', ' 123456! ');
1) CREATE TABLE: Db.createcollection ("Opdellog");
2) Create an index:
Db.opdellog.ensureIndex ({"UserId": 1, "UpdateTime":-1},{"name": "Opdellog_userid_index"});
Db.opdellog.ensureIndex ({"ArticleID": 1, "UpdateTime":-1},{"name": "Opdellog_docid_index"});
Db.opdellog.ensureIndex ({"Articleormodelname": 1, "UpdateTime":-1},{"name": "Opdellog_docname_index"});
3) View all indexes on a table
Db.opdellog.getIndexes ();
This article from "Quiet Zhiyuan" blog, declined reprint!
MongoDB Database Usage Summary