??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久久久久波多野高潮日日,久久精品成人,男女视频在线观看免费http://www.aygfsteel.com/paulwong/category/53872.htmlzh-cnWed, 19 Oct 2022 02:40:02 GMTWed, 19 Oct 2022 02:40:02 GMT60MONGODB SPRING DISTINCThttp://www.aygfsteel.com/paulwong/archive/2022/10/18/450835.htmlpaulwongpaulwongTue, 18 Oct 2022 02:22:00 GMThttp://www.aygfsteel.com/paulwong/archive/2022/10/18/450835.htmlhttp://www.aygfsteel.com/paulwong/comments/450835.htmlhttp://www.aygfsteel.com/paulwong/archive/2022/10/18/450835.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/450835.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/450835.html
    private boolean needReorderCheck(String requestId) {
        boolean result = false;
//        try(MongoCursor<String> mongoCursor = 
//                mongoTemplate.getCollection(mongoTemplate.getCollectionName(AccountNumProductLineIndex.class))
//                             .distinct(KEY, Filters.eq(REQUEST_ID, requestId), String.class)
//                             .iterator()
//                )
        try(MongoCursor<Document> mongoCursor = 
                mongoTemplate.getCollection(mongoTemplate.getCollectionName(AccountNumProductLineIndex.class))
                             .aggregate(
                                 Arrays.asList(
                                    Aggregates.project(
                                                    Projections.fields(
                                                                    Projections.excludeId(),
                                                                   Projections.include(KEY),
                                                                   Projections.include(REQUEST_ID)
                                                                )
                                               ),
                                    Aggregates.match(Filters.eq(REQUEST_ID, requestId)),
                                    Aggregates.group("$" + KEY)
                                 )
                              )
                             .allowDiskUse(true)
                             .iterator();
        )
        {
            String key = null;
            boolean breakMe = false;
            LOGGER.info("needReorderCheck.key --> start");
            while(mongoCursor.hasNext()) {
                if(breakMe) {
                    mongoCursor.close();
                    break;
                }
                Document keyDocument = mongoCursor.next();
                key = keyDocument.getString("_id");
//                key = mongoCursor.next().getString(KEY);
//                LOGGER.info("needReorderCheck.keyDocument --> {}, key --> {}", keyDocument, key);
                try(MongoCursor<Document> indexMongoCursor = 
                        mongoTemplate.getCollection(AccountNumProductLineIndex.COLLECTION_NAME)
                                        .find(Filters.and(Filters.eq(REQUEST_ID, requestId), Filters.eq(KEY, key)))
                                        .iterator()
                )
                {
                    int preIndex = -1, currentIndex = -1;
                    Document preIndexDocument = null, currentIndexDocument;
                    while(indexMongoCursor.hasNext()) {
                        currentIndexDocument = indexMongoCursor.next();
//                        System.out.println(currentIndexDocument.toJson());
                        if(preIndexDocument != null) {
                             currentIndex = currentIndexDocument.getInteger(INDEX);
                             preIndex = preIndexDocument.getInteger(INDEX);
                             if(currentIndex - preIndex > 1) {
                                indexMongoCursor.close();
                                breakMe = true;
                                result = true;
                                break;
                            }
                        }
                        preIndexDocument = currentIndexDocument;
                    }
                }
            }
        }
        
        return result;
    }



paulwong 2022-10-18 10:22 发表评论
]]>
MONGODB SHELLhttp://www.aygfsteel.com/paulwong/archive/2022/01/10/438649.htmlpaulwongpaulwongMon, 10 Jan 2022 03:10:00 GMThttp://www.aygfsteel.com/paulwong/archive/2022/01/10/438649.htmlhttp://www.aygfsteel.com/paulwong/comments/438649.htmlhttp://www.aygfsteel.com/paulwong/archive/2022/01/10/438649.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/438649.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/438649.htmlmongo -u admin -p 123456 --authenticationDatabase admin
use admin
db.createUser({
 user : "paul",
 pwd : "123456",
 roles : [{role : "readWrite", db : "batch"}]
})

#增加权限
db.grantRolesToUser( 
  "paul"
  [
    { "role" : "dbOwner",
      "db" : "mcra"
    }
  ]
)

paulwong 2022-01-10 11:10 发表评论
]]>
WEBFLUX + SPRING SESSION + REACTIVE MONGODBhttp://www.aygfsteel.com/paulwong/archive/2021/12/22/436240.htmlpaulwongpaulwongWed, 22 Dec 2021 01:24:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/12/22/436240.htmlhttp://www.aygfsteel.com/paulwong/comments/436240.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/12/22/436240.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/436240.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/436240.html d依赖Qpom.xml
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
        
        
<!-- spring session with mongodb -->
<dependency>
   <groupId>org.springframework.session</groupId>
   <artifactId>spring-session-data-mongodb</artifactId>
</dependency>
        
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>

配置文gQapplication.yaml

spring:
   session:
      store-type: mongodb
      timeout: 30s
      mongodb:
         collection-name: WEB_SESSIONS


java配置QHttpSessionConfiguration.javaQ?/h2>
package com.paul.testmicroservicecommon.config;

import org.springframework.boot.autoconfigure.session.MongoSessionProperties;
import org.springframework.boot.autoconfigure.session.SessionProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.session.config.ReactiveSessionRepositoryCustomizer;
import org.springframework.session.data.mongo.ReactiveMongoSessionRepository;
import org.springframework.session.data.mongo.config.annotation.web.reactive.EnableMongoWebSession;

@EnableMongoWebSession
@EnableConfigurationProperties(MongoSessionProperties.class)
public class HttpSessionConfiguration {
    
    @Bean
    public ReactiveSessionRepositoryCustomizer<ReactiveMongoSessionRepository> customize(
        SessionProperties sessionProperties,
        MongoSessionProperties mongoSessionProperties
    ){
        return c -> {
            c.setMaxInactiveIntervalInSeconds((int)sessionProperties.getTimeout().getSeconds());
            c.setCollectionName(mongoSessionProperties.getCollectionName());
        };
    }

}



paulwong 2021-12-22 09:24 发表评论
]]>MONGODB聚合资源http://www.aygfsteel.com/paulwong/archive/2021/04/08/435847.htmlpaulwongpaulwongThu, 08 Apr 2021 05:38:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/04/08/435847.htmlhttp://www.aygfsteel.com/paulwong/comments/435847.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/04/08/435847.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435847.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435847.htmlhttps://www.javaprogramto.com/2020/05/spring-boot-data-mongodb-projections-aggregations.html

In spring data mongodb how to achieve pagination for aggregation
https://stackoverflow.com/questions/34427241/in-spring-data-mongodb-how-to-achieve-pagination-for-aggregation

Create a ProjectionOperation with Difference with spring mongodb
https://stackoverflow.com/questions/46786577/create-a-projectionoperation-with-difference-with-spring-mongodb


paulwong 2021-04-08 13:38 发表评论
]]>
SPRING DATA MONGODB 教程http://www.aygfsteel.com/paulwong/archive/2020/11/20/435729.htmlpaulwongpaulwongFri, 20 Nov 2020 06:45:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/11/20/435729.htmlhttp://www.aygfsteel.com/paulwong/comments/435729.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/11/20/435729.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435729.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435729.htmlhttps://github.com/eugenp/tutorials/tree/master/persistence-modules/spring-data-mongodb


paulwong 2020-11-20 14:45 发表评论
]]>
Finding slow queries in MongoDBhttp://www.aygfsteel.com/paulwong/archive/2020/03/27/435309.htmlpaulwongpaulwongFri, 27 Mar 2020 15:35:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/03/27/435309.htmlhttp://www.aygfsteel.com/paulwong/comments/435309.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/03/27/435309.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435309.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435309.htmlDatabase Profiling

MongoDB Profiler is a db profiling system that can help identify inefficient

or slow queries and operations.

Levels of profiles available are:

Level

Setting

0

Off. & No profiling

1

On & only includes slow operations

2

On & Includes all operations


We can enable it by setting the Profile level value using the following
command in mongo shell :

"db.setProfilingLevel(1)"

By default, mongod records slow queries to its log, as defined by slowOpThresholdMs.

NOTE

Enabling database profiler puts negative impact on MongoDB’s performance.

It’s better to enable it for specific intervals & minimal on Production Servers.

We can enable profiling on a mongod basis but This setting will not propagate
across a replica set and sharded cluster.

We can view the output in the system.profile collection in mongo shell using show profile command, or using following:

db.system.profile.find( { millis : { $gt : 200 } } )

Command returns operations that took longer than 200 ms. Similarly we
can change the values as per our need.

Enabling profile for an entire mongod instance.

For the purpose of development in testing, we can enable database profiling/settings for an 
entire mongod instance. The profiling level will be applied to all databases.

 

NOTE:

We can't enable the profiling settings on a mongos instance. To enable the profiling in

shard clusters, we have to enable/start profiling for each mongod instance in cluster.

 

Query for the recent 10 entries

db.system.profile.find().limit(10).sort( { ts : 1 } ).pretty()

 

Collection with the slowest queries(No. Of queries)

db.system.profile.group({key: {ns: true}, initial: {count: 0}, reduce: function(obj,prev){ prev.count++;}})

 

Collection with the slowest queries(No. Of millis spent)

db.system.profile.group({key: {ns: true}, initial: {millis: 0}, reduce: function(obj, prev){ prev.millis += obj.millis;}})

 

Most recent slow query

db.system.profile.find().sort({$natural: -1}).limit(1)

 

Single slowest query(Right now)

db.system.profile.find().sort({millis: -1}).limit(1)



