Elasticsearch 单节点部署教程,以及踩坑记录_elasticsearch单节点配置

img
img

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

Elasticsearch 更新迭代速度非常快,并且不同版本有着很大区别,**Elasticsearch7.x 版本以后都会自带jdk,因此在Elasticsearch7.x以后不需要考虑jdk版本兼容问题;Elasticsearch8.x默认开启security(无论是生产环境还是开发环境都会带上),**由此对于Elasticsearch的使用安全性增加很多要求,本文将从两个方面(开启security、关闭security)介绍Elasticsearch的安装和使用。本文使用 Elasticsearch-8.3.3 版本。

2、Elasticsearch 和 jdk 版本/操作系统之间的对应关系

从7.x开始,以后的版本ES均自带jdk,所以可即使不安装jdk也可正常运行ES。对于 ES 8.0 而言,JDK版本只有一个选择,即 JDK 17;对于 ES 8.1 及以上版本而言,支持 JDK 17、JDK 18。

ES和JDK兼容性见网址:支持一览表 | Elastic(国内jdk镜像:WEJDK学习站

操作系统的兼容性见网址:支持一览表 | Elastic

自身以及一些管理工具兼容性:支持一览表 | Elastic

3、Elasticsearch 的下载与安装
3.1、Elasticsearch 下载

Elasticsearch 下载地址:Past Releases of Elastic Stack Software | Elastic

3.2、Elasticsearch 安装

注:Elasticsearch 不支持 root 用户启动,需要新建用户,并且赋予新的用户权限,才可以启动Elasticsearch(这些操作在root用户下进行)。

# 1、解压到指定目录下(opt)(本文使用 elasticsearch-8.3.3 版本) 
tar -zxvf elasticsearch-8.3.3-linux-x86_64.tar.gz -C /opt
# 2、新建用户
useradd elasticsearch
passwd elasticsearch  # 给新建的用户设置密码
# 3、给elasticsearch目录设置新用户
chown elasticsearch:elasticsearch -R elasticsearch-8.3.3/
3.3、Elasticsearch 目录结构解释
目录名称说明
bin可执行脚本文件目录
config配置文件目录
lib依赖包目录
data默认数据保存目录,最好修改
logs默认日志保存目录,最好修改
plugins已经安装的插件保存目录
jdk自带jdk目录
modules所有Elasticsearch模块
3.3、配置文件初解(elasticsearch.yml)
# ---------------------------------- Cluster -----------------------------------
# Use a descriptive name for your cluster:
# cluster.name: my-application
# ------------------------------------ Node ------------------------------------
# Use a descriptive name for the node:
# node.name: node-1
# Add custom attributes to the node:
#node.attr.rack: r1
# ----------------------------------- Paths ------------------------------------
# Path to directory where to store the data (separate multiple locations by comma):
#path.data: /path/to/data
# Path to log files:
#path.logs: /path/to/logs
# ----------------------------------- Memory -----------------------------------
# Lock the memory on startup:
# 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.
# ---------------------------------- Network -----------------------------------
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
network.host: 192.168.0.90
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
http.port: 9200
# For more information, consult the network module documentation.
# --------------------------------- Discovery ----------------------------------
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#discovery.seed_hosts: ["host1", "host2"]
# Bootstrap the cluster using an initial set of master-eligible nodes:
#cluster.initial_master_nodes: ["node-1", "node-2"]
# For more information, consult the discovery and cluster formation module documentation.
# --------------------------------- Readiness ----------------------------------
# Enable an unauthenticated TCP readiness endpoint on localhost
#readiness.port: 9399
# ---------------------------------- Various -----------------------------------
# Allow wildcard deletion of indices:
#action.destructive_requires_name: false
#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------

#----------------------- END SECURITY AUTO CONFIGURATION -------------------------

主要有几个模块:

模块名说明
Cluster配置集群名称
Node配置当前节点信息(节点名称默认主机名
Paths指定数据和日志保存路径
Memory内存使用相关配置
Network网络相关配置(主机ip,端口等)
Discovery集群相关参数配置
BEGIN SECURITY AUTO CONFIGURATIONES8.0默认使用security,启动时添加的配置
’4、Elasticsearch 启动
4.1、直接启动(默认开启security)
4.1.1、不修改配置文件启动

首次启动 Elasticsearch 时,会自动进行以下安全配置:

1)、为传输层和 HTTP 层生成 TLS 证书和密钥;

2)、TLS 配置设置被写入 elasticsearch.yml(BEGIN SECURITY AUTO CONFIGURATION 模块);

3)、为 elastic 用户生成密码。

4)、为 Kibana 生成一个注册令牌。

# 使用 elasticsearch 用户,进入bin目录执行
./elasticsearch -d

启动成功如下图:

验证服务状态,使用生成的密码登录(用户名:elastic,密码启动成功生成的):

4.1.2、修改密码

忘记密码怎么办,使用重新生成或者自定义密码。

# 1、重新生成密码
./elasticsearch-reset-password -u elastic # 可以使用./elasticsearch-reset-password --help查看使用
# 2、自定义密码
./elasticsearch-reset-password --username elastic -i

4.1.3、Elasticsearch 启动后配置文件(elasticsearch.yml)变化

新增如下内容(这些内容是针对security自动添加的):

#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------# 
# Enable security features
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
  enabled: true
  keystore.path: certs/http.p12


![img](https://img-blog.csdnimg.cn/img_convert/e0411f1f812d573e9a25ec0653da3cb0.png)
![img](https://img-blog.csdnimg.cn/img_convert/67153521ca8ec5120f45a7a81951e1d4.png)
![img](https://img-blog.csdnimg.cn/img_convert/f1154d3f1fc20fbc5c556da89779466c.png)

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

**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**

**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**

15670910328)]

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

**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**

**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**

  • 17
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Elasticsearch是一个开源的分布式搜索和分析引擎,可以用于快速和准确地搜索、分析和可视化大量数据。下面是节点部署Elasticsearch的步骤: 1. 下载和安装Java:Elasticsearch是用Java编写的,所以首先需要安装Java。可以前往Oracle官网下载Java,并按照安装向导进行安装。 2. 下载和解压缩Elasticsearch:在Elasticsearch官网下载最新稳定版本的Elasticsearch。将下载的压缩文件解压缩到所需位置。 3. 配置Elasticsearch:进入解压缩后的Elasticsearch目录,打开config目录下的elasticsearch.yml文件。可以编辑该文件以配置Elasticsearch的各种参数,例如集群名称、网络绑定地址等。 4. 启动Elasticsearch:在命令行中进入Elasticsearch目录,并执行bin目录下的elasticsearch.bat(Windows)或elasticsearch命令(Linux/Mac)来启动Elasticsearch。 5. 检查Elasticsearch状态:可以使用curl或浏览器访问http://localhost:9200来检查Elasticsearch的状态是否正常。如果返回类似以下内容表示成功: { "name" : "node-1", "cluster_name" : "myFirstCluster", "cluster_uuid" : "xxxxxxxxxxxxxxxxxxxx", "version" : { "number" : "7.10.2", "build_flavor" : "default", "build_type" : "zip", "build_hash" : "aa7f54684a9c2c91b66f9346176bdfd331cc624b", "build_date" : "2021-01-19T19:19:18.137384Z", "build_snapshot" : false, "lucene_version" : "8.8.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" } 至此,就成功完成了Elasticsearch节点部署。 请注意,在实际生产环境中,节点部署可能无法提供足够的性能和容错能力。通常建议使用多节点集群部署以提高可用性。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值