Add MONGO service: Mongod--logpath D:\mongodb\log\mongodb.log--logappend--dbpath D:\mongodb\data--servicename, MongoDB--ins Tall--auth
The Green Word section is the path to the database log and the database file, so make sure you already exist.
The--
Chapter One: Understanding Nodejs Framework express--Routing, middleware
- Routing
Routing is how to define an application's endpoint (URIs) and how to respond to a client's request.
A route consists of a URI, an HTTP request (get, post, and so
Although previously contacted the content of MySQL, but do the website, feel NoSQL database or go around.Many books have mentioned the use of Node.js and MongoDB, here to record the learning process.
Basic commands for MongoDB:
Use dbname new or
The discovery process of the problem is this, some hardware equipment uploaded real-time device information client can not show, so the query log, found that the data time delay is very serious, background logic to this data as outdated data thrown
Download MongoDB
wget http://downloads.mongodb.org/linux/mongodb-linux-i686-2.4.9.tgz
If the above address is not possible to go to the official website download Http://www.mongodb.org/downloads decompression MongoDB
Tar zxvfmongodb-linux-i686-2.4
the opening of the MongoDB
default startup:
$./mongodb
Default data Save path:/data/db/default port: 27017
To Modify the default path:
--dbpath $./mongdb--dbpath/mongodb/points The data storage location to a directory of its own/mongodb/
To
MongoDB cluster refactoring, freeing up disk space
Since MongoDB deletes part of the data, it does not reclaim the disk space, so it frees up disk space by rebuilding the data directory. an experimental environment
A replica set is configured that
Recently has been thinking about the architecture of things, there is a problem still bothering us to do business systems, that is, log and log statistics. The general question is as follows: We have a lot of modules, although the log format is
With yesterday's smooth, today is more confident, today to do is to obtain the number of interval records, for the foreground statistics chart preparation data, for example, the effect is,
In 1 days, there are xx times, within 2 days of XX times,
The final processing results are stored in the "ttt_date_out" table and the next mapreduce is written, and the expected result is the average record generation time Map for all records:
function Map () {
var count_time = 0;
var arv_time = 0;
var
Start real actual combat, table data about 100w, today first to solve the first demand, that is, to find the average record time, directly run "Combat 2" has been written mapreduce. An exception, no results, as long as the {sort}, there is no result,
Golang connecting MongoDB
Required Packages:
"Labix.org/v2/mgo"
"Labix.org/v2/mgo/bson"
//Connect to database session, Err: = MgO. Dial ("10.127.2.19:27017")//server and port to connect to if Err! = Nil { panic (err)
Article Source: Http://www.mongodb.org/display/DOCS/Database+Profiler
Just contact with MongoDB, have used the profile, but not so detailed to read this document, may be the size of their own system is not large enough, if the traffic will
Introductory Remarks: db.keyword.distinct ("keyword"). length
As follows:
Db.keyword.distinct ("keyword"). length
View the total number of records in the keyword field in the keyword table without duplicates
This method is not seen in the
Use command
MongoDB use database_name
Used to create the database. The command creates a new database and returns the existing database if it does not exist.
Dropdatabase () method
MongoDB Db.dropdatabase ()
The command is used to delete an
focus on MongoDB sum of a field sum
New Basicdbobject ("$group", New Basicdbobject ("_id", "$number"). Append ("Total", New Basicdbobject ("$sum", "$" + "length ")));
New Basicdbobject ("_id", "$" +queryfield) is a fixed format
GROUP BY query
A. Introduction
Db.collection.group () uses JavaScript, which is subject to some performance limitations. In most cases, the $ group in aggregation pipeline provides an alternative that has less restrictive applicability. A simple aggregation
# mongod.conf#where to logLogpath=/opt/mongodb/mongod.logLogappend=true# fork and run in backgroundFork=trueport=27017maxconns=5000Quiet=truenssize=2047Dbpath=/mongo/replset/data#dbpath =/opt/mongodb/replset/dataProfile=0#slowms =100#smallfiles
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service