elasticsearch8.1源码编译笔记

2022-09-20  本文已影响0人  醉鱼java

环境

前置准备

开始导入

./gradlew localDistro
├── elasticsearch
│   ├── BUILDING.md
│   ├── CONTRIBUTING.md
│   ├── LICENSE.txt
│   ├── NOTICE.txt
│   ├── README.asciidoc
│   ├── README.md
│   ├── TESTING.asciidoc
│   ├── Vagrantfile
│   ├── benchmarks
│   ├── build
│   ├── build-conventions
│   ├── build-tools
│   ├── build-tools-internal
│   ├── build.gradle
│   ├── ccr
│   ├── checkstyle_ide.xml
│   ├── client
│   ├── dev-tools
│   ├── distribution
│   ├── docs
│   ├── gradle
│   ├── gradle.properties
│   ├── gradlew
│   ├── gradlew.bat
│   ├── libs
│   ├── licenses
│   ├── modules
│   ├── plugins
│   ├── qa
│   ├── rest-api-spec
│   ├── server
│   ├── settings.gradle
│   ├── test
│   └── x-pack
├── home
│   ├── LICENSE.txt
│   ├── NOTICE.txt
│   ├── README.asciidoc
│   ├── bin
│   ├── config
│   ├── data
│   ├── jdk.app
│   ├── lib
│   ├── logs
│   ├── modules
└── └── plugins

-Des.path.conf=/cxt/codework/github/elasticsearch/8.1/home/config
-Des.path.home=/cxt/codework/github/elasticsearch/8.1/home
grant {
    permission javax.management.MBeanTrustPermission "register";
};

运行时指定

-Djava.security.policy=/cxt/codework/github/elasticsearch/8.1/home/config/java.policy
    permission java.lang.RuntimePermission "createClassLoader";
    permission java.lang.RuntimePermission "setContextClassLoader";
    permission org.elasticsearch.secure_sm.ThreadPermission "modifyArbitraryThreadGroup";
Caused by: java.lang.IllegalArgumentException: Unknown codebases [codebase.elasticsearch-plugin-classloader, codebase.elasticsearch, codebase.elasticsearch-secure-sm] in policy file [file:/cxt/codework/github/elasticsearch/8.1/elasticsearch/server/out/production/resources/org/elasticsearch/bootstrap/security.policy]

解决如下,找到 server/src/main/resources/org/elasticsearch/bootstrap/security.policy,注释掉一下三个
[codebase.elasticsearch-plugin-classloader, codebase.elasticsearch, codebase.elasticsearch-secure-sm]

//grant codeBase "${codebase.elasticsearch-plugin-classloader}" {
  // needed to create the classloader which allows plugins to extend other plugins
  //permission java.lang.RuntimePermission "createClassLoader";
//};

//grant codeBase "${codebase.elasticsearch-secure-sm}" {
//  permission java.security.AllPermission;
//};

//// Elasticsearch core:
//// These are only allowed inside the server jar, not in plugins
//grant codeBase "${codebase.elasticsearch}" {
  // needed for loading plugins which may expect the context class loader to be set
//  permission java.lang.RuntimePermission "setContextClassLoader";
//};

总结

-Des.path.conf=/cxt/codework/github/elasticsearch/8.1/home/config
-Des.path.home=/cxt/codework/github/elasticsearch/8.1/home
-Djava.security.policy=/cxt/codework/github/elasticsearch/8.1/home/config/java.policy
-Dlog4j2.disable.jmx=true

也可以在Elasticsearch.main方法执行前通过代码的形式指定环境变量(可选)

System.setProperty("es.path.conf","/cxt/codework/github/elasticsearch/8.1/home/config");
System.setProperty("es.path.home", "/cxt/codework/github/elasticsearch/8.1/home");
System.setProperty("log4j2.disable.jmx", "true");    System.setProperty("java.security.policy","/cxt/codework/github/elasticsearch/8.1/home/config/java.policy");
grant {
    permission javax.management.MBeanTrustPermission "register";
    permission java.lang.RuntimePermission "createClassLoader";
    permission java.lang.RuntimePermission "setContextClassLoader";
    permission org.elasticsearch.secure_sm.ThreadPermission "modifyArbitraryThreadGroup";
};

本文由mdnice多平台发布

上一篇下一篇

猜你喜欢

热点阅读