To improve query efficiency, MONGODB also provides indexes (like the index of relational databases, using B-tree storage), with a single field index, combination index, multiple key index (for array query), spatial index, text index, and hash index.
First step. Start the appropriate Mongod process
Mongod--fork--slave --port 27017--replset myset--rest--dbpath/data/dbmongo/shard11--logpath/data/dbmongo/ Shard11.log
mongod--fork--slave--port 27018--replset myset--rest--dbpath/data/dbmongo/shard12
Today in the project encountered about MongoDB nested query, has not been contacted before, query the relevant data to record the results.
The data in the MongoDB are as follows:
> Db.customer.findOne ()
{
"_id": ObjectId ("57636c8e35defe02996210
Replication Cluster Configuration
1. Install the MongoDB databaseInstall MongoDB on both the master node and from the node
# RPM-IVH mongo-10gen-2.4.6-mongodb_1.x86_64.rpm mongo-10gen-server-2.4.6-mongodb_1.x86_64.rpm
2. Configuration
How to create a Full-text index:
Db.ensureindex ({key: "text"})
Db.ensureindex ({key1: "text", Key2: "Text"})
Db.ensureindex ({"$**": "Text", Key2: "Text"})
MongoDB the use of Full-text indexing queries:
Db.article.find ({$text: {$search:
the concept of a replica set
The replica set (also known as the replica set Replica set) is the master-slave cluster with automatic failure recovery.
The most obvious difference between the traditional master-slave structure and the replication
One, the establishment of play of a project
Add a MongoDB jar package and create a tool class
Using a single case pattern
Third, create a test object
IV. CRUD
Implementation in Mongoutil
Routing control:
Test:
These two days a simple study of the MongoDB database, belong to the NoSQL type database, a simple macroscopic look at NoSQL knowledge and MongoDB basic knowledge.
NoSQL is not just SQL abbreviation, it refers to the relational database, which is
operation of the index
The work of database 80% is basically a query, and the index can help us to query the desired data more quickly. But it reduces the write speed of the data, so it is necessary to weigh the common query fields without having
MONGO Warning:
2016-09-05t10:55:13.241+0800 I CONTROL [initandlisten] * * WARNING:/sys/kernel/mm/transparent_hugepage/enabled is ' Always '.2016-09-05t10:55:13.241+0800 I CONTROL [initandlisten] * * We suggest setting it to ' never '2016-09-05t10:55
One, insufficient authority
We have two workarounds for this.
1,# setcap Cap_fowner+ep/usr/bin/mongod
2,chmod +777 MONGO
Two,
The reason for this problem is that there is no proper operation when exiting.
Workaround:
1. Find the file
MongoDB Getting Started column
Http://blog.csdn.net/column/details/19681.html
Database Operations View Database
# View all databases under the current MONGO
> Show Databases
> Show DBS
Create a database
# Connect, create TestDB database
> Use
By default, update updates the first found data, and we do an experiment by inserting 3 C-1 data.Db.test_collection.insert ({c:1})And then we'll find a bit.Db.test_collection.find ({c:1})The result is{"_id": ObjectId ("5b5e3f7da2b4848fd8c49dbf"), "C"
ReasonMongoDB will save the fragmented collection in the Config.collection collection, and if you need to see the Shard key, you need to find it based on that collection. Many other official Shard shortcut commands are also in the Config
When you need bulk operations, you can save network connection interactions and use Bulk_write.Set Ordered=false because there is no dependency in the bulk operation, and if there is an interdependence after the cyanide, it needs to be set to
Eg: there is a data for name = Lisi,age = 12, now, you want to modify the age of this data = 20The code is as follows:Db.admin.update ({name:'Lisi'},{$set: {age:Ten}})///The first parameter means finding the data, The second parameter indicates that
Currently, spring MongoDB is m3 and needs to be used in combination with spring 3.0.5 and JDK 1.6. The following is an example:
Note:
1. Start a MongoDB Database./MongoDB-xxxxxxx/bin/mongod -- dbpath =/MongoDB
2. In the example, 20 person objects
1. Clone collection1) clone the remote colletion and run the clonecollection command to copy the remote collection to the local computer.Command Format: DB. runcommand ({clonecollection: "set", from: "original machine", copyindexes: false}),
Source code implementation of replica set
1. Start the process
DB. cppMainMongodbmainInitandlisten_ InitandlistenListenCreateserver (options, new mymessagehandler ());Startreplication
The startreplication function is analyzed here.2.
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