cd ~/es_data
git clone https://github.com/elastic/elasticsearch.git
cd elasticsearch
git checkout -b test v7.3.1
Import Project => 选择 elasticsearch 目录 => Import project from external model (Gradle) => Use auto-import
# 这一步网络下载可能很慢,必要时使用代理
# export http_proxy=http://127.0.0.1:1087
# export https_proxy=http://127.0.0.1:1087;
./gradlew run --debug-jvm
Elasticsearch 启动类:server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch,继承EnvironmentAwareCommand
。
public abstract class EnvironmentAwareCommand extends Command {
@Override
protected void execute(Terminal terminal, OptionSet options) throws Exception {
putSystemPropertyIfSettingIsMissing(settings, "path.data", "es.path.data");
putSystemPropertyIfSettingIsMissing(settings, "path.home", "es.path.home");
putSystemPropertyIfSettingIsMissing(settings, "path.logs", "es.path.logs");
}
protected Environment createEnv(final Map<String, String> settings) throws UserException {
final String esPathConf = System.getProperty("es.path.conf");
}
}
cd ~/es_data
mkdir config data logs home
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.1-darwin-x86_64.tar.gz
tar zxvf elasticsearch-7.3.1-darwin-x86_64.tar.gz
cp -R elasticsearch-7.3.1/modules home/
cp -R elasticsearch-7.3.1/plugins home/
cp -R elasticsearch/distribution/src/config/* config/
vi config/elasticsearch.yml
cluster.name: my-application
node.name: node-1
#${path.data}
#${path.logs}
vi config/elasticsearch.policy
grant {
permission java.lang.RuntimePermission "createClassLoader";
};
-Des.path.data=~/es_idea/data
-Des.path.home=~/es_idea/home
-Des.path.logs=~/es_idea/logs
-Des.path.conf=~/es_idea/config
-Djava.security.policy=~/es_idea/config/elasticsearch.policy
-Dlog4j2.disable.jmx=true