This article is about MongoDB remote access configuration, not to mention the following, directly to see the detailed steps.
1, first modify the MongoDB configuration file to listen to all the extranet IP
Edit file: /etc/mongodb.conf
The revised
My goal is to achieve:
You can search for articles with one or more keywords.
You can find the relevant articles through the list of keywords in the article.
The results of the query are sorted in descending order of relevance.
Queries are fast
After installation, enter in the console:
MONGO start the client.
Show DBS displays all databases.
Use XXX to select the database for the current database.
Show collections displays all collections of the current database.
Db.colleciton.find ()
We know that MySQL in the installation of the need for us to set a database default username and password, MongoDB is no exception, but MongoDB is the default does not set access restrictions, do not need to enter a username and password can be
One, find operation
Find is used in MongoDB to query, and all and part of the query can be implemented by specifying the first parameter of find.
1, all inquiries
The empty query document {} will match the entire contents of the collection. If
MongoDB log files in the case of setting logappend=true, will continue to the same log file appended, the time is long, naturally become very large.
Resolved as follows: (Special note: The boot must be--logpath specified log path)
Connecting to
We look at MongoDB from an administrator's point of view, as an administrator, we are often exposed to 4 main areas:
1. Install deployment
2. State Monitoring
3. Security certification
4. Backup and Recovery,
Here we will explain the 1.1 points.
1. Create a Super User
Use admin
db.createuser (
{
User: "Adminusername",
pwd: "UserPassword",
roles:
[
{
roles: "Useradminanydatabase",
DB: "admin"
}
)
There are two types of superuser
Insert () Method:The following is a document that inserts a three field into the inventory collection:
Copy Code code as follows:
Db.inventory.insert ({_id:10, type: "Misc", Item: "Card", qty:15})
In the real example, the document
In the study of the index of MongoDB is to find a strange problem, set the text index to a string field, but did not use the index when querying. Like what:
Db.tomcat_access_logs.ensureIndex ({url: ' text '});
Db.tomcat_access.logs.find ({url: ' 1
1. $incUsage: {$inc: {Field:value}}Function: Adds value to a field of a number> db.test1.update ({' name ': ' Wang '},{$inc: {age:1}})> db.test1.find ({' name ': ' Wang '}){"_id": ObjectId ("58662477fb6a734e8f45133f"), "name": "Wang", "age": +, "sex"
1. ConceptSharding (sharding) refers to the process of splitting data and dispersing it across different machines. This concept is sometimes represented by partitioning (partitioning). Spread the data across different machines without the need for
1. Query the document in the collection, you can use the command DB. Collection name. Find ({condition}), or use DB. Collection name. FindOne () query the first document2. Query the document in the collection to return some specific key values3.
#mongodb安装 (3.4.0) #下载安装包, unzip Mkdir/data/mongodb Cd/data/mongodb mkdir Log conf Data bin Vim conf/mongod.conf #添加一下内容 port=27017Dbpath=/data/mongodb/dataLogpath=/data/mongodb/log/mongod.logFork=true#auth =true #添加管理员后取消注释, restart the
First, let's talk about the principle of Map-Reduce.For the basic principles of Map-Reduce, see the following figure:For the entire data processing process, see the official figure above. First, Query the data to be processed, map the data in the
Remove () function prototypeDb. collection. remove (, )Example The code is as follows:Copy code // Delete all dataDb. test. remove ()// Delete all data whose _ id is greater than 10Db. test. remove ({_ Id: {$ gt: 10 }}) // Delete a data entry
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