paulwong 2020-03-27 23:35 发表评论
]]>
Spring Boot Data Mongodb Starter自动配置那些?/title><link>http://www.aygfsteel.com/paulwong/archive/2020/03/17/435271.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Tue, 17 Mar 2020 01:39:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2020/03/17/435271.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/435271.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2020/03/17/435271.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/435271.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/435271.html</trackback:ping><description><![CDATA[<div style="font-size: medium;"><div><p>正好做MongodbM复制试使用Spring Boot Data Mongodb Starter插g链接讉KMongodb数据库集?/p><p>遇到的坑Q?/p><ul><li>spring.data.mongodb.host和spring.data.mongodb.port形式不适合集群配置Q会报host无法识别异常</li><li>spring.data.mongodb.uri中经常抛出authentication failed异常</li></ul><p><br /></p><p>解决办法Q?/p><ol><li> 对于W一个坑Q请使用spring.data.mongodb.uri?span style="background-color: yellow;">如果使用了uriQ则其余的host/username/password/db/auth-dbq些全部无效?/span></li><li> 对于W二个坑Q请在spring.data.mongodb.uri中指定replicaSet和authsourceQ另外记得把所有集节Ҏ务器地址都列全?br /><span style="background-color: yellow;">如果auth-db和db是同一个,则无需加authsourceQ如果不同,则加authsource=admin</span></li></ol><p><br /></p><p>我没有把authsource指定Q所以一直报authentication failed异常。然后只好一点点d掘问题点Q最后查到在com.mongodb.ConnectionStringcM的createCredentials?br /><br /></p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">private</span> MongoCredential createCredentials(<span style="color: #0000FF; ">final</span> Map<String, List<String>> optionsMap, <span style="color: #0000FF; ">final</span> String userName,<br />                                              <span style="color: #0000FF; ">final</span> <span style="color: #0000FF; ">char</span>[] password) {<br />        AuthenticationMechanism mechanism = <span style="color: #0000FF; ">null</span>;<br />        String authSource = (database == <span style="color: #0000FF; ">null</span>) ? "admin" : database;<br />        String gssapiServiceName = <span style="color: #0000FF; ">null</span>;<br />        String authMechanismProperties = <span style="color: #0000FF; ">null</span>;<br /><br />        <span style="color: #0000FF; ">for</span> (<span style="color: #0000FF; ">final</span> String key : AUTH_KEYS) {<br />            String value = getLastValue(optionsMap, key);<br /><br />            <span style="color: #0000FF; ">if</span> (value == <span style="color: #0000FF; ">null</span>) {<br />                <span style="color: #0000FF; ">continue</span>;<br />            }<br /><br />            <span style="color: #0000FF; ">if</span> (key.equals("authmechanism")) {<br />                mechanism = AuthenticationMechanism.fromMechanismName(value);<br />            } <span style="color: #0000FF; ">else</span> <span style="color: #0000FF; ">if</span> (key.equals("authsource")) {<br />                authSource = value;<br />            } <span style="color: #0000FF; ">else</span> <span style="color: #0000FF; ">if</span> (key.equals("gssapiservicename")) {<br />                gssapiServiceName = value;<br />            } <span style="color: #0000FF; ">else</span> <span style="color: #0000FF; ">if</span> (key.equals("authmechanismproperties")) {<br />                authMechanismProperties = value;<br />            }<br />        }<br /><br /><br />        MongoCredential credential = <span style="color: #0000FF; ">null</span>;<br />        <span style="color: #0000FF; ">if</span> (mechanism != <span style="color: #0000FF; ">null</span>) {<br />            <span style="color: #0000FF; ">switch</span> (mechanism) {<br />                <span style="color: #0000FF; ">case</span> GSSAPI:<br />                    credential = MongoCredential.createGSSAPICredential(userName);<br />                    <span style="color: #0000FF; ">if</span> (gssapiServiceName != <span style="color: #0000FF; ">null</span>) {<br />                        credential = credential.withMechanismProperty("SERVICE_NAME", gssapiServiceName);<br />                    }<br />                    <span style="color: #0000FF; ">break</span>;<br />                <span style="color: #0000FF; ">case</span> PLAIN:<br />                    credential = MongoCredential.createPlainCredential(userName, authSource, password);<br />                    <span style="color: #0000FF; ">break</span>;<br />                <span style="color: #0000FF; ">case</span> MONGODB_CR:<br />                    credential = MongoCredential.createMongoCRCredential(userName, authSource, password);<br />                    <span style="color: #0000FF; ">break</span>;<br />                <span style="color: #0000FF; ">case</span> MONGODB_X509:<br />                    credential = MongoCredential.createMongoX509Credential(userName);<br />                    <span style="color: #0000FF; ">break</span>;<br />                <span style="color: #0000FF; ">case</span> SCRAM_SHA_1:<br />                    credential = MongoCredential.createScramSha1Credential(userName, authSource, password);<br />                    <span style="color: #0000FF; ">break</span>;<br />                <span style="color: #0000FF; ">default</span>:<br />                    <span style="color: #0000FF; ">throw</span> <span style="color: #0000FF; ">new</span> UnsupportedOperationException(format("The connection string contains an invalid authentication mechanism'. "<br />                                                                           + "'%s' is not a supported authentication mechanism",<br />                            mechanism));<br />            }<br />        } <span style="color: #0000FF; ">else</span> <span style="color: #0000FF; ">if</span> (userName != <span style="color: #0000FF; ">null</span>) {<br />            credential = MongoCredential.createCredential(userName, authSource, password);<br />        }<br /><br />        <span style="color: #0000FF; ">if</span> (credential != <span style="color: #0000FF; ">null</span> && authMechanismProperties != <span style="color: #0000FF; ">null</span>) {<br />            <span style="color: #0000FF; ">for</span> (String part : authMechanismProperties.split(",")) {<br />                String[] mechanismPropertyKeyValue = part.split(":");<br />                <span style="color: #0000FF; ">if</span> (mechanismPropertyKeyValue.length != 2) {<br />                    <span style="color: #0000FF; ">throw</span> <span style="color: #0000FF; ">new</span> IllegalArgumentException(format("The connection string contains invalid authentication properties. "<br />                            + "'%s' is not a key value pair", part));<br />                }<br />                String key = mechanismPropertyKeyValue[0].trim().toLowerCase();<br />                String value = mechanismPropertyKeyValue[1].trim();<br />                <span style="color: #0000FF; ">if</span> (key.equals("canonicalize_host_name")) {<br />                    credential = credential.withMechanismProperty(key, Boolean.valueOf(value));<br />                } <span style="color: #0000FF; ">else</span> {<br />                    credential = credential.withMechanismProperty(key, value);<br />                }<br />            }<br />        }<br />        <span style="color: #0000FF; ">return</span> credential;<br />    }</div><p><br /></p><p>authSource默认会指向我们目标数据的数据库。然而在w䆾验证机制中我们通常需要指向admin。(非常x_口Q代码作者在q里脑袋被men挤了么)。所以需要强制指定authSource中指定。具体指定方式如下:</p><p> </p><p> </p><p> </p><p> </p><pre bash"=""><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->mongodb://{用户名}:{密码}@{host1}:27017,{host2}:27017,{host3}:27017/{目标数据库}?replicaSet={复制集名U}&write=1&readPreference=primary&authsource={授权数据库}</div></pre></div></div><img src ="http://www.aygfsteel.com/paulwong/aggbug/435271.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2020-03-17 09:39 <a href="http://www.aygfsteel.com/paulwong/archive/2020/03/17/435271.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MongDBq接池参数serverSelectionTimeout、connectTimeout、maxWaitTime和socketTimeout介绍http://www.aygfsteel.com/paulwong/archive/2020/03/07/435231.htmlpaulwongpaulwongSat, 07 Mar 2020 12:58:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/03/07/435231.htmlhttp://www.aygfsteel.com/paulwong/comments/435231.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/03/07/435231.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435231.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435231.htmlMongDB Clienth查询数据Q需要包括五个阶D:
MongoDB Client需要找到可用的MongoDB Server
MongoDB Client需要和MongoDB Server建立QnewQConnection
应用E序处理U程从Connection Pool中获取Connection
数据传输Q获取连接后Q进行Socket通信Q获取数据)
断开Collection
那么QMongoDB Client驱动讄中网l相关等待超时参数serverSelectionTimeout、connectTimeout、maxWaitTime和socketTimeout分别对应上面哪个环节呢?
参数serverSelectionTimeoutQ对应第1个环节,即MongoDB Client需要找到可用的MongoDB Server所需要的{待旉Q?nbsp;                                            MongDB部v的生产一般由多个服务器组成,要么作ؓ一个复刉或者作Z个分片集,参数                                                     serverSelectionTimeout的值即为多长时间内找不到合适服务器时候就军_攑ּ的时间间隔;
参数connectTimeoutQ对应第2个环节,每次创徏ConnectionQ对应的|络{待。单位毫U数, 0表示没有限制Q?/div>
参数maxWaitTimeQ对应第3个环节,应用E序处理U程从连接池中获取CollectionQ对应的|络{待旉。单位毫U数Q?表示                                   不等待,负数表示{待旉不确定;
参数socketTimeoutQ对应第4个环节,获取Connection后,有了Socket通信Q获取数据,卛_MonogoDB Client                                                      和MonogoDB Server的Socket通信q程中的|络{待旉。单位毫U数Q默认配|ؓ0Q也是没有限制Q?nbsp;                                 没有?旉ӞpȝZ问题也不Ҏ发现Q应该根据实际情况,l出合理的超时时间?/div>
 
其他相关参数如下Q?/div>
connectionsPerHostQ对mongo实例来说Q每个host允许链接的最大链接数,q些链接I闲时会攑օ池中,如果链接被耗尽QQ何请求链接的操作会被d{待链接可用,推荐配置10
minPoolsSizeQ当ConnectionI闲?Connection Pool中最Connection保有量;
threadsAllowedToBlockForConnectionMultiplierQ每个Connection的可以阻塞等待的U程队列敎ͼ它以上面connectionsPerHost值相乘的l果是d{待的线E队列最大倹{如果连接线E排满了队列׃抛出“Out of semaphores to get db”错误?/div>
socketKeepAlive:该标志用于控制socket保持zd的功能,通过防火墙保持连接活着
socketKeepAlive=false
autoConnectRetryQ这个控制是否在一个ConnectionӞpȝ会自动重?/div>
#true:假如Connection不能建立?驱动重试相同的server,有最大的重试ơ数,默认?5?q样可以避免一些server因ؓ一些阻塞操作零时down而驱动抛出异?q个对^滑过度到一个新的master,也是很有用的,注意:当集ؓ复制集时,驱动在q段旉?试链接到旧的master?而不会马上链接到新master?/div>
#false 当在q行socketd?不会L异常抛出,驱动已经有自动重建破坏链接和重试L? 推荐配置false
autoConnectRetry=false
#重新打开链接到相同server的最大毫U数,推荐配置?Q如?autoConnectRetry=true,表示旉?5s
#com.jd.mongodbclient2.mongo.JDClientMongo.maxAutoConnectRetryTime=false
#表示当没有手动关闭游标时,是否有一个自动释放游标对象的Ҏ,如果你L很小心的关闭游标,则可以将其设为false 推荐配置true

https://docs.mongodb.com/manual/reference/connection-string/#connections-connection-options
————————————————
版权声明Q本文ؓCSDN博主「pursuer211」的原创文章Q遵?CC 4.0 BY-SA 版权协议Q{载请附上原文出处链接及本声明?/div>
原文链接Qhttps://blog.csdn.net/pursuer211/article/details/82994027


paulwong 2020-03-07 20:58 发表评论
]]>Mongodb shell中select in 的实?/title><link>http://www.aygfsteel.com/paulwong/archive/2020/02/21/435146.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Fri, 21 Feb 2020 15:10:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2020/02/21/435146.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/435146.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2020/02/21/435146.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/435146.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/435146.html</trackback:ping><description><![CDATA[<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->var bookIds = db.likes.find({userId:100}).map(function(like) { <br />  return like.bookId<span style="color: #008000; ">;</span><span style="color: #008000; "> </span><span style="color: #008000; "><br /></span>})<span style="color: #008000; ">;<br /></span>var books = db.books.find({_id:{$in:bookIds}})<span style="color: #008000; ">;</span></div><br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->db.REPORT_ITEM.count({REQUEST_ID : db.BATCH_CONTROL.find({ FILE_NAME : "20200218_100000.file" }).map(function(like) { <br />  return like._id<span style="color: #008000; ">;</span><span style="color: #008000; "> </span><span style="color: #008000; "><br /></span>})<span style="color: #800000; font-weight: bold; ">[</span><span style="color: #800000; ">0</span><span style="color: #800000; font-weight: bold; ">]</span>.str, JOB_TYPE_ENUM:"CHECK"})</div><img src ="http://www.aygfsteel.com/paulwong/aggbug/435146.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2020-02-21 23:10 <a href="http://www.aygfsteel.com/paulwong/archive/2020/02/21/435146.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mongodb错误记录http://www.aygfsteel.com/paulwong/archive/2020/02/21/435142.htmlpaulwongpaulwongFri, 21 Feb 2020 00:50:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/02/21/435142.htmlhttp://www.aygfsteel.com/paulwong/comments/435142.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/02/21/435142.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435142.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435142.htmlhttps://blog.csdn.net/wangxiaotongfan/article/details/81560463




paulwong 2020-02-21 08:50 发表评论
]]>
MONGODB安装http://www.aygfsteel.com/paulwong/archive/2019/11/15/434911.htmlpaulwongpaulwongFri, 15 Nov 2019 09:30:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/11/15/434911.htmlhttp://www.aygfsteel.com/paulwong/comments/434911.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/11/15/434911.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/434911.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/434911.html https://www.jianshu.com/p/d3b31b7aa182 

后箋初始化用户及数据?br />http://www.qianduan8.com/1786.html
https://zocada.com/setting-mongodb-users-beginners-guide/

如果要以认证的方式登录,需加以下内容至/etc/mongod.conf
security:
  authorization: enabled

如果用GUIq接数据库时Q不昄数据库列表,要加权限QlistDatabases
https://stackoverflow.com/questions/19458524/mongodb-show-dbs-and-show-log-without-clusteradmin-role



paulwong 2019-11-15 17:30 发表评论
]]>
MONGODB拓展操作http://www.aygfsteel.com/paulwong/archive/2019/09/03/434556.htmlpaulwongpaulwongTue, 03 Sep 2019 07:52:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/09/03/434556.htmlhttp://www.aygfsteel.com/paulwong/comments/434556.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/09/03/434556.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/434556.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/434556.htmlhttps://blog.csdn.net/ClementAD/article/details/55210973

Spring Data MongoDBpd之三Q数据库扚w操作
https://blog.csdn.net/sinat_24044957/article/details/80646292

Distinct in Spring Data MongoDB
https://stackoverflow.com/questions/19203724/distinct-in-spring-data-mongodb

MONGODB SQL语句
http://www.runoob.com/mongodb/mongodb-indexing.html




paulwong 2019-09-03 15:52 发表评论
]]>
Multiple MongoDB connectors with Spring Boothttp://www.aygfsteel.com/paulwong/archive/2019/06/20/433910.htmlpaulwongpaulwongThu, 20 Jun 2019 07:12:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/06/20/433910.htmlhttp://www.aygfsteel.com/paulwong/comments/433910.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/06/20/433910.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/433910.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/433910.htmlhttp://blog.marcosbarbero.com/multiple-mongodb-connectors-in-spring-boot/

https://github.com/yinjihuan/spring-boot-starter-mongodb-pool

https://github.com/lish1le/mongodb-plus


paulwong 2019-06-20 15:12 发表评论
]]>
SpringBoot使用MongoDB异常问题http://www.aygfsteel.com/paulwong/archive/2019/05/29/433819.htmlpaulwongpaulwongWed, 29 May 2019 08:58:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/05/29/433819.htmlhttp://www.aygfsteel.com/paulwong/comments/433819.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/05/29/433819.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/433819.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/433819.htmlhttps://www.cnblogs.com/linzhanfly/p/9674778.html

