目前我们运行的MongoDB Replicaset包含2个Server + 1 Arbiter.
我们在replicaset的数据库中存储了大约150 GB的数据.
现在我们正在考虑何时开始分片.因为我们想知道是否有一个点无法再开始分片.
很明显,我们必须在硬盘空间耗尽之前开始分片,因为内存太少,我们的CPU过载或整体性能下降.
有人还告诉我,有256 GB的数据大小限制,之后你就不能再开始分片了.我也看了官方文档http://docs.mongodb.org/manual/sharding/和"MongoDB的权威指南",我不能说坡口.
根据您的经验,您应该从哪里开始进行分片?
我想通过API Gateway提供我的lambda微服务,这似乎不是一个大问题.
我的每个微服务都有一个提供的资源的JSON-Schema规范.因为它是一个静态文件,所以我想从S3 Bucket中提供它,而不是运行lambda函数来提供它.
所以虽然
GET,POST,PUT,DELETE http://api.domain.com/ressources
Run Code Online (Sandbox Code Playgroud)
应转发给lambda函数.我想要
GET http://api.domain.com/ressources/schema
Run Code Online (Sandbox Code Playgroud)
从S3提供我的schema.json.
我天真的第一种方法是为"/ v1/contracts/schema - GET - Integration Request"设置资源和方法,并将其配置为HTTP代理,端点url直接指向契约JSON-Schema.我收到500 - 内部服务器错误.
Execution log for request test-request
Fri Nov 27 09:24:02 UTC 2015 : Starting execution for request: test-invoke-request
Fri Nov 27 09:24:02 UTC 2015 : API Key: test-invoke-api-key
Fri Nov 27 09:24:02 UTC 2015 : Method request path: {}
Fri Nov 27 09:24:02 UTC 2015 : Method request query string: {}
Fri Nov 27 09:24:02 UTC 2015 : Method request headers: …Run Code Online (Sandbox Code Playgroud) 从在 stackoverflow 上找到的几篇文章中,我创建了这段代码。
设想
我想要一个 multiprocessing.queue 几个工人“听”
在键盘中断的情况下,主进程不应再将新项目放入队列中,并且在哨兵对象的帮助下,应该优雅地停止工作进程。
问题
我使用的当前版本的问题
signal.signal(signal.SIGINT, signal.SIG_IGN)
Run Code Online (Sandbox Code Playgroud)
忽略 Ctrl + C 就是它也被主进程忽略了。
有任何想法吗 ?我需要使用多处理工作池吗?一些例子表明我可能不得不这样做。那我还可以使用队列吗?
from multiprocessing import Pool, Process,Queue
import time
import signal
# http://docs.python.org/3.1/library/multiprocessing.html#multiprocessing.Queue
# http://docs.python.org/3.1/library/multiprocessing.html#multiprocessing.Process
class Worker(Process):
def __init__(self, queue,ident):
super(Worker, self).__init__()
# Ignore Signals
signal.signal(signal.SIGINT, signal.SIG_IGN)
self.queue= queue
self.idstr= str(ident)
print "Ident" + self.idstr
def run(self):
print 'Worker started'
# do some initialization here
print 'Computing things!'
for data in iter( self.queue.get, None ):
print "#" + self.idstr + " : " …Run Code Online (Sandbox Code Playgroud) 我想获得不存在字段下载的所有文档
find{ "download" : {$exists: false}}
Run Code Online (Sandbox Code Playgroud)
对于Java,我找到了一个例子:
BasicDBObject neQuery = new BasicDBObject();
neQuery.put("number", new BasicDBObject("$ne", 4));
DBCursor cursor = collection.find(neQuery);
while(cursor.hasNext()) {
System.out.println(cursor.next());
}
Run Code Online (Sandbox Code Playgroud)
我的改编是
BasicDBObject field = new BasicDBObject();
field.put("entities.media", 1);
field.put("download", new BasicDBObject("$exists",false));
System.out.println("Start Find");
DBCursor cursor = collection.find(query,field);
System.out.println("End Find Start Loop ALL 100k");
int i = 1;
while(cursor.hasNext())
Run Code Online (Sandbox Code Playgroud)
存在线不起作用:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: com.mongodb.MongoException: Unsupported projection option: $exists
at com.mongodb.MongoException.parse(MongoException.java:82)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:314) …Run Code Online (Sandbox Code Playgroud) 我想使用JQuery Validation Engine插件来查看动态添加的隐藏输入字段.
提交表单时,必须至少有一个这样的字段.
它尝试使用groupRequired Validator实现此目的
http://posabsolute.github.com/jQuery-Validation-Engine/#validators/grouprequired
<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css"/>
<script>
$(document).ready(function(){
$("#tagform").validationEngine();
});
</script>
<form id="tagform">
<input type="hidden" name="tags" id="tags-input" />
<input type="hidden" name="inc" value="locate">
<input type="hidden" class="validate[groupRequired[tagitem]]" name="validation">
<br><br>
<input type="submit" value="Save Tags">
</form>
Run Code Online (Sandbox Code Playgroud)
添加字段看起来像:
var formhtml ='<input type="hidden" name="tags[]" class="validate[groupRequired[tagitem]]" id="id'+itemid+'" parenttag="'+parent+'" value="'+itemid+'">';
$("#tagform").append(formhtml);
Run Code Online (Sandbox Code Playgroud)
目前它根本不检查隐藏的字段.
任何想法如何解决这个或另一种方法?
解决方法
使用简单的javaskript onSubmit函数来检查标记的出现
function checkForm(form)
{
var count = $('input[name="tags[]"]').length;
if(count == 0 ) {
alert("Select at least one tag");
return false;
}
alert ("Count " + count)
return true; …Run Code Online (Sandbox Code Playgroud) 我试着在一段时间内得到所有的日子.无论是一整天还是几个小时都没关系.我使用DatePeriod的当前代码对我不起作用.
例:
[start] => DateTime Object
(
[date] => 2014-01-27 22:40:40
[timezone_type] => 1
[timezone] => +00:00
)
[end] => DateTime Object
(
[date] => 2014-01-28 17:40:40
[timezone_type] => 1
[timezone] => +00:00
)
$interval = new DateInterval('P1D'); // 1Day Interval
$daterange = new DatePeriod($time['start'], $interval ,$time['end']);
$return['days'] = array();
foreach($daterange as $date){
$return['days'][] = $date->format("Y-m-d");
}
Run Code Online (Sandbox Code Playgroud)
我想得到
[0] => 2014-01-27
[1] => 2014-01-28
Run Code Online (Sandbox Code Playgroud)
但我只得到了
[0] => 2014-01-27
Run Code Online (Sandbox Code Playgroud)
是否可以更改DatePeriod参数或其他内容?
我的情况类似于PHP shell_exec 使用 ssh 运行 shellscript,但不一样。
情况:我在两台服务器之间交换了 ssh 密钥,切换到www-data用户并通过 SSH 连接到第二台服务器,无需密码。
测试 1:ssh user@10.8.0.6 Documents/run.sh list 在 shell 中执行时工作正常
测试 2:将简单的 PHP Exec 放入 PHP 文件中效果很好。它返回一个数组并且Retval为0
测试 3:将 exec 放入“大”PHP 脚本中并调用它会导致 Retval 255(致命错误?!?!?)
所以目前我真的不明白为什么它不起作用。我试图找出有关 retval 255 的更多详细信息,但没有走得太远。
PHP5 与 PHP5 cli 之间的差异一定存在于某个地方。但在我不得不使用 OpenVPN 之前,它通过正常的 Apache 调用也可以正常工作。