Ubuntu 22安装MongoDB遇CPU指令不支持问题,求替代解决方案
在Ubuntu 22上安装MongoDB(不更换CPU的替代方案)
我尝试在Ubuntu 22系统上安装MongoDB 5及4.4版本,但我的CPU不支持部分指令,导致安装后出现core-dump错误和illegal instruction错误。我也尝试过通过tar.gz包安装,但同样无法成功。
我的CPU信息如下:
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 39 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 2 On-line CPU(s) list: 0,1 Vendor ID: GenuineIntel Model name: Intel(R) Pentium(R) CPU G3260 @ 3.30GHz CPU family: 6 Model: 60 Thread(s) per core: 1 Core(s) per socket: 2 Socket(s): 1 Stepping: 3 CPU max MHz: 3300.0000 CPU min MHz: 800.0000 BogoMIPS: 6585.15 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mc a cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arc h_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vm x est tm2 ssse3 sdbg cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer xsave rdrand lahf_lm ab m cpuid_fault epb invpcid_single pti ssbd ibrs ibpb sti bp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbas e tsc_adjust erms invpcid xsaveopt dtherm arat pln pts md_clear flush_l1d Virtualization features: Virtualization: VT-x Caches (sum of all): L1d: 64 KiB (2 instances) L1i: 64 KiB (2 instances) L2: 512 KiB (2 instances) L3: 3 MiB (1 instance) NUMA: NUMA node(s): 1 NUMA node0 CPU(s): 0,1 Vulnerabilities: Itlb multihit: KVM: Mitigation: VMX disabled L1tf: Mitigation; PTE Inversion; VMX conditional cache flushe s, SMT disabled Mds: Mitigation; Clear CPU buffers; SMT disabled Meltdown: Mitigation; PTI Mmio stale data: Not affected Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Spectre v2: Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIB P disabled, RSB filling Srbds: Mitigation; Microcode Tsx async abort: Not affected
可行解决方案
- 安装更低版本的MongoDB:MongoDB 4.2及更早版本对CPU指令集要求更低,你的Intel Pentium G3260支持的SSE4.2、POPCNT等指令集可满足其运行需求。可通过官方源或deb包手动安装4.2版本,避开需要高级指令的新版本。
- 使用Docker容器运行MongoDB:选择针对旧x86_64架构编译的MongoDB镜像,容器内的预编译版本可兼容你的CPU。例如执行启动命令:
docker run -d -p 27017:27017 mongo:4.2 - 手动编译MongoDB源码:下载对应版本源码,编译时指定兼容当前CPU的选项,禁用高级指令优化:
- 安装编译依赖:
sudo apt install build-essential cmake libssl-dev libsasl2-dev - 下载并解压目标版本源码
- 创建编译目录并进入:
mkdir build && cd build - 配置CMake兼容选项:
cmake .. -DCMAKE_CXX_FLAGS="-march=haswell -mtune=generic"(G3260属于Haswell架构) - 编译并安装:
make -j$(nproc) && sudo make install
- 安装编译依赖:
内容的提问来源于stack exchange,提问作者parpar31
相关产品推荐
相关产品推荐