paulwong 2019-05-29 16:58 发表评论
]]>
MONGODB去除_class字段http://www.aygfsteel.com/paulwong/archive/2019/05/29/433818.htmlpaulwongpaulwongWed, 29 May 2019 06:18:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/05/29/433818.htmlhttp://www.aygfsteel.com/paulwong/comments/433818.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/05/29/433818.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/433818.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/433818.html
MongodbConfiguration.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.convert.DbRefResolver;
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
import org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
 
@Configuration
public class AppMongoConfig {
  @Autowired private MongoDbFactory mongoDbFactory;
 
  @Autowired private MongoMappingContext mongoMappingContext;
 
  @Bean
  public MappingMongoConverter mappingMongoConverter() {
 
    DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoDbFactory);
    MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, mongoMappingContext);
    converter.setTypeMapper(new DefaultMongoTypeMapper(null));
 
    return converter;
  }
}


paulwong 2019-05-29 14:18 发表评论
]]>
MongoDB健壮集群——用副本集做分片http://www.aygfsteel.com/paulwong/archive/2015/12/18/428724.htmlpaulwongpaulwongFri, 18 Dec 2015 06:03:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/12/18/428724.htmlhttp://www.aygfsteel.com/paulwong/comments/428724.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/12/18/428724.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/428724.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/428724.html阅读全文

paulwong 2015-12-18 14:03 发表评论
]]>
利用Mongodb的复刉搭徏高可用分片,Replica Sets + Sharding的搭E?/title><link>http://www.aygfsteel.com/paulwong/archive/2015/12/18/428723.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Fri, 18 Dec 2015 05:54:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2015/12/18/428723.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/428723.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2015/12/18/428723.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/428723.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/428723.html</trackback:ping><description><![CDATA[     摘要: 参考资?nbsp;reference:  http://mongodb.blog.51cto.com/1071559/740131  http://docs.mongodb.org/manual/tutorial/deploy-shard-cluster/#sharding-setup-shard-collection感谢|友Mr.SharpQ他l了我很?..  <a href='http://www.aygfsteel.com/paulwong/archive/2015/12/18/428723.html'>阅读全文</a><img src ="http://www.aygfsteel.com/paulwong/aggbug/428723.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2015-12-18 13:54 <a href="http://www.aygfsteel.com/paulwong/archive/2015/12/18/428723.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MONGODB的复制与分片http://www.aygfsteel.com/paulwong/archive/2015/12/18/428720.htmlpaulwongpaulwongFri, 18 Dec 2015 05:21:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/12/18/428720.htmlhttp://www.aygfsteel.com/paulwong/comments/428720.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/12/18/428720.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/428720.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/428720.html
  • 一般主从:一d从,Md数据Q从作从d份数据用Q如果主宕机Q则整个MONGODB无法工作?/li>
  • 复制式主从:一动态主多从Q主由选D产生Q当中一个主宕机Q其他的从会选出一个主?/li>

适用场景Q高负荷的读多写?br />
分片QSHARDINGQ一般数据库中的分库分表Q一个表分成几个表用。每个片再做复制?br />
适用场景Q高负荷的写多读。即如果发现MONGODB写不能支撑了Q则要{此模式?br />
安装配置服务器,安装ROUTERQMONGOSQ安装分片服务器Q通知MONGOS挂蝲SHARD?br />
如果只启用数据库的分片,则不同的表放在不同的分片上,即一个表只占一个分片,另一个表占另一个分片,如果做了表的分片Q则此表会分布在所有分片上?br />












paulwong 2015-12-18 13:21 发表评论
]]>
mongodb的监控与性能优化http://www.aygfsteel.com/paulwong/archive/2015/12/16/428691.htmlpaulwongpaulwongWed, 16 Dec 2015 10:50:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/12/16/428691.htmlhttp://www.aygfsteel.com/paulwong/comments/428691.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/12/16/428691.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/428691.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/428691.html阅读全文

