elasticsearch 7.x基于arm64构建rpm

下载配置java 13

wget https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk13u-2019-12-06-19-50/OpenJDK13U-jdk_aarch64_linux_hotspot_2019-12-06-19-50.tar.gz
tar -xvf OpenJDK13U-jdk_aarch64_linux_hotspot_2019-12-06-19-50.tar.gz -C /usr/local/share/
echo -e "JAVA_HOME=/usr/local/share/jdk-13.0.1+9/\nPATH=$JAVA_HOME/bin:$PATH\nexport JAVA_HOME PATH" >> /etc/profile
source /etc/profile

确认java版本

# java -version
openjdk version "13.0.1" 2019-10-15
OpenJDK Runtime Environment AdoptOpenJDK (build 13.0.1+9-201912061032)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 13.0.1+9-201912061032, mixed mode, sharing)

修改maven仓库地址

在USER_HOME/.gradle/下新建init.gradle,输入下面的内容并保存

allprojects{
    repositories {
        def REPOSITORY_URL = 'https://mirrors.huaweicloud.com/repository/maven/'
        all {
            ArtifactRepository repo ->
    if (repo instanceof MavenArtifactRepository) {
                def url = repo.url.toString()
                if (url.startsWith('https://repo.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
                    remove repo
                }
            }
        }
        maven {
            url REPOSITORY_URL
        }
    }
}

编译

git clone https://github.com/elastic/elasticsearch.git
# 或者单独下载tar包,快很多
wget https://github.com/elastic/elasticsearch/archive/v7.5.0.tar.gz

由于默认编译的包只能在x86_64环境下安装,我们可以通过修改成noarch来规避:

--- a/distribution/packages/build.gradle
+++ b/distribution/packages/build.gradle
@@ -107,7 +107,7 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk) {
   return {
     dependsOn "process${oss ? 'Oss' : ''}${jdk ? '' : 'NoJdk'}${type.capitalize()}Files"
     packageName "elasticsearch${oss ? '-oss' : ''}"
-    arch (type == 'deb' ? 'amd64' : 'X86_64')
+    arch (type == 'deb' ? 'amd64' : 'NOARCH')
     // Follow elasticsearch's file naming convention
     String jdkString = jdk ? "" : "no-jdk-"
     archiveName "${packageName}-${project.version}-${jdkString}${archString}.${type}"

编译没有打包jdk的包

cd elasticsearch
./gradlew -p distribution/packages/no-jdk-rpm/ assemble

如果是distribution/packages/rpm/则会打包x86_64的jdk

编译完成后,生成的包在 distribution/packages/no-jdk-rpm/build/distributions/elasticsearch-7.5.0-SNAPSHOT-no-jdk-noarch.rpm

安装配置

安装

yum install distribution/packages/no-jdk-rpm/build/distributions/elasticsearch-7.5.0-SNAPSHOT-no-jdk-noarch.rpm

设置JAVA_HOME

修改/etc/sysconfig/elasticsearch

JAVA_HOME=/usr/local/share/jdk-13.0.1+9/

修改配置

修改配置文件/etc/elasticsearch/elasticsearch.yml添加:

xpack.ml.enabled: false

X-Pack只支持x86_64,需要禁用,否则运行es会报错

运行服务

systemctl start elasticsearch

你可能感兴趣的:(elasticsearch 7.x基于arm64构建rpm)