(一)elasticsearch 編譯和啟動

来源:https://www.cnblogs.com/darcy-yuan/archive/2022/12/23/16997682.html
-Advertisement-
Play Games

1.準備 先從github官網上clone elasticsearch源碼到本地,選擇合適的分支。筆者這裡選用的是7.4.0(與筆者工作環境使用的分支一致),此版本編譯需要jdk11。 2.編譯 Readme 中說明瞭編譯命令 ./gradlew assemble 執行此命令,等待1h左右即可,根據 ...


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/home/data
#
# Path to log files:
#
path.logs: /Users/xxx/IdeaProjects/elasticsearch-my/home/data

modules 包在發行版elasticsearch中可以找到,這裡就不自行編譯了

問題2:

Exception in thread "main" java.lang.IllegalStateException: path.home is not configured
	at org.elasticsearch.env.Environment.<init>(Environment.java:104)
	at org.elasticsearch.env.Environment.<init>(Environment.java:95)
	at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:69)
	at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:95)
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125)
	at org.elasticsearch.cli.Command.main(Command.java:90)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)

同樣的,在vm參數中設定home地址即可,-Des.path.home=/Users/xxx/IdeaProjects/elasticsearch-my/home

問題3:

no log4j2.properties found; tried [/Users/xxx/IdeaProjects/elasticsearch-my/config] and its subdirectories

 

同問題1,沒有複製log4j2.properties引起的問題

問題4:

java.lang.NoClassDefFoundError: org/elasticsearch/plugins/ExtendedPluginsClassLoader

找到

compileOnly project(':libs:elasticsearch-plugin-classloader')

修改為

compile project(':libs:elasticsearch-plugin-classloader')

問題5:

Caused by: org.elasticsearch.ElasticsearchException: Failure running machine learning native code. This could be due to running on an unsupported OS or distribution, missing OS libraries, or a problem with the temp directory. To bypass this problem by running Elasticsearch without machine learning functionality set [xpack.ml.enabled: false].

意思是我的機器不支持機器學習,把modules中的插件 x-pack-ml 去掉就行

最後啟動完成如下

[2022-12-22T11:19:36,704][INFO ][o.e.p.PluginsService     ] [tiger] loaded module [x-pack-sql]
[2022-12-22T11:19:36,705][INFO ][o.e.p.PluginsService     ] [tiger] loaded module [x-pack-voting-only-node]
[2022-12-22T11:19:36,705][INFO ][o.e.p.PluginsService     ] [tiger] loaded module [x-pack-watcher]
[2022-12-22T11:19:36,706][INFO ][o.e.p.PluginsService     ] [tiger] no plugins loaded
[2022-12-22T11:19:37,238][INFO ][i.n.u.i.PlatformDependent] [tiger] Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system instability.
[2022-12-22T11:19:43,453][DEBUG][o.e.a.ActionModule       ] [tiger] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2022-12-22T11:19:43,530][INFO ][i.n.u.i.PlatformDependent] [tiger] Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system instability.
[2022-12-22T11:19:43,914][INFO ][o.e.d.DiscoveryModule    ] [tiger] using discovery type [zen] and seed hosts providers [settings]
[2022-12-22T11:19:45,141][INFO ][o.e.n.Node               ] [tiger] initialized
[2022-12-22T11:19:45,142][INFO ][o.e.n.Node               ] [tiger] starting ...
[2022-12-22T11:19:45,383][INFO ][o.e.t.TransportService   ] [tiger] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2022-12-22T11:19:45,417][WARN ][o.e.b.BootstrapChecks    ] [tiger] initial heap size [268435456] not equal to maximum heap size [4294967296]; this can cause resize pauses and prevents mlockall from locking the entire heap
[2022-12-22T11:19:45,418][WARN ][o.e.b.BootstrapChecks    ] [tiger] the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
[2022-12-22T11:19:45,425][INFO ][o.e.c.c.Coordinator      ] [tiger] cluster UUID [hhUOjQTPTxC11orp9ptAoQ]
[2022-12-22T11:19:45,450][INFO ][o.e.c.c.ClusterBootstrapService] [tiger] no discovery configuration found, will perform best-effort cluster bootstrapping after [3s] unless existing master is discovered
[2022-12-22T11:19:45,588][INFO ][o.e.c.s.MasterService    ] [tiger] elected-as-master ([1] nodes joined)[{tiger}{alQTCfqOStya2j1epxaskQ}{qDAgKIDeTmCbif0-EDJ0FA}{127.0.0.1}{127.0.0.1:9300}{dim}{xpack.installed=true} elect leader, _BECOME_MASTER_TASK_, _FINISH_ELECTION_], term: 2, version: 18, reason: master node changed {previous [], current [{tiger}{alQTCfqOStya2j1epxaskQ}{qDAgKIDeTmCbif0-EDJ0FA}{127.0.0.1}{127.0.0.1:9300}{dim}{xpack.installed=true}]}
[2022-12-22T11:19:45,733][INFO ][o.e.c.s.ClusterApplierService] [tiger] master node changed {previous [], current [{tiger}{alQTCfqOStya2j1epxaskQ}{qDAgKIDeTmCbif0-EDJ0FA}{127.0.0.1}{127.0.0.1:9300}{dim}{xpack.installed=true}]}, term: 2, version: 18, reason: Publication{term=2, version=18}
[2022-12-22T11:19:45,796][INFO ][o.e.h.AbstractHttpServerTransport] [tiger] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2022-12-22T11:19:45,797][INFO ][o.e.n.Node               ] [tiger] started
[2022-12-22T11:19:46,175][INFO ][o.e.l.LicenseService     ] [tiger] license [003ac67e-0dd0-42ee-8b76-59e2c21c444a] mode [basic] - valid
[2022-12-22T11:19:46,175][INFO ][o.e.x.s.s.SecurityStatusChangeListener] [tiger] Active license is now [BASIC]; Security is disabled
[2022-12-22T11:19:46,184][INFO ][o.e.g.GatewayService     ] [tiger] recovered [0] indices into cluster_state

