欢迎您光临本小站。希望您在这里可以找到自己想要的信息。。。

5.6.12 elasticsearch es 源码 搭建

架构&设计模式 water 3947℃ 0评论

一 idea 运行

1) github下载

2) 5.0之后使用gradle管理项目依赖,5.4使用gradle 3.3+,先把gradle安装好 ,下载gradle-3.3-bin.zip

3) gradle的仓库需要翻墙,使用阿里云maven镜像,创建gradle 的初始化脚本 init.gradle放到 userhome/.gradle下,eg:root用户放到 /root/.gradle下,

这个初始化脚本的目的就是为了替换 jcenter()或者mavenCentral()

把下面代码拷贝到一个文本文件里 取名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://repo1.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

}

}

}

4) 修改本地资源库

修改根目录 build.gradle:

allprojects {

apply plugin: ‘idea’

if (isIdea) {

project.buildDir = file(‘build-idea’)

}

repositories {

maven{ url ‘http://10.58.50.26:8082/nexus/content/groups/public/’}

}

5)运行 gradlew idea 编译项目 ,时间比较长(这个地方最好用gradlew)

6)导入 idea    (直接用idea打开.ipr文件就可以,open)

7) 配置运行参数 path.home

-Des.path.home=/server/downcode/elasticsearch-5.5.1/distribution/src/main/resources(这个目录下必须有config,以及以下的三个配置文件 ;还有一个plugins目录,自己创建吧)

8)开始run以下试试 应该跑不通,提示 transport type [] 的错误,因为5.0之后transport模块也移到modules里,与core分开的,两个解决方式

a  不想debug transport或者使用独立的插件集成环境debug transport,可以将打包之后的modules模块拷贝到 -Des.path.home 目录下的modules目录下

b  修改源码node 类 使用classpath 加入modules 比如添加一个方法如下:

public List<Class<? extends Plugin>>   getModuls(){

List<Class<? extends Plugin>>   classpathPlugins=new ArrayList<Class<? extends Plugin>>();

classpathPlugins.add(Netty4Plugin.class);

classpathPlugins.add(Netty3Plugin.class);

classpathPlugins.add(ReindexPlugin.class);

classpathPlugins.add(PercolatorPlugin.class);

classpathPlugins.add(PainlessPlugin.class);

classpathPlugins.add(MustachePlugin.class);

//     classpathPlugins.add(GroovyPlugin.class);

//     classpathPlugins.add(ExpressionPlugin.class);

classpathPlugins.add(IngestCommonPlugin.class);

classpathPlugins.add(MatrixAggregationPlugin.class);

return classpathPlugins;

}并且修改node 构造函数中初始化 pluginsService 的参数 替换classpathPlugins为 getModules()方法

9) 导入依赖会提示,会有循环以来,不用管这个 确定就行。

10) 另外 5.0之后es已经没有是否在root用户下启动 的参数,代码是写死的必须root目录,可以把检查是否root用的代码注释掉,bootstrap类里:

//        if (Natives.definitelyRunningAsRoot()) {

//            throw new RuntimeException(“can not run elasticsearch as root”);

//        }

ok  run

-Des.path.conf=/home/lipeng-ds/project/elasticsearch-5.6.12/distribution/src/main/resources/config
-Des.path.home=/home/lipeng-ds/project/elasticsearch-5.6.12/distribution/src/main
-Dlog4j2.disable.jmx=true
-Djava.security.policy=/workspace/lipeng-ds/project/elasticsearch-5.6.12/distribution/src/main/resources/config/java.policy

修改es配置文件

cluster.name:

network.host:

discovery.type: single-node  添加这个配置,不然会好多安全启动检查

java.policy文件

/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the “License”); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

grant {
// Hadoop UserGroupInformation, HdfsConstants, PipelineAck clinit
permission java.lang.RuntimePermission “getClassLoader”;

// UserGroupInformation (UGI) Metrics clinit
permission java.lang.RuntimePermission “accessDeclaredMembers”;
permission java.lang.reflect.ReflectPermission “suppressAccessChecks”;

// org.apache.hadoop.util.StringUtils clinit
permission java.util.PropertyPermission “*”, “read,write”;

// org.apache.hadoop.util.ShutdownHookManager clinit
permission java.lang.RuntimePermission “shutdownHooks”;

// JAAS is used always, we use a fake subject, hurts nobody
permission javax.security.auth.AuthPermission “getSubject”;
permission javax.security.auth.AuthPermission “doAs”;
permission javax.security.auth.AuthPermission “modifyPrivateCredentials”;
permission java.lang.RuntimePermission “accessDeclaredMembers”;
permission java.lang.RuntimePermission “getClassLoader”;
permission java.lang.RuntimePermission “shutdownHooks”;
permission java.lang.reflect.ReflectPermission “suppressAccessChecks”;
permission javax.security.auth.AuthPermission “doAs”;
permission javax.security.auth.AuthPermission “getSubject”;
permission javax.security.auth.AuthPermission “modifyPrivateCredentials”;
permission java.security.AllPermission;
permission java.util.PropertyPermission “*”, “read,write”;
permission javax.security.auth.PrivateCredentialPermission “org.apache.hadoop.security.Credentials * \”*\””, “read”;
};

另外可参考:http://laijianfeng.org/2018/08/%E6%95%99%E4%BD%A0%E7%BC%96%E8%AF%91%E8%B0%83%E8%AF%95Elasticsearch-6-3-2%E6%BA%90%E7%A0%81/

转载请注明:学时网 » 5.6.12 elasticsearch es 源码 搭建

喜欢 (0)or分享 (0)

您必须 登录 才能发表评论!