elasticsearch安装与配置

./elasticsearch -d

如此,使elasticsearch在后台运行,在后台运行的elasticsearch可以使用jdk自带的查看当前Java进程的工具jps命令查看运行状况,如下:

在这里插入图片描述

当然也可以直接使用Linux中的命令查看,如下:

ps aux|grep elasticsearch

不管哪一种查看方式,查看后都可以获取到elasticsearch的进程id,然后通过kill命令可以关闭elasticsearch,如下:

kill 8423

操作结果如下:

在这里插入图片描述

配置

=============================================================

安装目录介绍


elasticsearch下载之后,解压后,可以看到目录结构如下:

在这里插入图片描述

目录含义如下:

| 文件/文件夹 | 作用 |

| :-- | :-- |

| bin | 可执行文件存放目录,例如启动文件 |

| config | 配置文件存放目录 |

| data | 数据存储目录 |

| lib | 第三方依赖库 |

| logs | 运行日志输出目录 |

| modules | 依赖模块目录 |

| plugins | 插件目录 |

| LICENSE.txt | LICENSE声明文件 |

| NOTICE.txt | 版权声明文件 |

| README.textile | 框架介绍信息 |

配置介绍


在config目录下,主要有如下配置文件:

  • elasticsearch.keystore

  • jvm.options

  • role_mapping.yml

  • users

  • elasticsearch.yml

  • log4j2.properties

  • roles.yml

  • users_roles

其中,我们经常涉及到的有三个,elasticsearch.yml、log4j2.properties以及jvm.options,其中,elasticsearch.yml是elasticsearch的基本配置文件,log4j2是日志输出配置文件,jvm则是jvm基本参数配置。这里主要来看看elasticsearch.yml配置文件,如下:

======================== Elasticsearch Configuration =========================

NOTE: Elasticsearch comes with reasonable defaults for most settings.

Before you set out to tweak and tune the configuration, make sure you

understand what are you trying to accomplish and the consequences.

The primary way of configuring a node is via this file. This template lists

the most important settings you may want to configure for a production cluster.

Please consult the documentation for further information on configuration options:

https://www.elastic.co/guide/en/elasticsearch/reference/index.html

---------------------------------- 集群配置 -----------------------------------

Use a descriptive name for your cluster:

#配置集群名字,集群名字默认为elasticsearch,

#elasticsearch会自动发现在同一网段下的elasticsearch节点。

#读者在第一次启动elasticsearch时,在浏览器中输入http://localhost:9200,

#在返回的数据中,就有集群名字,默认即为elasticsearch。

#cluster.name: my-application

------------------------------------ 节点配置 ------------------------------------

Use a descriptive name for the node:

#配置节点名称

#node.name: node-1

Add custom attributes to the node:

#给节点添加自定义属性

#node.attr.rack: r1

----------------------------------- 路径配置 ------------------------------------

Path to directory where to store the data (separate multiple locations by comma):

#数据存放目录,默认是elasticsearch下的data目录,可以指定多个目录,用,隔开,如:

#path.data:/path/data1,/path/data2

#path.data: /path/to/data

Path to log files:

#日志存放目录,默认为elasticsearch下的logs目录

#path.logs: /path/to/logs

----------------------------------- 内存配置 -----------------------------------

Lock the memory on startup:

#配置是否锁住内存。当jvm开始swapping时,elasticsearch的效率降低,为了避免这种情况,可以设置为true。

#bootstrap.memory_lock: true

Make sure that the heap size is set to about half the memory available

on the system and that the owner of the process is allowed to use this

limit.

Elasticsearch performs poorly when the system is swapping the memory.

---------------------------------- 网络配置 -----------------------------------

Set the bind address to a specific IP (IPv4 or IPv6):

#设置绑定的ip地址

#network.host: 192.168.0.1

Set a custom port for HTTP:

#配置对外提供服务的http端口号

#http.port: 9200

For more information, consult the network module documentation.

--------------------------------- 集群节点发现参数 ----------------------------------

Pass an initial list of hosts to perform discovery when new node is started:

The default list of hosts is [“127.0.0.1”, “[::1]”]

#设置集群中master节点的初始列表,通过这个配置可以发现新加入的集群的节点。

#discovery.zen.ping.unicast.hosts: [“host1”, “host2”]

Prevent the “split brain” by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):

#保证集群中的节点可以知道其他n个有master资格的节点,防止出现split brain,默认为1

#discovery.zen.minimum_master_nodes:

For more information, consult the zen discovery module documentation.

---------------------------------- Gateway -----------------------------------

Block initial recovery after a full cluster restart until N nodes are started:

#当n个节点启动后,再开始集群的恢复

#gateway.recover_after_nodes: 3

For more information, consult the gateway module documentation.

---------------------------------- Various -----------------------------------

Require explicit names when deleting indices:

#action.destructive_requires_name: true

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)

img

读者福利

由于篇幅过长,就不展示所有面试题了,感兴趣的小伙伴

35K成功入职:蚂蚁金服面试Java后端经历!「含面试题+答案」

35K成功入职:蚂蚁金服面试Java后端经历!「含面试题+答案」

35K成功入职:蚂蚁金服面试Java后端经历!「含面试题+答案」

更多笔记分享

35K成功入职:蚂蚁金服面试Java后端经历!「含面试题+答案」
《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》点击传送门即可获取!
le=“zoom: 33%;” />

读者福利

由于篇幅过长,就不展示所有面试题了,感兴趣的小伙伴

[外链图片转存中…(img-aMToZdLn-1711967586074)]

[外链图片转存中…(img-2E2O9LYV-1711967586075)]

[外链图片转存中…(img-UpWYHMg9-1711967586075)]

更多笔记分享

[外链图片转存中…(img-hX0HTQlb-1711967586076)]
《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》点击传送门即可获取!

  • 21
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值