电脑版 为什么打不开

日志数据是选择mysql 还是 mongodb 还是 postgredb
你好,想跟你请教个问题:
我是做游戏服务器的, 目前我的游戏服饰部署在阿里云上面的,现在我们要将玩家操作日志和一些重要的日志分析入库。 日志服务器获取的日志服务器是json格式, 将这些json格式的日志分析入库,以便运营分析。现在面临的问题就是选择那个数据库:&
mysql: 监控的日志字段变化大,如果采用关系型数据库则冗余字段叫多,而且当数据量很大不易扩展
mongodb:可以直接存储json, 问题在阿里云不支持, 需要自己搞个云服务器搭建,
postgredb: 我只知道这个数据库最新版本支持nosql, 网上还有有测评显示各方面新能比mongodb好, 而且阿里云支持,但不知道这个中数据库使用的场景。
希望你能帮我分析一下,选择那个数据库? 还有你了解个阿里云的OTS? 如果选择这个又怎么样?
日志字段变化大,还是使用nosql更合适,如果量不是特别特别大,可以用mongodb的,目前据我所知只有青云的mongodb 3.0的服务,但它不建议外网使用,也就是,你要用我的mongo你就得用的其他server和存储,价格稍贵。
postgre的benchmark我没看过,不做评论
如果特别大的话,hbase存储 +&elasticsearch搜索,会比较好一些MongoDB日志过大怎么办?
来源:博客园
MongoDB 日志文件过大怎么办? MongoDB的日志文件在设置 logappend=true 的情况下,会不断向同一日志文件追加的,时间长了,自然变得非常大。 解决如下:(特别注意:启动的时候必须是--logpath指定了log路径的) 用mongo连接到服务端 use admin
//切换到admin数据库 db.runCommand({logRotate:1}) 这样会使mongo关闭当前日志文件,重启一个新的日志文件,不需要停止mongodb服务。
免责声明:本站部分内容、图片、文字、视频等来自于互联网,仅供大家学习与交流。相关内容如涉嫌侵犯您的知识产权或其他合法权益,请向本站发送有效通知,我们会及时处理。反馈邮箱&&&&。
学生服务号
在线咨询,奖学金返现,名师点评,等你来互动查看: 2694|回复: 13
看MongoDB的日志是怎么工作的
认证徽章论坛徽章:277
I was working on a section on the gooey innards of journaling for The Definitive Guide, but then I realized it’s an implementation detail that most people won’t care about. However, I had all of these nice diagrams just laying around.
patrick.jpg (72.07 KB, 下载次数: 2)
17:47 上传
Good idea, Patrick!
mapfile.png (11.05 KB, 下载次数: 2)
17:47 上传
So, how does journaling work? Your disk has your data files and your journal files, which we’ll represent like this:
认证徽章论坛徽章:277
When you start up mongod, it maps your data files to a shared view. Basically, the operating system says: “Okay, your data file is 2,000 bytes on disk. I’ll map that to memory address 1,000,000-1,002,000. So, if you read the memory at memory address 1,000,042, you’ll be getting the 42nd byte of the file.” (Also, the data won’t necessary be loaded until you actually access that memory.)
to_shared.png (16.1 KB, 下载次数: 2)
17:48 上传
认证徽章论坛徽章:277
This memory is still backed by the file: if you make changes in memory, the operating system will flush these changes to the underlying file. This is basically how mongod works without journaling: it asks the operating system to flush in-memory changes every 60 seconds.
However, with journaling, mongod makes a second mapping, this one to a private view. Incidentally, this is why enabling journalling doubles the amount of virtual memory mongod uses.
to_private.png (19.21 KB, 下载次数: 2)
17:49 上传
认证徽章论坛徽章:277
Note that the private view is not connected to the data file, so the operating system cannot flush any changes from the private view to disk.
Now, when you do a write, mongod writes this to the private view.
write.png (20.75 KB, 下载次数: 4)
17:50 上传
认证徽章论坛徽章:277
mongod will then write this change to the journal file, creating a little description of which bytes in which file changed.
journaling.png (22.2 KB, 下载次数: 2)
17:51 上传
认证徽章论坛徽章:277
The journal appends each change description it gets.
图片1.jpg (15.17 KB, 下载次数: 0)
09:57 上传
认证徽章论坛徽章:277
At this point, the write is safe. If mongod crashes, the journal can replay the change, even though it hasn’t made it to the data file yet.
The journal will then replay this change on the shared view.
图片2.jpg (17.8 KB, 下载次数: 0)
09:58 上传
认证徽章论坛徽章:277
At this point, the write is safe. If mongod crashes, the journal can replay the change, even though it hasn’t made it to the data file yet.
The journal will then replay this change on the shared view.
图片2.jpg (17.8 KB, 下载次数: 0)
09:59 上传
认证徽章论坛徽章:277
Finally, at a glacial speed compared to everything else, the shared view will be flushed to disk. By default, mongod requests that the OS do this every 60 seconds.
图片3.jpg (16.46 KB, 下载次数: 0)
09:59 上传
认证徽章论坛徽章:277
The last step is that mongod remaps the shared view to the private view. This prevents the private view from getting too “dirty” (having too many changes from the shared view it was mapped from).
图片4.jpg (16.65 KB, 下载次数: 0)
10:00 上传
itpub.net All Right Reserved. 北京皓辰网域网络信息技术有限公司版权所有    
 北京市公安局海淀分局网监中心备案编号: 广播电视节目制作经营许可证:编号(京)字第1149号查看: 2984|回复: 4