paulwong 2015-12-16 18:50 发表评论
]]>
MONGODB删除/新增/更改大量记录的方?/title><link>http://www.aygfsteel.com/paulwong/archive/2015/12/11/428617.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Fri, 11 Dec 2015 07:03:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2015/12/11/428617.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/428617.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2015/12/11/428617.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/428617.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/428617.html</trackback:ping><description><![CDATA[MONGODB中,׃删除大量记录会十分耗时Q一般推荐由MONGODB自己在后台处理,只需在某个字D设一个烦引的标签卛_?br /><br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->@Indexed(expireAfterSeconds=180)<br /><span style="color: #0000FF; ">private</span> Date deletedAt;</div><br /><span style="color: red;">以上代码Q如果字D?/span><span style="font-size: 13px; color: red; background-color: #eeeeee;">deletedAt</span><span style="color: red;">有|那么在180U后被MONGODB删除Q如果没g会被删除?/span><br /><br />扚w新增Q小扚w更新Q防止读取超?br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">private</span> <T> <span style="color: #0000FF; ">void</span> insertAll(List<T> list) {<br />        <span style="color: #0000FF; ">if</span> (<span style="color: #0000FF; ">null</span> != list) {<br />            <span style="color: #0000FF; ">int</span> total = list.size();<br />            <span style="color: #0000FF; ">int</span> count = (total + 50000 -1) / 50000;<br />            <span style="color: #0000FF; ">for</span> (<span style="color: #0000FF; ">int</span> i = 0; i < count; i++) {<br />                <span style="color: #0000FF; ">int</span> toIndex = ((i +1) * 50000 > total) ? total : ((i +1) * 50000);<br />                log.info("toIndex = " + toIndex);<br />                mongoTemplate1.insertAll(list.subList(i * 50000, toIndex));<br />            }<br />        }<br />    }</div><br />扚w更改<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">import</span> java.util.Date;<br /><br /><span style="color: #0000FF; ">import</span> org.springframework.beans.factory.annotation.Autowired;<br /><span style="color: #0000FF; ">import</span> org.springframework.data.mongodb.core.MongoTemplate;<br /><span style="color: #0000FF; ">import</span> org.springframework.data.mongodb.core.query.Criteria;<br /><span style="color: #0000FF; ">import</span> org.springframework.data.mongodb.core.query.Query;<br /><span style="color: #0000FF; ">import</span> org.springframework.data.mongodb.core.query.Update;<br /><br /><span style="color: #0000FF; ">import</span> com.tcl.project7.boss.gameapplication.yearendactivities.bigwheelgame.valueobject.SingleUseRedeemCode;<br /><br /><span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> SingleUseRedeemCodeRepositoryImpl <span style="color: #0000FF; ">implements</span> SingleUseRedeemCodeRepositoryCustom{<br />    <br />    @Autowired<br />    <span style="color: #0000FF; ">private</span> MongoTemplate mongoTemplate1;<br />    <br />    <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">void</span> batchUpdateSingleUseRedeemCodeList(String bigWheelGameAwardId) {<br />        <br />        Query query = <span style="color: #0000FF; ">new</span> Query();<br />        query.addCriteria(Criteria.where("bigwheelgameawardid").is(bigWheelGameAwardId));<br />        mongoTemplate1.updateMulti(<br />                                    query, <br />                                    <span style="color: #0000FF; ">new</span> Update().set("bigwheelgameawardid", "-1")<br />                                        .set("deletedat", <span style="color: #0000FF; ">new</span> Date()), <br />                                    SingleUseRedeemCode.<span style="color: #0000FF; ">class</span>);<br />    }<br /><br />}</div><br /><br /><h1>Expire Data from Collections by Setting TTL<a title="Permalink to this headline" style="box-sizing: border-box; color: #c60f0f; text-decoration: none; visibility: visible; font-size: 0.8em; padding: 0px 4px;">¶</a></h1><div style="box-sizing: border-box; color: #494747; font-family: Akzidenz, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 24px; background-color: #ffffff;"><p style="box-sizing: border-box; margin: 24px 0px;"><span style="box-sizing: border-box; font-style: italic;">New in version 2.2.</span></p></div><p style="box-sizing: border-box; margin: 24px 0px; color: #494747; font-family: Akzidenz, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 24px; background-color: #ffffff;">This document provides an introduction to MongoDB’s “<em style="box-sizing: border-box;">time to live</em>” or <a internal"="" style="box-sizing: border-box; color: #006cbc; text-decoration: none;">TTL</a> collection feature. TTL collections make it possible to store data in MongoDB and have the <a internal"="" title="mongod" style="box-sizing: border-box; color: #006cbc; text-decoration: none;"><tt mongodb="" mongodb-program="" docutils="" literal"="" style="box-sizing: border-box; font-family: 'Source Code Pro', monospace; background-color: transparent;">mongod</tt></a> automatically remove data after a specified number of seconds or at a specific clock time.</p><p style="box-sizing: border-box; margin: 24px 0px; color: #494747; font-family: Akzidenz, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 24px; background-color: #ffffff;">Data expiration is useful for some classes of information, including machine generated event data, logs, and session information that only need to persist for a limited period of time.</p><p style="box-sizing: border-box; margin: 24px 0px; color: #494747; font-family: Akzidenz, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 24px; background-color: #ffffff;">A special <a internal"="" style="box-sizing: border-box; color: #006cbc; text-decoration: none;">TTL index property</a> supports the implementation of TTL collections. The TTL feature relies on a background thread in <a internal"="" title="mongod" style="box-sizing: border-box; color: #006cbc; text-decoration: none;"><tt mongodb="" mongodb-program="" docutils="" literal"="" style="box-sizing: border-box; font-family: 'Source Code Pro', monospace; background-color: transparent;">mongod</tt></a> that reads the date-typed values in the index and removes expired <a internal"="" style="box-sizing: border-box; color: #006cbc; text-decoration: none;">documents</a>from the collection.</p><div class="wmqeeuq" id="procedures" style="box-sizing: border-box; margin-top: 48px; color: #494747; font-family: Akzidenz, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 24px; background-color: #ffffff;"><h2>Procedures<a title="Permalink to this headline" style="box-sizing: border-box; color: #c60f0f; text-decoration: none; visibility: hidden; font-size: 0.8em; padding: 0px 4px;"></a></h2><p style="box-sizing: border-box; margin: 24px 0px; padding: 0px;">To create a <a internal"="" style="box-sizing: border-box; color: #006cbc; text-decoration: none;">TTL index</a>, use the <a internal"="" title="db.collection.createIndex()" style="box-sizing: border-box; color: #006cbc; text-decoration: none;"><tt mongodb="" mongodb-method="" docutils="" literal"="" style="box-sizing: border-box; font-family: 'Source Code Pro', monospace; background-color: transparent;">db.collection.createIndex()</tt></a> method with the<tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">expireAfterSeconds</tt> option on a field whose value is either a <a internal"="" style="box-sizing: border-box; color: #006cbc; text-decoration: none;">date</a> or an array that contains <a internal"="" style="box-sizing: border-box; color: #006cbc; text-decoration: none;">date values</a>.</p><div note"="" style="box-sizing: border-box; margin: 24px 0px; padding: 2px 12px 22px; width: auto; max-width: 100%; border-left-width: 5px; border-left-style: solid; border-color: #6ba442; background-color: #edf4e8;"><p admonition-title"="" style="box-sizing: border-box; margin: 0px; font-weight: bold; font-size: 12px; text-transform: uppercase; color: #89b668;">NOTE</p><p style="box-sizing: border-box; margin: 0px;">The TTL index is a single field index. Compound indexes do not support the TTL property. For more information on TTL indexes, see <a internal"="" style="box-sizing: border-box; color: #006cbc; text-decoration: none;">TTL Indexes</a>.</p></div><div class="wmqeeuq" id="expire-documents-after-a-specified-number-of-seconds" style="box-sizing: border-box; margin-top: 48px;"><h3>Expire Documents after a Specified Number of Seconds<a title="Permalink to this headline" style="box-sizing: border-box; color: #c60f0f; text-decoration: none; visibility: hidden; font-size: 0.8em; padding: 0px 4px;"></a></h3><p style="box-sizing: border-box; margin: 0px 0px 24px; padding: 0px;">To expire data after a specified number of seconds has passed since the indexed field, create a TTL index on a field that holds values of BSON date type or an array of BSON date-typed objects <em style="box-sizing: border-box;">and</em> specify a positive non-zero value in the <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">expireAfterSeconds</tt> field. A document will expire when the number of seconds in the <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">expireAfterSeconds</tt> field has passed since the time specified in its indexed field. <a id="id1" style="box-sizing: border-box; color: #006cbc; text-decoration: none;">[1]</a></p><p style="box-sizing: border-box; margin: 24px 0px;">For example, the following operation creates an index on the <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">log_events</tt> collection’s <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">createdAt</tt> field and specifies the <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">expireAfterSeconds</tt> value of <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">3600</tt> to set the expiration time to be one hour after the time specified by <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">createdAt</tt>.</p><div style="box-sizing: border-box;"><div style="box-sizing: border-box; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><pre style="box-sizing: border-box; font-family: 'Source Code Pro', monospace; font-size: 14px; padding: 24px 12px; margin-top: 24px; margin-bottom: 24px; word-break: break-all; word-wrap: normal; color: #222222; border-left-width: 5px; border-style: none none none solid; border-left-color: #494747; border-radius: 0px; overflow: auto; background: url("https://media.mongodb.org/code-block-bg.png") 0px 0px repeat #f5f6f7;"><span style="box-sizing: border-box;">db</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">log_events</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">createIndex</span><span style="box-sizing: border-box;">(</span> <span style="box-sizing: border-box;">{</span> <span style="box-sizing: border-box; color: #4070a0;">"createdAt"</span><span style="box-sizing: border-box; color: #666666;">:</span> <span style="box-sizing: border-box; color: #208050;">1</span> <span style="box-sizing: border-box;">},</span> <span style="box-sizing: border-box;">{</span> <span style="box-sizing: border-box;">expireAfterSeconds</span><span style="box-sizing: border-box; color: #666666;">:</span> <span style="box-sizing: border-box; color: #208050;">3600</span> <span style="box-sizing: border-box;">}</span> <span style="box-sizing: border-box;">)</span> </pre></div></div><p style="box-sizing: border-box; margin: 24px 0px;">When adding documents to the <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">log_events</tt> collection, set the <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">createdAt</tt> field to the current time:</p><div style="box-sizing: border-box;"><div style="box-sizing: border-box; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><pre style="box-sizing: border-box; font-family: 'Source Code Pro', monospace; font-size: 14px; padding: 24px 12px; margin-top: 24px; margin-bottom: 24px; word-break: break-all; word-wrap: normal; color: #222222; border-left-width: 5px; border-style: none none none solid; border-left-color: #494747; border-radius: 0px; overflow: auto; background: url("https://media.mongodb.org/code-block-bg.png") 0px 0px repeat #f5f6f7;"><span style="box-sizing: border-box;">db</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">log_events</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">insert</span><span style="box-sizing: border-box;">(</span> <span style="box-sizing: border-box;">{</span> <span style="box-sizing: border-box; color: #4070a0;">"createdAt"</span><span style="box-sizing: border-box; color: #666666;">:</span> <span style="box-sizing: border-box; color: #007020; font-weight: bold;">new</span> <span style="box-sizing: border-box; color: #007020;">Date</span><span style="box-sizing: border-box;">(),</span> <span style="box-sizing: border-box; color: #4070a0;">"logEvent"</span><span style="box-sizing: border-box; color: #666666;">:</span> <span style="box-sizing: border-box; color: #208050;">2</span><span style="box-sizing: border-box;">,</span> <span style="box-sizing: border-box; color: #4070a0;">"logMessage"</span><span style="box-sizing: border-box; color: #666666;">:</span> <span style="box-sizing: border-box; color: #4070a0;">"Success!"</span> <span style="box-sizing: border-box;">}</span> <span style="box-sizing: border-box;">)</span> </pre></div></div><p style="box-sizing: border-box; margin: 24px 0px;">MongoDB will automatically delete documents from the <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">log_events</tt> collection when the document’s<tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">createdAt</tt> value <a id="id2" style="box-sizing: border-box; color: #006cbc; text-decoration: none;">[1]</a> is older than the number of seconds specified in <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">expireAfterSeconds</tt>.</p><table footnote"="" frame="void" id="field-is-array-of-dates" rules="none" style="box-sizing: border-box; border-collapse: collapse; border-spacing: 0px; max-width: 100%; border: 0px; font-size: 14px; line-height: 24px; margin: 24px 0px; background-color: transparent;"><colgroup style="box-sizing: border-box;"><col style="box-sizing: border-box;"><col style="box-sizing: border-box;"></colgroup><tbody valign="top" style="box-sizing: border-box;"><tr style="box-sizing: border-box;"><td style="box-sizing: border-box; padding: 11px 5px 12px; border: 0px #ebebed !important;">[1]</td><td style="box-sizing: border-box; padding: 11px 5px 12px; border: 0px #ebebed !important;"><em style="box-sizing: border-box;">(<a style="box-sizing: border-box; color: #006cbc; text-decoration: none;">1</a>, <a style="box-sizing: border-box; color: #006cbc; text-decoration: none;">2</a>)</em> If the field contains an array of BSON date-typed objects, data expires if at least one of BSON date-typed object is older than the number of seconds specified in <tt literal"="" style="box-sizing: border-box; font-family: 'Source Code Pro', monospace;">expireAfterSeconds</tt>.</td></tr></tbody></table><div seealso"="" style="box-sizing: border-box; margin: 24px 0px; padding: 2px 12px 22px; width: auto; max-width: 100%; border-left-width: 5px; border-left-style: solid; border-left-color: transparent;"><p admonition-title"="" style="box-sizing: border-box; margin: 0px; font-weight: bold; font-size: 12px; text-transform: uppercase;">SEE ALSO</p><p style="box-sizing: border-box; margin: 0px;"><a internal"="" title="$currentDate" style="box-sizing: border-box; color: #006cbc; text-decoration: none;"><tt mongodb="" mongodb-update="" docutils="" literal"="" style="box-sizing: border-box; font-family: 'Source Code Pro', monospace; background-color: transparent;">$currentDate</tt></a> operator</p></div></div><div class="wmqeeuq" id="expire-documents-at-a-specific-clock-time" style="box-sizing: border-box; margin-top: 48px;"><h3>Expire Documents at a Specific Clock Time<a title="Permalink to this headline" style="box-sizing: border-box; color: #c60f0f; text-decoration: none; visibility: hidden; font-size: 0.8em; padding: 0px 4px;"></a></h3><p style="box-sizing: border-box; margin: 0px 0px 24px; padding: 0px;">To expire documents at a specific clock time, begin by creating a TTL index on a field that holds values of BSON date type or an array of BSON date-typed objects <em style="box-sizing: border-box;">and</em> specify an <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">expireAfterSeconds</tt> value of<tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">0</tt>. For each document in the collection, set the indexed date field to a value corresponding to the time the document should expire. If the indexed date field contains a date in the past, MongoDB considers the document expired.</p><p style="box-sizing: border-box; margin: 24px 0px;">For example, the following operation creates an index on the <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">log_events</tt> collection’s <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">expireAt</tt> field and specifies the <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">expireAfterSeconds</tt> value of <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">0</tt>:</p><div style="box-sizing: border-box;"><div style="box-sizing: border-box; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><pre style="box-sizing: border-box; font-family: 'Source Code Pro', monospace; font-size: 14px; padding: 24px 12px; margin-top: 24px; margin-bottom: 24px; word-break: break-all; word-wrap: normal; color: #222222; border-left-width: 5px; border-style: none none none solid; border-left-color: #494747; border-radius: 0px; overflow: auto; background: url("https://media.mongodb.org/code-block-bg.png") 0px 0px repeat #f5f6f7;"><span style="box-sizing: border-box;">db</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">log_events</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">createIndex</span><span style="box-sizing: border-box;">(</span> <span style="box-sizing: border-box;">{</span> <span style="box-sizing: border-box; color: #4070a0;">"expireAt"</span><span style="box-sizing: border-box; color: #666666;">:</span> <span style="box-sizing: border-box; color: #208050;">1</span> <span style="box-sizing: border-box;">},</span> <span style="box-sizing: border-box;">{</span> <span style="box-sizing: border-box;">expireAfterSeconds</span><span style="box-sizing: border-box; color: #666666;">:</span> <span style="box-sizing: border-box; color: #208050;">0</span> <span style="box-sizing: border-box;">}</span> <span style="box-sizing: border-box;">)</span> </pre></div></div><p style="box-sizing: border-box; margin: 24px 0px;">For each document, set the value of <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">expireAt</tt> to correspond to the time the document should expire. For instance, the following <a internal"="" title="db.collection.insert()" style="box-sizing: border-box; color: #006cbc; text-decoration: none;"><tt mongodb="" mongodb-method="" docutils="" literal"="" style="box-sizing: border-box; font-family: 'Source Code Pro', monospace; background-color: transparent;">insert()</tt></a> operation adds a document that should expire at <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;"><span style="box-sizing: border-box;">July</span> <span style="box-sizing: border-box;">22,</span> <span style="box-sizing: border-box;">2013</span><span style="box-sizing: border-box;">14:00:00</span></tt>.</p><div style="box-sizing: border-box;"><div style="box-sizing: border-box; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><pre style="box-sizing: border-box; font-family: 'Source Code Pro', monospace; font-size: 14px; padding: 24px 12px; margin-top: 24px; margin-bottom: 24px; word-break: break-all; word-wrap: normal; color: #222222; border-left-width: 5px; border-style: none none none solid; border-left-color: #494747; border-radius: 0px; overflow: auto; background: url("https://media.mongodb.org/code-block-bg.png") 0px 0px repeat #f5f6f7;"><span style="box-sizing: border-box;">db</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">log_events</span><span style="box-sizing: border-box;">.</span><span style="box-sizing: border-box;">insert</span><span style="box-sizing: border-box;">(</span> <span style="box-sizing: border-box;">{</span> <span style="box-sizing: border-box; color: #4070a0;">"expireAt"</span><span style="box-sizing: border-box; color: #666666;">:</span> <span style="box-sizing: border-box; color: #007020; font-weight: bold;">new</span> <span style="box-sizing: border-box; color: #007020;">Date</span><span style="box-sizing: border-box;">(</span><span style="box-sizing: border-box; color: #4070a0;">'July 22, 2013 14:00:00'</span><span style="box-sizing: border-box;">),</span> <span style="box-sizing: border-box; color: #4070a0;">"logEvent"</span><span style="box-sizing: border-box; color: #666666;">:</span> <span style="box-sizing: border-box; color: #208050;">2</span><span style="box-sizing: border-box;">,</span> <span style="box-sizing: border-box; color: #4070a0;">"logMessage"</span><span style="box-sizing: border-box; color: #666666;">:</span> <span style="box-sizing: border-box; color: #4070a0;">"Success!"</span> <span style="box-sizing: border-box;">}</span> <span style="box-sizing: border-box;">)</span> </pre></div></div><p style="box-sizing: border-box; margin: 24px 0px;">MongoDB will automatically delete documents from the <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">log_events</tt> collection when the documents’<tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">expireAt</tt> value is older than the number of seconds specified in <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">expireAfterSeconds</tt>, i.e. <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">0</tt> seconds older in this case. As such, the data expires at the specified <tt literal"="" style="box-sizing: border-box; color: #000000; font-family: 'Source Code Pro', monospace;">expireAt</tt> value.</p></div></div><img src ="http://www.aygfsteel.com/paulwong/aggbug/428617.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2015-12-11 15:03 <a href="http://www.aygfsteel.com/paulwong/archive/2015/12/11/428617.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>How to delete large amount of data of a MongoDB collection “quickly?/title><link>http://www.aygfsteel.com/paulwong/archive/2015/12/10/428601.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Thu, 10 Dec 2015 12:09:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2015/12/10/428601.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/428601.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2015/12/10/428601.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/428601.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/428601.html</trackback:ping><description><![CDATA[<p style="margin: 0px 0px 20px; padding: 0px; color: #626566; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px; background-color: #ffffff;">We have a db collection that is around 30 million documents, and I need to trim it down, to only keeping the documents created on the last month. </p><p style="margin: 0px 0px 20px; padding: 0px; color: #626566; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px; background-color: #ffffff;">One approach would be use the <code style="font-family: Monaco, Consolas, 'Courier New', monospace;">remove</code> command with a condition on the <code style="font-family: Monaco, Consolas, 'Courier New', monospace;">created_at</code> field (the collection already have an index on this field):</p><pre js"="" style="margin-top: 10px; margin-bottom: 10px; padding: 10px; font-family: Monaco, Consolas, 'Courier New', monospace; text-shadow: #ffffff 0px 1px; overflow: auto; color: #626566; font-size: 13px; line-height: 20.8px; background: #eeeeee;">db.my_collection.remove({created_at: {$lte: new Date("11/01/2012")}});</pre><p style="margin: 0px 0px 20px; padding: 0px; color: #626566; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px; background-color: #ffffff;">But this approach will be very slow, instead of that, a better way to do it is rename the current collection (for instance to “old_collection”) using <code style="font-family: Monaco, Consolas, 'Courier New', monospace;">renameCollection</code>. Then performing a query-and-insert from the “old_collection” into “my_collection”:</p><pre js"="" style="margin-top: 10px; margin-bottom: 10px; padding: 10px; font-family: Monaco, Consolas, 'Courier New', monospace; text-shadow: #ffffff 0px 1px; overflow: auto; color: #626566; font-size: 13px; line-height: 20.8px; background: #eeeeee;">db.my_collection.renameCollection("old_collection"); <br />db.createCollection("my_collection"); <br />db.my_collection.createIndex(...); // recreate the indexes for the collection <br />// copy docs from old collection into the new collection <br />db.old_collection.find( <br />{created_at: {$gte: new Date("11/01/2012")}} ).sort({_id: -1}).forEach( <br />function(row) { db.my_collection.insert(row); } ); // drop old collection db.old_collection.drop(); </pre><p style="margin: 0px 0px 20px; padding: 0px; color: #626566; font-family: Georgia, serif; font-size: 13px; line-height: 20.8px; background-color: #ffffff;">This approach is typically faster than running a bunch of removes on your data</p><img src ="http://www.aygfsteel.com/paulwong/aggbug/428601.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2015-12-10 20:09 <a href="http://www.aygfsteel.com/paulwong/archive/2015/12/10/428601.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MongoDB 固定集合(Capped Collections)http://www.aygfsteel.com/paulwong/archive/2015/12/09/428576.htmlpaulwongpaulwongWed, 09 Dec 2015 06:41:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/12/09/428576.htmlhttp://www.aygfsteel.com/paulwong/comments/428576.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/12/09/428576.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/428576.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/428576.htmlMongoDB 固定集合QCapped CollectionsQ是性能且有着固定大小的集合,对于大小固定Q我们可以想象其像一个环形队列,当集合空间用完后Q再插入的元素就会覆盖最初始的头部的元素Q?/p>

