Elasticsearch 6.7.2 源码编译
环境:
git
jdk12 https://jdk.java.net/java-se-ri/12 解压 配置环境变量
gradle5.2.1 https://gradle.org/next-steps/?version=5.2.1&format=all 安装 配置环境变量
idea 2019
1.源码地址:https://github.com/elastic/elasticsearch
2.git clone https://github.com/elastic/elasticsearch
3.git tag -l
4.git checkout v6.7.2
5.源码gradle配置
用户目录./gradle文件夹中新建init.gradle文件
配置如下内容:
allprojects {
repositories {
def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public/'
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
}
}
}
6.源码编译:
gradle 安装包拷贝至源码根目录/gradle/wrapper下
并修改gradle-wrapper.properties文件内容为:
distributionUrl=gradle-5.2.1-all.zip
gradlew idea
进入源码根目录doc环境中执行./gradlew idea编译源码 (联网操作)
尝试过java11和java13均失败
本地有装hadoop 编译失败
7.源码打包:未完成
8.idea源码调试
idea -》file -》project from existing sources -》源码根目录 -》ok -》Import project from external model -》 Gradle -》auto-import office work gradle选到用户目录
ERROR: the system property [es.path.conf] must be set
下载同版本release包解压
源码根目录下创建home文件夹
release包的config目录拷贝至上诉文件夹
idea中做如下配置:
VM options 配置中添加
-Des.path.conf=D:\code\code-zhx\elasticsearch\home\config
Exception in thread "main" java.lang.IllegalStateException: path.home is not configured
VM options 配置中添加
-Des.path.home=D:\code\code-zhx\elasticsearch\home
ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
VM options 配置中添加
-Dlog4j2.disable.jmx=true
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: modules directory [D:\code\code-zhx\elasticsearch\home\modules] not found
release版本的config目录中的modules文件夹放在源码根目录下建的home文件夹
java.lang.NoClassDefFoundError: org/elasticsearch/plugins/ExtendedPluginsClassLoader
org.elasticsearch.bootstrap.StartupException: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "createClassLoader")
源码根目录 /home/config下新建java.policy文件
并配置如下内容:
grant {
permission java.lang.RuntimePermission "createClassLoader";
};
并在VM options 配置中添加
-Djava.security.policy=D:\code\code-zhx\elasticsearch\home\config\java.policy