MongoDB的日志Journaling详解
认证徽章论坛徽章:277
运行MongoDB如果开启了journaling日志功能,MongoDB先在内存保存写操作,并记录journaling日志到磁盘,然后才会把数据改变刷入到磁盘上的数据文件。为了保证journal日志文件的一致性,写日志是一个原子操作。本文将讨论MongoDB中journaling日志的实现机制。
Journal日志文件
如果开启了journal日志功能,MongoDB会在数据目录下创建一个journal文件夹,用来存放预写重放日志。同时这个目录也会有一个last-sequence-number文件。如果MongoDB安全关闭的话,会自动删除此目录下的所有文件,如果是崩溃导致的关闭,不会删除日志文件。在MongoDB进程重启的过程中,journal日志文件用于自动修复数据到一个一致性的状态。
journal日志文件是一种往文件尾不停追加内容的文件,它命名以j._开头,后面接一个数字(从0开始)作为序列号。如果文件超过1G大小,MongoDB会新建一个journal文件j._1。只要MongoDB把特定日志中的所有写操作刷入到磁盘数据文件,将会删除此日志文件。因为数据已经持久化,不再需要用它来重放恢复数据了。journal日志文件一般情况下只会生成两三个,除非你每秒有大量的写操作发生。
如果你需要的话,你可以使用storage.smallFiles参数来配置journal日志文件的大小。比如配置为128M。
认证徽章论坛徽章:277
Journaling机制的存储视图
Journaling功能用到了MongoDB存储层数据集内部的两个视图。
shared视图保存数据修改操作,用于刷入到磁盘数据文件。shared视图是MongoDB中唯一访问磁盘数据文件的视图。mongod进程请求操作系统把磁盘数据文件映射到虚拟内存的shared视图。操作系统只是映射数据与内存关系,并不马上加载数据到内存。当查询需要的时候,才会加载数据到内存,即按需加载。
private视图存储用于查询操作的数据。同时private视图也是MongoDB执行写操作的第一个地方。一旦journal日志提交完成,MongoDB会复制private视图中的改变到shared视图,再通过shared视图将数据刷入到磁盘数据文件。
journal视图是一个用来保证新的写操作的磁盘视图。当MongoDB在private视图执行完写操作后,在数据刷入磁盘之前,会先记录journal日志。journal日志保证了持久性。如果mongod实例在数据刷入磁盘之前崩溃,重启过程中journal日志会重放并写入shared视图,最终刷入磁盘持久化。
认证徽章论坛徽章:277
Journaling如何纪录写操作
MongoDB采用group commits方式将写操作批量复制到journal日志文件中。group commits提交方式能够最小化journal日志机制对性能的影响。因此group commits方式在提交过程中必须阻塞所有写入。commitIntervalMs参数可以用于配置日志提交的频率,默认是100ms。
Journaling存储以下原始操作:
1. 文档插入或更新
2. 索引修改
3. 命名空间文件元数据的修改
4. 创建和者删除数据库或关联的数据文件
认证徽章论坛徽章:277
当发生写操作,MongoDB首先写入数据到内存中的private视图,然后批量复制写操作到journal日志文件。写个journal日志实体来用描述写操作改变数据文件的哪些字节。
MongoDB接下来执行journal的写操作到shared视图。此时,shared视图与磁盘数据文件不一样。
默认每60s钟,MongoDB请求操作系统将shared视图刷入到磁盘。使数据文件更新到最新的写入状态。如果系统内存资源不足的时候,操作系统会选择以更高的频率刷入shared视图到磁盘。
MongoDB刷入数据文件完成后,会通知journal日志已经刷入。一旦journal日志文件只包含全部刷入的写操作,不再用于恢复,MongoDB会将它删除或者作为一个新的日志文件再次使用。
作为journaling机制的一部分,MongoDB会例行性请求操作系统重新将shared视图映射到private视图,为了节省物理内存。一旦发生重映射,操作系统能够识别到可以在private视图和shared视图共享的内存页映射。
认证徽章论坛徽章:277
Journaling是MongoDB中非常重要的一项功能,类似于关系数据库中的事务日志。Journaling能够使MongoDB数据库由于意外故障后快速恢复。MongoDB2.0版本后默认开启了Journaling日志功能,mongod实例每次启动时都会检查journal日志文件看是否需要恢复。由于提交journal日志会产生写入阻塞,所以它对写入的操作有性能影响,但对于读没有影响。在生产环境中开启Journaling是很有必要的。
itpub.net All Right Reserved. 北京皓辰网域网络信息技术有限公司版权所有    
 北京市公安局海淀分局网监中心备案编号: 广播电视节目制作经营许可证:编号(京)字第1149号

我要回帖

 

随机推荐