创徏固定集合

我们通过createCollection来创Z个固定集合,且capped选项讄为trueQ?/p>

>db.createCollection("cappedLogCollection",{capped:true,size:10000})

q可以指定文个?加上max:1000属性:

>db.createCollection("cappedLogCollection",{capped:true,size:10000,max:1000})

判断集合是否为固定集?

>db.cappedLogCollection.isCapped()

如果需要将已存在的集合转换为固定集合可以用以下命令:

>db.runCommand({"convertToCapped":"posts",size:10000})

以上代码我们已存在?posts 集合转换为固定集合?/p>


固定集合查询

固定集合文档按照插入序储存?默认情况下查询就是按照插入顺序返回的,也可以?natural调整q回序?/p>

>db.cappedLogCollection.find().sort({$natural:-1})

固定集合的功能特?/h2>

可以插入及更?但更C能超出collection的大?否则更新p|,不允许删?但是可以调用drop()删除集合中的所有行,但是drop后需要显式地重徏集合?/p>

?2位机子上一个cappped collection的最大值约?82.5M,64位上只受pȝ文g大小的限制?/p>


固定集合属性及用法

属?/h3>
  • 属?:对固定集合进行插入速度极快
  • 属?:按照插入序的查询输出速度极快
  • 属?:能够在插入最新数据时,淘汰最早的数据

