我无法在 ubuntu 20.04 上执行 ./bin/elasticsearch

我无法在 ubuntu 20.04 上执行 ./bin/elasticsearch

当我运行./bin/elasticsearch命令时,出现以下错误:

./bin/elasticsearch-cli: line 14: /home/samira/elasticsearch-8.4.2/jdk/bin/java: cannot execute binary file: Exec format error
./bin/elasticsearch-cli: line 14: /home/samira/elasticsearch-8.4.2/jdk/bin/java: Success

这是我的 elasticsearch-cli:

#!/bin/bash

set -e -o pipefail

source "`dirname "$0"`"/elasticsearch-env

# use a small heap size for the CLI tools, and thus the serial collector to
# avoid stealing many CPU cycles; a user can override by setting CLI_JAVA_OPTS
CLI_JAVA_OPTS="-Xms4m -Xmx64m -XX:+UseSerialGC ${CLI_JAVA_OPTS}"

LAUNCHER_CLASSPATH=$ES_HOME/lib/*:$ES_HOME/lib/cli-launcher/*

exec \
  "$JAVA" \
  $CLI_JAVA_OPTS \
  -Dcli.name="$CLI_NAME" \
  -Dcli.script="$0" \
  -Dcli.libs="$CLI_LIBS" \
  -Des.path.home="$ES_HOME" \
  -Des.path.conf="$ES_PATH_CONF" \
  -Des.distribution.type="$ES_DISTRIBUTION_TYPE" \
  -cp "$LAUNCHER_CLASSPATH" \
  org.elasticsearch.launcher.CliToolLauncher \
  "$@"

我运行java -version并输出:

openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Ubuntu-0ubuntu120.04, mixed mode)

然后我运行lscpu并输出:

Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   39 bits physical, 48 bits virtual
CPU(s):                          4
On-line CPU(s) list:             0-3
Thread(s) per core:              1
Core(s) per socket:              4
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       GenuineIntel
CPU family:                      6
Model:                           94
Model name:                      Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
Stepping:                        3
CPU MHz:                         1098.724
CPU max MHz:                     3600.0000
CPU min MHz:                     800.0000
BogoMIPS:                        6399.96
L1d cache:                       128 KiB
L1i cache:                       128 KiB
L2 cache:                        1 MiB
L3 cache:                        6 MiB
NUMA node0 CPU(s):               0-3
Vulnerability Itlb multihit:     KVM: Mitigation: VMX unsupported
Vulnerability L1tf:              Mitigation; PTE Inversion
Vulnerability Mds:               Mitigation; Clear CPU buffers; SMT disabled
Vulnerability Meltdown:          Mitigation; PTI
Vulnerability Mmio stale data:   Mitigation; Clear CPU buffers; SMT disabled
Vulnerability Retbleed:          Mitigation; IBRS
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; IBRS, IBPB conditional, RSB filling
Vulnerability Srbds:             Mitigation; Microcode
Vulnerability Tsx async abort:   Mitigation; TSX disabled
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss 
                                 ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_
                                 tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1
                                  sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault
                                  invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx s
                                 map clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window h
                                 wp_epp md_clear flush_l1d arch_capabilities

我该如何修复这个错误?

答案1

您的 CPU 架构如下,x86_64而下载的 elastic-search 则为aarch64

前往elasticsearch目录,在那里打开一个终端并运行./uninstall.sh以卸载当前aarch64版本,然后安装正确的版本;

您可以下载该架构的两个版本,一个是文件.tar.gz,另一个是.deb文件,.deb安装文件更容易安装,也更容易卸载,因此要安装的正确版本是elasticsearch-8.4.2-amd64.deb(推荐)或elasticsearch-8.4.2-linux-x86_64.tar.gz

我建议第一个

相关内容