Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> MongoDB

วิธีตรวจสอบว่า MongoDB ติดตั้งเป็น 32-bit หรือ 64-bit

ใช้คำสั่ง buildInfo ผ่าน db.runCommand() หลังจากสลับไปที่ database admin

ขั้นตอนการตรวจสอบ

1. สลับไป database admin

> use admin
switched to db admin

2. รันคำสั่ง buildInfo

> db.runCommand("buildInfo");

หรือ

> db.runCommand({ buildInfo: 1 });

3. ผลลัพธ์ตัวอย่าง (MongoDB 64-bit)

{
    "version" : "4.0.5",
    "gitVersion" : "3739429dd92b92d1b0ab120911a23d50bf03c412",
    "targetMinOS" : "Windows 7/Windows Server 2008 R2",
    "modules" : [ ],
    "allocator" : "tcmalloc",
    "javascriptEngine" : "mozjs",
    "sysInfo" : "deprecated",
    "versionArray" : [ 4, 0, 5, 0 ],
    "openssl" : { "running" : "Windows SChannel" },
    "buildEnvironment" : {
        "distmod" : "2008plus-ssl",
        "distarch" : "x86_64",
        "cc" : "cl: Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24223 for x64",
        "target_arch" : "x86_64",
        "target_os" : "windows"
    },
    "bits" : 64,                    // <-- สำคัญ: 64 = 64-bit, 32 = 32-bit
    "debug" : false,
    "maxBsonObjectSize" : 16777216,
    "storageEngines" : [ "devnull", "ephemeralForTest", "mmapv1", "wiredTiger" ],
    "ok" : 1
}

ฟิลด์สำคัญที่ต้องดู

สรุป

  • ดูฟิลด์ "bits" : 64 → MongoDB 64-bit
  • ดูฟิลด์ "bits" : 32 → MongoDB 32-bit (จำกัดข้อมูล ~2GB)
  • MongoDB 32-bit ไม่เหมาะสำหรับ production เนื่องจากข้อจำกัดหน่วยความจำ
  • คำสั่งนี้ทำงานได้ใน MongoDB shell ทุกเวอร์ชัน
ฟิลด์ความหมาย
bits32 หรือ 64 - บอกว่าเป็น 32-bit หรือ 64-bit
buildEnvironment.distarchสถาปัตยกรรม: x86_64 = 64-bit, x86 = 32-bit
buildEnvironment.target_archเหมือนด้านบน