下载源码
由于git clone 拉不下来,直接下在zip文件
https://github.com/elastic/elasticsearch/archive/refs/heads/master.zip
遇到问题
-
最新版本需要jdk16,下载jdk16 并支持切换环境。JAVA_HOME配置jdk16
-
执行./gradlew localDistro(https://github.com/elastic/elasticsearch),产物在distribution中。选择你对应系统的包,mac 系统对应的包位于 darwin-tar 下的 build/distributions 目录下。并在 elasticsech 源代码创建一个目录,这里就叫 product,将刚才打包生成的 elasticsearch-xxx.tar.gz 解压到 product 目录下
-
启动,主类在server下org.elasticsearch.bootstrap.Elasticsearch
-
启动报错解决
idea 添加vm options
-Des.path.conf=xxx/elasticsearch-master/product/config/
-Des.path.home=xxx/study/elasticsearch-master/product/
-Dlog4j2.disable.jmx=true
-Djava.security.policy=xxx/elasticsearch-master/server/src/main/resources/org/elasticsearch/bootstrap/elasticsearch.policy
java.lang.reflect.InaccessibleObjectException:——将scala插件disable
elasticsearch codec header mismatch: actual header=1072676797 vs expected header=1071082519——删除keystore
- 修改密码:
到bin目录,执行 ./elasticsearch-reset-password --username elastic.
然后postman Authorization 中选择Basic Auth 输入用户密码 - 验证。浏览器输入127.0.0.1:9200,输入用户密码。然后返回: