Elasticsearch6,系统架构师面试问题

  1. 找到Node.java的如下方法:

protected Node(final Environment environment, Collection<Class<? extends Plugin>> classpathPlugins) {

final List resourcesToClose = new ArrayList<>(); // register everything we need to release in the case of an error

boolean success = false;

{

// use temp logger just to say we are starting. we can’t use it later on because the node name might not be set

Logger logger = Loggers.getLogger(Node.class, NODE_NAME_SETTING.get(environment.settings()));

logger.info(“initializing …”);

}

logger.info(“initializing …”);这一行代码下面增加下面这一行内容,作用是在elasticsearch启动时打印Node类实例的调用堆栈:

printTrack(logger, “Here is stack of Node instance”);

保存好再退出,接下来可以编译了;

编译构建

  1. 进入文件夹elasticsearch-6.1.2,执行命令./gradlew assemble即可开始编译,下载依赖会消耗大量时间,因此请耐心等待,编译过程中CPU占用略高,如下图:

在这里插入图片描述

  1. 大约10多分钟后,编译构建成功,控制台如下所示:

Task

《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》

【docs.qq.com/doc/DSmxTbFJ1cmN1R2dB】 完整内容开源分享

:test:fixtures:old-elasticsearch:javadocJar

Building without git revision id.

Task :test:fixtures:old-elasticsearch:sourcesJar

Building without git revision id.

BUILD SUCCESSFUL in 11m 3s

473 actionable tasks: 473 executed

  1. 编译完成后,进入目录elasticsearch-6.1.2/distribution/tar/build/distributions可以见到构建成功的结果:elasticsearch-6.1.2-SNAPSHOT.tar.gz,这就是可用的elasticsearch-6.1.2;

  2. 构建结果文件以SNAPSHOT作为文件名后缀,如果不想要此后缀,在编译的时候改用以下命令即可:

./gradlew assemble -Dbuild.snapshot=false

验证构建的elasticsearch是否可用

  1. 解压elasticsearch-6.1.2-SNAPSHOT.tar.gz到一个目录下;

  2. 进入目录elasticsearch-6.1.2-SNAPSHOT/config,修改network.host的配置为0.0.0.0,如下图:

在这里插入图片描述

  1. 进入目录elasticsearch-6.1.2-SNAPSHOT/bin,执行./elasticsearch命令启动服务;

  2. 在控制台可以看到新增的代码打出的日志,将Node类的调用堆栈打印出来了,我们也借此机会了解到elasticsearch启动时的涉及到的关键类:

[2019-04-20T04:02:55,785][INFO ][o.e.n.Node ] [] initializing …

[2019-04-20T04:02:55,789][INFO ][o.e.n.Node ] [] Here is stack of Node instance


java.lang.Thread.getStackTrace() 1,559 <-

org.elasticsearch.node.Node.printTrack() 953 <-

org.elasticsearch.node.Node.() 255 <-

org.elasticsearch.node.Node.() 245 <-

org.elasticsearch.bootstrap.Bootstrap$5.() 212 <-

org.elasticsearch.bootstrap.Bootstrap.setup() 212 <-

org.elasticsearch.bootstrap.Bootstrap.init() 322 <-

org.elasticsearch.bootstrap.Elasticsearch.init() 121 <-

org.elasticsearch.bootstrap.Elasticsearch.execute() 112 <-

org.elasticsearch.cli.EnvironmentAwareCommand.execute() 86 <-

org.elasticsearch.cli.Command.mainWithoutErrorHandling() 124 <-

org.elasticsearch.cli.Command.main() 90 <-

org.elasticsearch.bootstrap.Elasticsearch.main() 92 <-

org.elasticsearch.bootstrap.Elasticsearch.main() 85


  1. 我的ubutnu电脑的IP地址是192.168.50.75,因此用浏览器访问此地址:http://192.168.50.75:9200 ,返回内容如下所示:

在这里插入图片描述

至此编译构建elasticsearch6.1.2成功,在您编译构建elasticsearch的时候,希望本文能给您提供参考;

建议

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值