MongoDB High Availability
上QQ阅读APP看书,第一时间看更新

Understanding the limitation of a 32-bit version of MongoDB

If you want to deploy MongoDB in a production environment, it's necessary that you use a 64-bit version and not a 32-bit one. In the 32-bit version, MongoDB has the limitation of storage size, that is, you cannot store datasets more than 2 GB.

While using a 32-bit version, if the database storage is more than 2 GB, you will get an error, and you can't start the server till the time you remove your data or migrate your database to a 64-bit version of MongoDB.

The Unix limitation

Most of the Unix family systems such as OS X and Linux provide a method to limit the amount of resources that each user and process can use at the moment. The ulimit function is responsible for managing and applying this limitation.

When the mongod or mongos processes reach the limitation, some errors will show up and the MongoDB server will crash at that moment. You can simply change the limitation using the ulimit function.

Both mongod and mongos instances need to connect to other nodes, members and clients, so it's recommended that you change the limitation manually to prevent problems in the production and for high throughput.

By using the ulimit -a command, you can see the limitations. The following screenshot is an example of using this command:

The Unix limitation

The ulimit command shows you the limitation per user. So, if you run the mongod or mongos instances as a user, you will realize that these processes might reach this limitation.

Note

Note that the processes' value (that is, -u) refers to the combined number of distinct processes and subprocess threads. This can be accessed at http://docs.mongodb.org/manual/reference/ulimit/.

To change the limitation, you can simply use the following command:

ulimit -a 256 

After changing the limitation, its better to restart the mongod or mongos instances to apply the limitation.

The following is the recommended setting for the mongod and mongos processes from the MongoDB documentation page at http://docs.mongodb.org/manual/reference/ulimit/. The settings are set using the following command:

-f (file size): unlimited 
-t (cpu time): unlimited 
-v (virtual memory): unlimited
-n (open files): 64000 
-m (memory size): unlimited
-u (processes/threads): 32000