用法

  • 用法1:储存日志信息
  • 用法2:~存一些少量的文档


paulwong 2015-12-09 14:41 发表评论
]]>
MongoDB 聚合http://www.aygfsteel.com/paulwong/archive/2015/12/08/428558.htmlpaulwongpaulwongTue, 08 Dec 2015 02:44:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/12/08/428558.htmlhttp://www.aygfsteel.com/paulwong/comments/428558.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/12/08/428558.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/428558.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/428558.htmlhttp://www.runoob.com/mongodb/mongodb-aggregate.html
MongoDB中聚?aggregate)主要用于处理数据(诸如l计q_?求和{?Qƈq回计算后的数据l果。有点类似sql语句中的 count(*)?/p>

aggregate() Ҏ

MongoDB中聚合的Ҏ使用aggregate()?/p>

语法

aggregate() Ҏ的基本语法格式如下所C:

>db.COLLECTION_NAME.aggregate(AGGREGATE_OPERATION)

实例

集合中的数据如下Q?/p>

{    _id: ObjectId(7df78ad8902c)    title: 'MongoDB Overview',     description: 'MongoDB is no sql database',    by_user: 'w3cschool.cc',    url: 'http://www.w3cschool.cc',    tags: ['mongodb', 'database', 'NoSQL'],    likes: 100 }, {    _id: ObjectId(7df78ad8902d)    title: 'NoSQL Overview',     description: 'No sql database is very fast',    by_user: 'w3cschool.cc',    url: 'http://www.w3cschool.cc',    tags: ['mongodb', 'database', 'NoSQL'],    likes: 10 }, {    _id: ObjectId(7df78ad8902e)    title: 'Neo4j Overview',     description: 'Neo4j is no sql database',    by_user: 'Neo4j',    url: 'http://www.neo4j.com',    tags: ['neo4j', 'database', 'NoSQL'],    likes: 750 },

现在我们通过以上集合计算每个作者所写的文章敎ͼ使用aggregate()计算l果如下Q?/p>

> db.mycol.aggregate([{$group : {_id : "$by_user", num_tutorial : {$sum : 1}}}]) { "result" : [ { "_id" : "w3cschool.cc", "num_tutorial" : 2 }, { "_id" : "Neo4j", "num_tutorial" : 1 } ], "ok" : 1 } >

以上实例cMsql语句Q?em style="border: 0px; margin: 0px; padding: 0px;"> select by_user, count(*) from mycol group by by_user

在上面的例子中,我们通过字段by_user字段Ҏ据进行分l,q计by_user字段相同值的d?/p>

下表展示了一些聚合的表达?

表达?/th>描述实例
$sum计算d?/td>db.mycol.aggregate([{$group : {_id : "$by_user", num_tutorial : {$sum : "$likes"}}}])
$avg计算q_?/td>db.mycol.aggregate([{$group : {_id : "$by_user", num_tutorial : {$avg : "$likes"}}}])
$min获取集合中所有文对应值得最倹{?/td>db.mycol.aggregate([{$group : {_id : "$by_user", num_tutorial : {$min : "$likes"}}}])
$max获取集合中所有文对应值得最大倹{?/td>db.mycol.aggregate([{$group : {_id : "$by_user", num_tutorial : {$max : "$likes"}}}])
$push在结果文档中插入值到一个数l中?/td>db.mycol.aggregate([{$group : {_id : "$by_user", url : {$push: "$url"}}}])
$addToSet在结果文中插入值到一个数l中Q但不创建副本?/td>db.mycol.aggregate([{$group : {_id : "$by_user", url : {$addToSet : "$url"}}}])
$firstҎ资源文的排序获取第一个文数据?/td>db.mycol.aggregate([{$group : {_id : "$by_user", first_url : {$first : "$url"}}}])
$lastҎ资源文档的排序获取最后一个文数?/td>db.mycol.aggregate([{$group : {_id : "$by_user", last_url : {$last : "$url"}}}])

道的概?/h2>

道在Unix和Linux中一般用于将当前命o的输出结果作Z一个命令的参数?/p>

MongoDB的聚合管道将MongoDB文在一个管道处理完毕后结果传递给下一个管道处理。管道操作是可以重复的?/p>

表达式:处理输入文q输出。表辑ּ是无状态的Q只能用于计当前聚合管道的文档Q不能处理其它的文?/p>

q里我们介绍一下聚合框架中常用的几个操作:

  • $projectQ修改输入文的l构。可以用来重命名、增加或删除域,也可以用于创结果以及嵌套文档?/li>
  • $matchQ用于过滤数据,只输出符合条件的文?match使用MongoDB的标准查询操作?/li>
  • $limitQ用来限制MongoDB聚合道q回的文数?/li>
  • $skipQ在聚合道中蟩q指定数量的文Qƈq回余下的文?/li>
  • $unwindQ将文中的某一个数l类型字D|分成多条Q每条包含数l中的一个倹{?/li>
  • $groupQ将集合中的文档分组Q可用于l计l果?/li>
  • $sortQ将输入文排序后输出?/li>
  • $geoNearQ输出接q某一地理位置的有序文?/li>

道操作W实?/h3>

1?project实例

db.article.aggregate( { $project : {         title : 1 ,         author : 1 , }} );

q样的话l果中就只还有_id,tilte和author三个字段了,默认情况下_id字段是被包含的,如果要想不包含_id话可以这?

db.article.aggregate( { $project : {         _id : 0 ,         title : 1 ,         author : 1 }});

2.$match实例

db.articles.aggregate( [ { $match : { score : { $gt : 70, $lte : 90 } } }, { $group: { _id: null, count: { $sum: 1 } } } ] );

$match用于获取分数大于70于或等?0记录Q然后将W合条g的记录送到下一阶段$group道操作W进行处理?/p>

3.$skip实例

db.article.aggregate( { $skip : 5 }); 

l过$skip道操作W处理后Q前五个文?qo"掉?/p>

paulwong 2015-12-08 10:44 发表评论
]]>mongodbq维之副本集实践http://www.aygfsteel.com/paulwong/archive/2015/06/30/425955.htmlpaulwongpaulwongTue, 30 Jun 2015 02:30:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/06/30/425955.htmlhttp://www.aygfsteel.com/paulwong/comments/425955.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/06/30/425955.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/425955.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/425955.html阅读全文

paulwong 2015-06-30 10:30 发表评论
]]>
MONGODB优化资源http://www.aygfsteel.com/paulwong/archive/2015/05/05/424867.htmlpaulwongpaulwongTue, 05 May 2015 09:32:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/05/05/424867.htmlhttp://www.aygfsteel.com/paulwong/comments/424867.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/05/05/424867.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/424867.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/424867.htmlhttp://database.51cto.com/art/201309/411076.htm

Do you want a timeout?
http://blog.mongolab.com/2013/10/do-you-want-a-timeout/


MongoDB 查询时异常的原因及解决办法
http://database.51cto.com/art/201503/467581.htm


Mongoq接池操作MongoOptions
http://dawn-sky.iteye.com/blog/1343659




paulwong 2015-05-05 17:32 发表评论
]]>
MONGODB常用命ohttp://www.aygfsteel.com/paulwong/archive/2015/04/15/424445.htmlpaulwongpaulwongWed, 15 Apr 2015 09:39:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/04/15/424445.htmlhttp://www.aygfsteel.com/paulwong/comments/424445.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/04/15/424445.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/424445.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/424445.html
启动Q?/span>
mongod --config /usr/local/mongodb/conf/cms.conf

关闭Q?/span>
ps -ef | grep mongo (查PID)
kill -15 pid

