关于MongoDB你需要知道的几件事_MySQL
MongoDB
Henrique Lobo Weissmann是一位来自于巴西的软件开发者,他是itexto公司的联合创始人,这是一家咨询公司。近日,Henrique在博客上撰文谈到了关于MongoDB的一些内容,其中有些观点值得我们,特别是正在和打算使用MongoDB的开发者关注。
到目前为止,MongoDB在巴西是最为流行的NoSQL数据库(至少根据关于MongoDB的博客数量以及文章所判断)。MongoDB是个非常棒的解决方案,不过困扰我们的是很少有人了解过关于它的一些限制。这样的事情正在不断上演:人们看到MongoDB的限制,心里却认为这些是它的Bug。
本文列举了颇让作者困惑的一些MongoDB限制,如果你也打算使用MongoDB,那么至少要提前了解这些限制,以免遇到的时候措手不及。
消耗磁盘空间
这是我的第一个困惑:MongoDB会消耗太多的磁盘空间了。当然了,这与它的编码方式有关,因为MongoDB会通过预分配大文件空间来避免磁盘碎片问题。它的工作方式是这样的:在创建数据库时,系统会创建一个名为[db name].0的文件,当该文件有一半以上被使用时,系统会再次创建一个名为[db name].1的文件,该文件的大小是方才的两倍。这个情况会持续不断的发生,因此256、512、1024、2048大小的文件会被写到磁盘上。最后,再次创建文件时大小都将为2048Mb。如果存储空间是项目的一个限制,那么你必须要考虑这个情况。该问题有个商业解决方案,名字叫做TokuMX,使用后存储消耗将会减少90%。此外,从长远来看,repairDatabase与compact命令也会在一定程度上帮到你。
通过复制集实现的数据复制效果非常棒,不过也有限制
MongoDB中数据复制的复制集策略非常棒,很容易配置并且使用起来确实不错。但如果集群的节点有12个以上,那么你就会遇到问题。MongoDB中的复制集有12个节点的限制,这里是问题的描述,你可以追踪这个问题看看是否已经被解决了。
主从复制不会确保高可用性
尽管已经不建议被使用了,不过MongoDB还是提供了另外一种复制策略,即主从复制。它解决了12个节点限制问题,不过却产生了新的问题:如果需要改变集群的主节点,那么你必须得手工完成,感到惊讶?看看这个链接吧。
不要使用32位版本
MongoDB的32位版本也是不建议被使用的,因为你只能处理2GB大小的数据。还记得第一个限制么?这是MongoDB关于该限制的说明。
咨询费非常非常昂贵(至少对于巴西的开发者与公司来说如此)
我不清楚其他国家的情况,不过至少在巴西MongoDB的咨询费是个天价。对于“Lightning Consult”计划来说,每小时的价格是450,00美金,而你至少需要购买两个小时的,换句话说,对于任何一家公司来说,每次咨询的价格至少是900,00美金。相比于RedHat和Oracle来说,这个价格太高了。
差劲的管理工具
这对于初学者来说依然是个让人头疼的问题,MongoDB的管理控制台太差劲了。我所知道的最好的工具是RoboMongo,它对于那些初次使用的开发者来说非常趁手。
了解官方的限制
让我感到惊讶的是,很少有人会查询关于他们将要使用的工具的限制。幸好,MongoDB的开发人员发布了一篇MongoDB所有限制的博客,你可以提前了解相关信息,避免在使用过程中难堪。
各位读者,现在使用MongoDB的公司也越来越多了,不妨与大家分享你在使用这个NoSQL数据库时的一些经验与教训。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











When developing an e-commerce website, I encountered a difficult problem: how to provide users with personalized product recommendations. Initially, I tried some simple recommendation algorithms, but the results were not ideal, and user satisfaction was also affected. In order to improve the accuracy and efficiency of the recommendation system, I decided to adopt a more professional solution. Finally, I installed andres-montanez/recommendations-bundle through Composer, which not only solved my problem, but also greatly improved the performance of the recommendation system. You can learn composer through the following address:

This article introduces how to configure MongoDB on Debian system to achieve automatic expansion. The main steps include setting up the MongoDB replica set and disk space monitoring. 1. MongoDB installation First, make sure that MongoDB is installed on the Debian system. Install using the following command: sudoaptupdatesudoaptinstall-ymongodb-org 2. Configuring MongoDB replica set MongoDB replica set ensures high availability and data redundancy, which is the basis for achieving automatic capacity expansion. Start MongoDB service: sudosystemctlstartmongodsudosys

This article describes how to build a highly available MongoDB database on a Debian system. We will explore multiple ways to ensure data security and services continue to operate. Key strategy: ReplicaSet: ReplicaSet: Use replicasets to achieve data redundancy and automatic failover. When a master node fails, the replica set will automatically elect a new master node to ensure the continuous availability of the service. Data backup and recovery: Regularly use the mongodump command to backup the database and formulate effective recovery strategies to deal with the risk of data loss. Monitoring and Alarms: Deploy monitoring tools (such as Prometheus, Grafana) to monitor the running status of MongoDB in real time, and

It is impossible to view MongoDB password directly through Navicat because it is stored as hash values. How to retrieve lost passwords: 1. Reset passwords; 2. Check configuration files (may contain hash values); 3. Check codes (may hardcode passwords).

Detailed explanation of MongoDB efficient backup strategy under CentOS system This article will introduce in detail the various strategies for implementing MongoDB backup on CentOS system to ensure data security and business continuity. We will cover manual backups, timed backups, automated script backups, and backup methods in Docker container environments, and provide best practices for backup file management. Manual backup: Use the mongodump command to perform manual full backup, for example: mongodump-hlocalhost:27017-u username-p password-d database name-o/backup directory This command will export the data and metadata of the specified database to the specified backup directory.

GitLab Database Deployment Guide on CentOS System Selecting the right database is a key step in successfully deploying GitLab. GitLab is compatible with a variety of databases, including MySQL, PostgreSQL, and MongoDB. This article will explain in detail how to select and configure these databases. Database selection recommendation MySQL: a widely used relational database management system (RDBMS), with stable performance and suitable for most GitLab deployment scenarios. PostgreSQL: Powerful open source RDBMS, supports complex queries and advanced features, suitable for handling large data sets. MongoDB: Popular NoSQL database, good at handling sea

Encrypting MongoDB database on a Debian system requires following the following steps: Step 1: Install MongoDB First, make sure your Debian system has MongoDB installed. If not, please refer to the official MongoDB document for installation: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/Step 2: Generate the encryption key file Create a file containing the encryption key and set the correct permissions: ddif=/dev/urandomof=/etc/mongodb-keyfilebs=512

To set up a MongoDB user, follow these steps: 1. Connect to the server and create an administrator user. 2. Create a database to grant users access. 3. Use the createUser command to create a user and specify their role and database access rights. 4. Use the getUsers command to check the created user. 5. Optionally set other permissions or grant users permissions to a specific collection.