這裡推薦一個chrome下的小插件elaticsearch-head,可視化當前集群的狀態

4.參考列表

https://www.cnblogs.com/Jackeyzhe/p/13352543.html 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • C++核心編程 本階段主要針對C++==面向對象==編程技術做詳細講解,探討C++中的核心和精髓。 1 記憶體分區模型 C++程式在執行時,將記憶體大方向劃分為4個區域 代碼區:存放函數體的二進位代碼,由操作系統進行管理的 全局區:存放全局變數和靜態變數以及常量 棧區:由編譯器自動分配釋放, 存放函數的 ...
  • 聲明 本文章中所有內容僅供學習交流,抓包內容、敏感網址、數據介面均已做脫敏處理,嚴禁用於商業用途和非法用途,否則由此產生的一切後果均與作者無關,若有侵權,請聯繫我立即刪除! 本文章未經許可禁止轉載,禁止任何修改後二次傳播,擅自使用本文講解的技術而導致的任何意外,作者均不負責,若有侵權,請在公眾號【K ...
  • hello,大家好呀,我是小樓。 上篇文章《一言不合就重構》 說了我最近重構的一個系統,雖然重構完了,但還在灰度,這不,在灰度過程中又發現了一個問題。 背景 這個問題簡單說一下背景,如果不明白可以看上篇文章 ,不想看也沒關係,這是個通用的解法,後面我會總結抽象下。 在上篇文章的最後提到對每個摘除的地 ...
  • 摘要:本文我們就結合案常式序來說明Java記憶體模型中的Happens-Before原則。 本文分享自華為雲社區《【高併發】一文秒懂Happens-Before原則》,作者: 冰 河。 在正式介紹Happens-Before原則之前,我們先來看一段代碼。 【示例一】 class VolatileExa ...
  • 電腦誕生以來,為適應程式不斷增長的複雜過程,程式設計方法論發生了巨大變化。例如,在電腦發展初期,程式設計是通過輸入二進位機器指令來完成的。在程式僅限於幾百條指令的情況下,這種方法是可接受的。隨著程式規模的增長,人們發明瞭彙編語言,這樣程式員就可以使用代表機器指令的符號表示法來處理大型的、複雜的程 ...
  • 1、認識SpringMVC 1、什麼是MVC MVC是一種軟體架構的思想,將軟體按照模型、視圖、控制器來劃分 M:Model,模型層,指工程中的JavaBean,作用是處理數據 JavaBean分為兩類: 一類稱為實體類Bean:專門存儲業務數據的,如 Student、User 等 一類稱為業務處理 ...
  • 前言 在學習《Python從入門到精通(第2版)》的第15章 GUI界面編程——15.2.4 將.ui文件轉換為.py文件時,按照書中步驟出錯時的問題解決,希望對同樣學習本書的同學有所幫助。 問題 問題出現 當跟著書15.2.4執行步驟(2)時PyCharm報錯 錯誤提示:pyuic5: error ...
  • 上一篇文章中我們聊了Caffeine的同步、非同步的數據回源方式。本篇文章我們再一起研討下經Caffeine改良過的非同步數據驅逐處理實現,以及Caffeine支持的多種不同的數據淘汰驅逐機制和對應的實際使用。 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...