设为首页 加入收藏

TOP

(一)elasticsearch 编译和启动(一)
2023-07-25 21:39:01 】 浏览:45
Tags:elasticsearch

1.准备

先从github官网上clone elasticsearch源码到本地,选择合适的分支。笔者这里选用的是7.4.0(与笔者工作环境使用的分支一致),此版本编译需要jdk11。

2.编译

Readme 中说明了编译命令

./gradlew assemble

执行此命令,等待1h左右即可,根据机器性能可能会有差异

> Task :x-pack:plugin:sql:qa:compileJava
注: /Users/xxx/IdeaProjects/elasticsearch-my/x-pack/plugin/sql/qa/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/CsvTestUtils.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。

BUILD SUCCESSFUL in 52m 0s
947 actionable tasks: 946 executed, 1 up-to-date

 编译过程中可能会遇到的问题:

FAILURE: Build failed with an exception.

* What went wrong:
a problem occurred running Docker from [/usr/local/bin/docker] yet it is required to run the following tasks: 
  :distribution:docker:buildDockerImage
  :distribution:docker:buildOssDockerImage
the problem is that Docker exited with exit code [1] with standard error output [Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?]
you can address this by attending to the reported issue, removing the offending tasks from being executed, or by passing -Dbuild.docker=false

 新版本 elasticsearch 编译过程依赖docker,启动docker后台或者注释掉以下代码

文件路径:/distribution/docker/build.gradle

void addBuildDockerImage(final boolean oss) {
//  final Task buildDockerImageTask = task(taskName("build", oss, "DockerImage"), type: LoggedExec) {
//    dependsOn taskName("copy", oss, "DockerContext")
//    List<String> tags
//    if (oss) {
//      tags = [
//        "docker.elastic.co/elasticsearch/elasticsearch-oss:${VersionProperties.elasticsearch}",
//        "elasticsearch-oss:test"
//      ]
//    } else {
//      tags = [
//        "elasticsearch:${VersionProperties.elasticsearch}",
//        "docker.elastic.co/elasticsearch/elasticsearch:${VersionProperties.elasticsearch}",
//        "docker.elastic.co/elasticsearch/elasticsearch-full:${VersionProperties.elasticsearch}",
//        "elasticsearch:test",
//      ]
//    }
//    executable 'docker'
//    final List<String> dockerArgs = ['build', files(oss), '--pull', '--no-cache']
//    for (final String tag : tags) {
//      dockerArgs.add('--tag')
//      dockerArgs.add(tag)
//    }
//    args dockerArgs.toArray()
//  }
//  BuildPlugin.requireDocker(buildDockerImageTask)
}

for (final boolean oss : [false, true]) {
  addCopyDockerContextTask(oss)
  addBuildDockerImage(oss)
}

//assemble.dependsOn "buildOssDockerImage"
//assemble.dependsOn "buildDockerImage"

3.启动

启动elasticsearch 服务,启动类是 org.elasticsearch.bootstrap.Elasticsearch

启动过程中可能会出现的问题:

问题1:

the system property [es.path.conf] must be set

在vm启动项加入参数:-Des.path.conf=/Users/xxx/IdeaProjects/elasticsearch-my/config,然后将配置文件elasticsearch.yml ,log4j2.properties, modules 复制到这个目录

项目中有配置文件的例子

笔者是这样配置的

# Use a descriptive name for your cluster:
#
cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: tiger
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /Users/xxx/IdeaProjects/elasticsearch-my/ho
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇每日算法之二叉搜索树的第k个节点 下一篇LeetCode刷题第七周

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目