修复Q?/span>
rm /data/mongodb/mongod.lock
mongod --dbpath /data/mongodb --repair
mongod --config /usr/local/mongodb/conf/cms.conf

q入命o模式Q?/span>
mongo admin -u root -p cloudDB

查看服务器连接数Q?/span>
db.serverStatus().connections

查看版本Q?/span>
db.runCommand({"buildInfo":1})  

查看l计Q?/span>
mongostat -u root -p cloudDB

备䆾数据Q?/span>
mongodump -u cms -p cms -d cms -o /data/dump/cms

恢复数据Q?/span>
mongorestore -u cms -p cms -d cms /data/dump/cms



paulwong 2015-04-15 17:39 发表评论
]]>几大NOSQL数据库性能比较http://www.aygfsteel.com/paulwong/archive/2015/01/30/422565.htmlpaulwongpaulwongThu, 29 Jan 2015 16:16:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/01/30/422565.htmlhttp://www.aygfsteel.com/paulwong/comments/422565.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/01/30/422565.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/422565.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/422565.htmlhttp://planetcassandra.org/nosql-performance-benchmarks

NoSQL Benchmarking
http://www.cubrid.org/blog/dev-platform/nosql-benchmarking/


http://www.badrit.com/blog/2013/11/18/redis-vs-mongodb-performance#.VMpfW2SUfsg

How many requests per second can I get out of Redis?
http://skipperkongen.dk/2013/08/27/how-many-requests-per-second-can-i-get-out-of-redis/

redis性能试Q测试ƈ发性能
http://my.oschina.net/pblack/blog/102394

paulwong 2015-01-30 00:16 发表评论
]]>
Mongodb 查询性能的事?/title><link>http://www.aygfsteel.com/paulwong/archive/2015/01/06/422096.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Tue, 06 Jan 2015 15:39:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2015/01/06/422096.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/422096.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2015/01/06/422096.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/422096.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/422096.html</trackback:ping><description><![CDATA[上一:Mongodb VS Mysql 查询性能Q测试了 mongodb ?mysql 的查询性能。结果说?mongodb 性能可以Q?可以代替 mysql 来用?br /><br />但是q个试都是在百万别,我的场景?KW U别。所以还要对 mongodb ?kw U别下测试效果?br /><br />我测试环境是 4G 内存Q有好些内存被其它程序占用)Q?kw 数据Q查询随机生?idQ一ơ查?20 个idQ?br /><br />在这L环境中测试不理想Q比较失望。^均一ơ查?500msQ比 mysql q差Q特别是在ƈ发查询下Q性能较差。很底的吞吐量)。查看其索引大小Q用 db.mycoll.stats() 可以查询Q:2kw 数据中有 1.1G 左右的烦引,存储的数据在 11G 左右?br /><br />试q程中发?iowait ?50% 左右Q看来还?io 的瓶颈。还看到 mongodb 使用的内存不多(于索引的大,看来q机器不_来测试)?br /><br />换了个有可用 6G 内存的机器。在 50 个ƈ发下Q可以达到^?100 ms 左右Q算比较满意Q但是ƈ发好像能力不够强。但q个性能不能由我控制Q还由机器的可用内存控制。原因就?mongodb 没有指定可占用的内存大小Q它把所有空闲内存当~存使用Q既是优点也是缺点:优点--可以最大限度提升性能Q缺?-Ҏ受其它程序干扎ͼ占用了它的缓存)。由我测试来看,它抢占内存的能力不强。mongodb 是用内存映射文g vmmQ官方的说明Q?br /><br />Memory Mapped Storage Engine<br /><br />This is the current storage engine for MongoDB, and it uses memory-mapped files for all disk I/O. Using this strategy, the operating system's virtual memory manager is in charge of caching. This has several implications:<br /><br />There is no redundancy between file system cache and database cache: they are one and the same.<br />MongoDB can use all free memory on the server for cache space automatically without any configuration of a cache size.<br />Virtual memory size and resident size will appear to be very large for the mongod process. This is benign: virtual memory space will be just larger than the size of the datafiles open and mapped; resident size will vary depending on the amount of memory not used by other processes on the machine.<br />Caching behavior (such as LRU'ing out of pages, and laziness of page writes) is controlled by the operating system: quality of the VMM implementation will vary by OS.<br />所以这么来看,我觉?mongodb 没有指定内存大小来保证正常的~存是个~点。应该至保证烦引全部能攑ֈ内存中。但q个行ؓ不是由启动程序决定,而是q境决定(中不Q?br /><br />官方也有D内容说到烦引放到内存中Q?br /><br />If your queries seem sluggish, you should verify that your indexes are small enough to fit in RAM. For instance, if you're running on 4GB RAM and you have 3GB of indexes, then your indexes probably aren't fitting in RAM. You may need to add RAM and/or verify that all the indexes you've created are actually being used.<br /><br />q是希望 mongodb 中可以指定内存大,保它有_内存加蝲索引?br /><br />结Q大数据量下QkwU)mongodb q发查询不够理想Q?00-200/sQ。写数据很快Q我的环境,q程提交q?1w/sQ估计达?1.5W/s 是没问题的,基本不受大数据量的媄响)?br /><br />贴个试数据Q?br /><br />1 id(内存使用 <1.5g) 10 id(内存使用 2-3g) 20 id(内存使用 >4g)<br />1 2 3 1 2 3 1 2 3<br />total time 17.136 25.508 17.387 37.138 33.788 25.143 44.75 31.167 30.678<br />1 thread thruput 583.5668 392.0339 575.1423 269.266 295.9631 397.725 223.4637 320.8522 325.9665<br />total time 24.405 22.664 24.115 41.454 41.889 39.749 56.138 53.713 54.666<br />5 thread thruput 2048.76 2206.142 2073.398 1206.156 1193.631 1257.893 890.6623 930.8733 914.6453<br />total time 27.567 26.867 28.349 55.672 54.347 50.93 72.978 81.857 75.925<br />10 thread thruput 3627.526 3722.038 3527.461 1796.235 1840.028 1963.479 1370.276 1221.643 1317.089<br />total time 51.397 57.446 53.81 119.386 118.015 76.405 188.962 188.034 138.839<br />20 thread thruput 3891.278 3481.53 3716.781 1675.238 1694.7 2617.63 1058.414 1063.637 1440.517<br />total time 160.038 160.808 160.346 343.559 352.732 460.678 610.907 609.986 1411.306<br />50 thread thruput 3124.258 3109.298 3118.257 1455.354 1417.507 1085.357 818.4552 819.6909 354.2818<br />total time 2165.408 635.887 592.958 1090.264 1034.057 1060.266 1432.296 1466.971 1475.061<br />100 thread thruput 461.8067 1572.606 1686.46 917.209 967.0647 943.1595 698.1797 681.6767 677.9381<br />上面的测试分别用三种查询Q每?1,10,20 idQ,在不同ƈ发下试3ơ,每次发出 1w ơ查询。第一行数据ؓ所有线E篏加时_单位 msQ,W二行数据ؓ吞吐?1w /(total time / thread num))。测试中内存使用慢慢增加Q所以后面的数据可能比较高效的(高效的环境)?br /><br />从上表看Q?0 - 20U程比较高的吞吐量。看到内存用,前提是索引加蝲到内存中Qƈ有些内存作ؓ~存?br /><br />下面有个索引查询优化?pdf?br /><br />Indexing and Query Optimizer<br /><br />Indexing and Query Optimizer (Aaron Staple)<br />ps:<br /><br />默认 mongodb 服务器只?0个ƈ发,如果要提高它的连接数Q可以用 --maxConns num 来提高它的接收ƈ发的数据?br /><br />mongodb ?java 驱动默认最多只?10 q发q接池。要提高它,可以?mongo.jar 的环境中加入 MONGO.POOLSIZE pȝ参数Q如 java -DMONGO.POOLSIZE=50 ...<img src ="http://www.aygfsteel.com/paulwong/aggbug/422096.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2015-01-06 23:39 <a href="http://www.aygfsteel.com/paulwong/archive/2015/01/06/422096.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于MongoDB最大连接数的查看与修改http://www.aygfsteel.com/paulwong/archive/2015/01/06/422093.htmlpaulwongpaulwongTue, 06 Jan 2015 14:10:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/01/06/422093.htmlhttp://www.aygfsteel.com/paulwong/comments/422093.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/01/06/422093.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/422093.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/422093.html
[root@DELL113 mongodb-linux-i686-2.4.1]# mongo admin -u root -p password
MongoDB shell version: 2.4.1
connecting to: 192.168.6.42/admin
> db.serverStatus().connections
{ "current" : 1, "available" : 818, "totalCreated" : NumberLong(1) }

途中available昄818了一个,表示I闲的。current表示已经占用了的q接敎ͼ两数一加就{于819Q如果我现在在连接一个,那么available是817Qcurrent是2

[root@DELL113 mongodb-linux-i686-2.4.1]# ./bin/mongo 192.168.6.42
MongoDB shell version: 2.4.1
connecting to: 192.168.6.42/test
> db.serverStatus().connections
"current" : 1, "available" : 818, "totalCreated" : NumberLong(1) }
> db.serverStatus().connections
"current" : 2, "available" : 817, "totalCreated" : NumberLong(2) }

819个连接数对于一般的站点我认为已l够用,q且都是现连现取现断。但q个q接C可以修改Q只要在启动的时候加?-maxConns卛_
服务器启?br />
[root@lee mongodb-linux-x86_64-2.4.1]# ./bin/mongod --dbpath=/root/db --maxConns=2000
Wed Apr 3 11:06:21.905 [initandlisten] MongoDB starting : pid=2812 port=27017 dbpath=/root/db 64-bit host=lee
Wed Apr 3 11:06:21.957 [initandlisten] db version v2.4.1
Wed Apr 3 11:06:21.957 [initandlisten] git version: 1560959e9ce11a693be8b4d0d160d633eee75110
Wed Apr 3 11:06:21.957 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Wed Apr 3 11:06:21.957 [initandlisten] allocator: tcmalloc
Wed Apr 3 11:06:21.957 [initandlisten] options: { dbpath: "/root/db", maxConns: 2000 }
Wed Apr 3 11:06:21.982 [initandlisten] journal dir=/root/db/journal
Wed Apr 3 11:06:21.982 [initandlisten] recover : no journal files present, no recovery needed
Wed Apr 3 11:06:22.297 [initandlisten] preallocateIsFaster=true 2.62
Wed Apr 3 11:06:22.717 [initandlisten] --maxConns too high, can only handle 819
Wed Apr 3 11:06:22.724 [initandlisten] waiting for connections on port 27017
Wed Apr 3 11:06:22.725 [websvr] admin web console waiting for connections on port 28017
Wed Apr 3 11:06:25.126 [initandlisten] connection accepted from 192.168.4.86:53917 #1 (1 connection now open)

