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架构下存在兼容问题,直接跳过加载即可:
- 找到Cassandra安装目录下的
bin/cassandra启动脚本 - 打开脚本后,定位到包含
LD_PRELOAD或JEMALLOC_PATH的行,比如类似export LD_PRELOAD="$JEMALLOC_PATH/libjemalloc.dylib"的语句,直接注释掉 - 保存脚本后重新启动Cassandra
方案2:编译适配arm64的jemalloc
如果需要保留jemalloc的内存优化功能,可手动编译适配M1架构的版本:
- 卸载现有jemalloc:
brew uninstall jemalloc - 克隆jemalloc源码仓库:
git clone https://github.com/jemalloc/jemalloc.git - 进入源码目录执行编译安装:
cd jemalloc ./autogen.sh ./configure --with-lg-page=16 make make install - 完成后重启Cassandra验证
方案3:通过Rosetta 2兼容模式运行
利用Rosetta 2模拟x86_64环境规避架构冲突:
- 在终端执行
arch -x86_64 zsh切换到x86_64架构的shell环境 - 在该环境下执行
cassandra启动服务
内容的提问来源于stack exchange,提问作者Nick
相关产品推荐
相关产品推荐

