You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac M1设备无法启动Cassandra 4.1的问题求助

Apple M1 Mac启动Cassandra 4.1时libjemalloc架构兼容问题解决

环境信息

Arch: Apple M1
OS: Mac 13.0.1
Java: 17
Cassandra: 4.1

安装尝试

我试过两种Mac上安装Cassandra的方法:

  • 通过Homebrew安装
  • 从官网下载apache-cassandra-4.1.0-bin.tar.gz手动安装

启动错误信息

启动Cassandra时触发以下错误:

dyld[29837]: terminating because inserted dylib '/usr/local/lib/libjemalloc.dylib' could not be loaded: tried: '/usr/local/lib/libjemalloc.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need '')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/libjemalloc.dylib' (no such file), '/usr/local/lib/libjemalloc.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need '')), '/opt/homebrew/Cellar/jemalloc/5.3.0/lib/libjemalloc.2.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need '')), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/jemalloc/5.3.0/lib/libjemalloc.2.dylib' (no such file), '/opt/homebrew/Cellar/jemalloc/5.3.0/lib/libjemalloc.2.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need ''))
dyld[29837]: tried: '/usr/local/lib/libjemalloc.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need '')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/libjemalloc.dylib' (no such file), '/usr/local/lib/libjemalloc.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need '')), '/opt/homebrew/Cellar/jemalloc/5.3.0/lib/libjemalloc.2.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need '')), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/jemalloc/5.3.0/lib/libjemalloc.2.dylib' (no such file), '/opt/homebrew/Cellar/jemalloc/5.3.0/lib/libjemalloc.2.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need ''))
Error parsing arguments! Unknown argument ""

额外情况

cqlsh可以正常运行,能够连接到其他Cassandra服务器。

解决方案

方案1:禁用jemalloc加载

Cassandra默认依赖jemalloc做内存优化,但M1架构下存在兼容问题,直接跳过加载即可:

  1. 找到Cassandra安装目录下的bin/cassandra启动脚本
  2. 打开脚本后,定位到包含LD_PRELOAD或JEMALLOC_PATH的行,比如类似export LD_PRELOAD="$JEMALLOC_PATH/libjemalloc.dylib"的语句,直接注释掉
  3. 保存脚本后重新启动Cassandra

方案2:编译适配arm64的jemalloc

如果需要保留jemalloc的内存优化功能,可手动编译适配M1架构的版本:

  1. 卸载现有jemalloc:brew uninstall jemalloc
  2. 克隆jemalloc源码仓库:git clone https://github.com/jemalloc/jemalloc.git
  3. 进入源码目录执行编译安装:
    cd jemalloc
    ./autogen.sh
    ./configure --with-lg-page=16
    make
    make install
    
  4. 完成后重启Cassandra验证

方案3:通过Rosetta 2兼容模式运行

利用Rosetta 2模拟x86_64环境规避架构冲突:

  1. 在终端执行arch -x86_64 zsh切换到x86_64架构的shell环境
  2. 在该环境下执行cassandra启动服务

内容的提问来源于stack exchange,提问作者Nick

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 00:05:15