查询最大连接数

[root@DELL113 mongodb-linux-i686-2.4.1]# ./bin/mongo 192.168.6.42
MongoDB shell version: 2.4.1
connecting to: 192.168.6.42/test
> db.serverStatus().connections
"current" : 1, "available" : 818, "totalCreated" : NumberLong(1) }

发现q是819Q其实是Linux默认q程能打开最大文件数有关Q可以通过ulimit 解决

[root@lee mongodb-linux-x86_64-2.4.1]# ulimit -n 2500
[root@lee mongodb-linux-x86_64-2.4.1]# ./bin/mongod --dbpath=/root/db --maxConns=2000
Wed Apr 3 11:11:07.013 [initandlisten] MongoDB starting : pid=2930 port=27017 dbpath=/root/db 64-bit host=lee
Wed Apr 3 11:11:07.013 [initandlisten] db version v2.4.1
Wed Apr 3 11:11:07.013 [initandlisten] git version: 1560959e9ce11a693be8b4d0d160d633eee75110
Wed Apr 3 11:11:07.013 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Wed Apr 3 11:11:07.013 [initandlisten] allocator: tcmalloc
Wed Apr 3 11:11:07.013 [initandlisten] options: { dbpath: "/root/db", maxConns: 2000 }
Wed Apr 3 11:11:07.031 [initandlisten] journal dir=/root/db/journal
Wed Apr 3 11:11:07.031 [initandlisten] recover : no journal files present, no recovery needed
Wed Apr 3 11:11:07.170 [initandlisten] waiting for connections on port 27017
Wed Apr 3 11:11:07.171 [websvr] admin web console waiting for connections on port 28017
Wed Apr 3 11:11:10.076 [initandlisten] connection accepted from 192.168.4.86:53161 #1 (1 connection now open)

再查看最大连接数Q搞?br />
[root@DELL113 mongodb-linux-i686-2.4.1]# ./bin/mongo 192.168.6.42
MongoDB shell version: 2.4.1
connecting to: 192.168.6.42/test
> db.serverStatus().connections
"current" : 1, "available" : 1999, "totalCreated" : NumberLong(1) }

关于ulimit的更多知识大家可以去|上索检?br />
客户端程序通常是通过DRIVER来链接,׃每次建立链接的成本都挺高Q因此都用链接池来实玎ͼSPRING DATA MONGODB中是如下配置
mongo.dbname=cms
#U程池的大小
mongo.connectionsPerHost=100
#q个*mongo.connectionsPerHost则是如果链接数大?00的等待xttk?/span>
mongo.threadsAllowedToBlockForConnectionMultiplier=4
#{待U程的等待时?/span>
mongo.maxWaitTime=1500
mongo.socketTimeout=1500
mongo.connectTimeout=1000
mongo.autoConnectRetry=true
mongo.socketKeepAlive=true
mongo.slaveOk=true


  • autoConnectRetry simply means the driver will automatically attempt to reconnect to the server(s) after unexpected disconnects. In production environments you usually want this set to true.

  • connectionsPerHost are the amount of physical connections a single Mongo instance (it's singleton so you usually have one per application) can establish to a mongod/mongos process. At time of writing the java driver will establish this amount of connections eventually even if the actual query throughput is low (in order words you will see the "conn" statistic in mongostat rise until it hits this number per app server).

    There is no need to set this higher than 100 in most cases but this setting is one of those "test it and see" things. Do note that you will have to make sure you set this low enough so that the total amount of connections to your server do not exceed

    db.serverStatus().connections.available

    In production we currently have this at 40.

  • connectTimeout. As the name suggest number of milliseconds the driver will wait before a connection attempt is aborted. Set timeout to something long (15-30 seconds) unless there's a realistic, expected chance this will be in the way of otherwise succesful connection attempts. Normally if a connection attempt takes longer than a couple of seconds your network infrastructure isn't capable of high throughput.

  • maxWaitTime. Number of ms a thread will wait for a connection to become available on the connection pool, and raises an exception if this does not happen in time. Keep default.

  • socketTimeout. Standard socket timeout value. Set to 60 seconds (60000).

  • threadsAllowedToBlockForConnectionMultiplier. Multiplier for connectionsPerHost that denotes the number of threads that are allowed to wait for connections to become available if the pool is currently exhausted. This is the setting that will cause the "com.mongodb.DBPortPool$SemaphoresOut: Out of semaphores to get db connection" exception. It will throw this exception once this thread queue exceeds the threadsAllowedToBlockForConnectionMultiplier value. For example, if the connectionsPerHost is 10 and this value is 5 up to 50 threads can block before the aforementioned exception is thrown.

    If you expect big peaks in throughput that could cause large queues temporarily increase this value. We have it at 1500 at the moment for exactly that reason. If your query load consistently outpaces the server you should just improve your hardware/scaling situation accordingly.

  • readPreference(UPDATED, 2.8+) Used to determine the default read preference and replaces "slaveOk". Set up a ReadPreference through one of the class factory method. A full description of the most common settings can be found at the end of this post

  • w(UPDATED, 2.6+) This value determines the "safety" of the write. When this value is -1 the write will not report any errors regardless of network or database errors. WriteConcern.NONE is the appropriate predefined WriteConcern for this. If w is 0 then network errors will make the write fail but mongo errors will not. This is typically referred to as "fire and forget" writes and should be used when performance is more important than consistency and durability. Use WriteConcern.NORMAL for this mode.

    If you set w to 1 or higher the write is considered safe. Safe writes perform the write and follow it up by a request to the server to make sure the write succeeded or retrieve an error value if it did not (in other words, it sends a getLastError() command after you write). Note that until this getLastError() command is completed the connection is reserved. As a result of that and the additional command the throughput will be signficantly lower than writes with w <= 0. With a w value of exactly 1 MongoDB guarantees the write succeeded (or verifiably failed) on the instance you sent the write to.

    In the case of replica sets you can use higher values for w whcih tell MongoDB to send the write to at least "w" members of the replica set before returning (or more accurately, wait for the replication of your write to "w" members). You can also set w to the string "majority" which tells MongoDB to perform the write to the majority of replica set members (WriteConcern.MAJORITY). Typicall you should set this to 1 unless you need raw performance (-1 or 0) or replicated writes (>1). Values higher than 1 have a considerable impact on write throughput.

  • fsync. Durability option that forces mongo to flush to disk after each write when enabled. I've never had any durability issues related to a write backlog so we have this on false (the default) in production.

  • j *(NEW 2.7+)*. Boolean that when set to true forces MongoDB to wait for a successful journaling group commit before returning. If you have journaling enabled you can enable this for additional durability. Refer to http://www.mongodb.org/display/DOCS/Journaling to see what journaling gets you (and thus why you might want to enable this flag).

ReadPreference The ReadPreference class allows you to configure to what mongod instances queries are routed if you are working with replica sets. The following options are available :

  • ReadPreference.primary() : All reads go to the repset primary member only. Use this if you require all queries to return consistent (the most recently written) data. This is the default.

  • ReadPreference.primaryPreferred() : All reads go to the repset primary member if possible but may query secondary members if the primary node is not available. As such if the primary becomes unavailable reads become eventually consistent, but only if the primary is unavailable.

  • ReadPreference.secondary() : All reads go to secondary repset members and the primary member is used for writes only. Use this only if you can live with eventually consistent reads. Additional repset members can be used to scale up read performance although there are limits to the amount of (voting) members a repset can have.

  • ReadPreference.secondaryPreferred() : All reads go to secondary repset members if any of them are available. The primary member is used exclusively for writes unless all secondary members become unavailable. Other than the fallback to the primary member for reads this is the same as ReadPreference.secondary().

  • ReadPreference.nearest() : Reads go to the nearest repset member available to the database client. Use only if eventually consistent reads are acceptable. The nearest member is the member with the lowest latency between the client and the various repset members. Since busy members will eventually have higher latencies this should also automatically balance read load although in my experience secondary(Preferred) seems to do so better if member latencies are relatively consistent.

Note : All of the above have tag enabled versions of the same method which return TaggableReadPreference instances instead. A full description of replica set tags can be found here :Replica Set Tags



参考网址Q?br />http://api.mongodb.org/java/2.10.1/com/mongodb/MongoClientOptions.Builder.html#connectionsPerHost(int)
https://github.com/spring-projects/spring-data-mongodb/blob/master/spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.5.xsd

paulwong 2015-01-06 22:10 发表评论
]]>
Architecture for Redis cache & Mongo for persistencehttp://www.aygfsteel.com/paulwong/archive/2015/01/04/422026.htmlpaulwongpaulwongSun, 04 Jan 2015 07:50:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/01/04/422026.htmlhttp://www.aygfsteel.com/paulwong/comments/422026.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/01/04/422026.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/422026.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/422026.htmlhttp://www.javacodegeeks.com/2013/02/caching-with-spring-data-redis.html

Architecture for Redis cache & Mongo for persistence
http://stackoverflow.com/questions/11218941/architecture-for-redis-cache-mongo-for-persistence

MongoDB with redis
http://stackoverflow.com/questions/10696463/mongodb-with-redis/10721249#10721249

Caching Data in Spring Using Redis
http://caseyscarborough.com/blog/2014/12/18/caching-data-in-spring-using-redis/

Springside Redis
https://github.com/springside/springside4/wiki/Redis

Spring Cache注解+Redis
http://hanqunfeng.iteye.com/blog/2176172















paulwong 2015-01-04 15:50 发表评论
]]>
վ֩ģ壺 ɽ| | | | Т| | ɽ| ֶ| ˾| ͨɽ| | Dz| | ɽ| | | ˶| | | | | ɽ| | | | ͨ| | | | | Ƥ| ֦| ɽ| ̨| | ɳ| | | | | ƽ|