MongoDB assumes 64 bit system - does it mean the hardware or the OS kernel or both?
This post says that you need a 64 bit system for MongoDB if your data is bigger than 2GB.
In my local machine, a 64 bit Intel C2D running 32 bit Mac OS X Leopard, the MongoDB 64 bit version runs wit开发者_运维技巧hout any error.
On the server, a 64 bit machine running 32 bit CentOS 5.0, the 64 bit MongoDB won't run. 32 bit runs OK.
My question is, does MongoDB requires both Hardware AND the OS Kernel to be 64 bit? If so, why the discrepancy in my experience in the above systems?
Actually the requirement is that if you want to work with more than about 2GB of data you need to use a 64-bit version of the mongod executable. This requires a 64-bit OS which in turn requires 64-bit hardware.
The requirement has nothing to do with physical ram and is about how much virtual memory a single process can address. Since mongodb uses mmap to map the contents of data files, you must have at least enough virtual address space to fit all of your data. Note that virtual address space is not increased by PAE. PAE is purely a Physical Address Extension to allow you to have more than about 3.5GB of RAM.
Edit: It looks like it is possible for a kernel running in 32bit mode to be written in a way to support 64bit userspace. OSX running on 64bit hardware is the only example I know of that uses this though. On windows and linux you must install the 64bit version of the operating system to run 64bit software.
If your data is > 2GB, the kernel needs to be able to address > 2GB memory. This requires either a 64-bit kernel, or you could try using the PAE kernel extension to allow a 32-bit kernel to address more RAM.
Perhaps MAC OS X already has something like the PAE extension, hence the discrepancy.
MAC OS X is a special case, since it tries VERY hard to hide the whole 32/64 bit stuff from the user. Leopard, afaik, already supports 64 bit apps through some tricks.
精彩评论