Elasticsearch02:ES安装部署【单机】

一、ES安装部署【单机】

1、下载

ES支持单机和集群,在使用层面是完全一样的。
首先下载ES的安装包,目前ES最新版本是7.x,在这使用7.13.4版本。

(1)百度网盘地址:

链接:https://pan.baidu.com/s/1rnvMTGm5CYAh0GfdNDHx-g?pwd=d8xv 
提取码:d8xv 

(2)官网下载地址:

https://www.elastic.co/cn/downloads/past-releases#elasticsearch

选择ES的对应版本。
在这里插入图片描述
ES 7.13.4版本的安装包下载地址为:

https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.13.4-linux-x86_64.tar.gz

注意:目前ES中自带的有open JDK,不用单独安装部署Oracle JDK。

在这里插入图片描述

2、分析一下ES中的核心配置文件

在具体安装集群之前,先来分析一下ES中的核心配置文件:
在ES_HOME的config目录下有一个elasticsearch.yml配置文件,这个文件是一个yaml格式的文件。
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
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
# 集群名称,默认是elasticsearch,如果想要将多个ES实例组成一个集群,那么它们的cluster.name必须一致
#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):
# 可以指定ES的数据存储目录,默认存储在ES_HOME/data目录下
#path.data: /path/to/data
#
# Path to log files:
# 可以指定ES的日志存储目录,默认存储在ES_HOME/logs目录下
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
# 锁定物理内存地址,防止ES内存被交换出去,也就是避免ES使用swap交换分区中的内存
#bootstrap.memory_lock: true
# 确保ES_HEAP_SIZE参数设置为系统可用内存的一半左右
# 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.
# 当系统进行内存交换的时候,会导致ES的性能变的很差
# 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:
# 为ES设置绑定的IP,默认是127.0.0.1,也就是默认只能通过127.0.0.1 或者localhost才能访问
# ES 1.x版本默认绑定的是0.0.0.0,但是从ES 2.x版本之后默认绑定的是127.0.0.1
#network.host: 192.168.0.1
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
# 为ES服务设置监听的端口,默认是9200
# 如果想要在一台机器上启动多个ES实例,需要修改此处的端口号
#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]"]
# 
# 当启动新节点时,通过这个ip列表进行节点发现,组建集群
# 默认ip列表:
# 	127.0.0.1,表示ipv4的本地回环地址。
#	[::1],表示ipv6的本地回环地址。
# 在ES 1.x中默认使用的是组播(multicast)协议,默认会自动发现同一网段的ES节点组建集群。
# 从ES 2.x开始默认使用的是单播(unicast)协议,想要组建集群的话就需要在这指定要发现的节点信息了。
# 
# 指定想要组装成一个ES集群的多个节点信息
#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.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
# 禁止使用通配符或_all删除索引, 必须使用名称或别名才能删除该索引。
#action.destructive_requires_name: true

1、上传安装包

将ES的安装包上传到bigdata01的/data/soft目录下

[root@bigdata01 soft]# ll elasticsearch-7.13.4-linux-x86_64.tar.gz 
-rw-r--r--. 1 root root 327143992 Sep  2  2021 elasticsearch-7.13.4-linux-x86_64.tar.gz 

2、创建es用户

在Linux中添加一个普通用户:es。
因为ES目前不支持root用户启动。

[root@bigdata01 soft]# useradd -d /home/es -m es
[root@bigdata01 soft]# passwd es
Changing password for user es.
New password: bigdata1234
Retype new password: bigdata1234
passwd: all authentication tokens updated successfully.

3、修改参数

修改Linux中最大文件描述符以及最大虚拟内存的参数

因为ES对Linux的最大文件描述符以及最大虚拟内存有一定要求,所以需要修改,否则ES无法正常启动。

[root@bigdata01 soft]# vi /etc/security/limits.conf 
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
[root@bigdata01 soft]# vi /etc/sysctl.conf
vm.max_map_count=262144

4、重启系统

重启Linux系统。
前面修改的参数需要重启系统才会生效。

[root@bigdata01 soft]# reboot -h now

5、解压安装包

解压ES安装包

[root@bigdata01 soft]# tar -zxvf elasticsearch-7.13.4-linux-x86_64.tar.gz

6、配置java环境变量

配置ES_JAVA_HOME环境变量,指向ES中内置的JDK。

[root@bigdata01 soft]# vi /etc/profile
......
export ES_JAVA_HOME=/data/soft/elasticsearch-7.13.4/jdk
......
[root@bigdata01 soft]# source /etc/profile

7、修改目录权限

修改elasticsearch-7.13.4目录的权限

因为前面是使用root用户解压的,elasticsearch-7.13.4目录下的文件es用户是没有权限的。

[root@bigdata01 soft]# chmod 777 -R /data/soft/elasticsearch-7.13.4

8、切换用户

切换到es用户

[root@bigdata01 soft]# su es

9、修改配置文件

修改elasticsearch.yml配置文件内容

主要修改network.host、discovery.seed_hosts这两个参数。

注意:yaml文件的格式,参数和值之间需要有一个空格。

例如:network.host: bigdata01
bigdata01前面必须要有一个空格,否则会报错。

[es@bigdata01 soft]$ cd elasticsearch-7.13.4
[es@bigdata01 elasticsearch-7.13.4]$ vi config/elasticsearch.yml 
......
network.host: bigdata01
discovery.seed_hosts: ["bigdata01"]

10、前台启动

启动ES服务【前台启动】

[es@bigdata01 elasticsearch-7.13.4]$ bin/elasticsearch

按ctrl+c停止服务。

11、后台启动

启动ES服务【后台启动】
在实际工作中需要将ES放在后台运行。

[es@bigdata01 elasticsearch-7.13.4]$ bin/elasticsearch -d

12、验证

验证ES服务。
通过jps命令验证进程是否存在。

[es@bigdata01 elasticsearch-7.13.4]$ jps
1849 Elasticsearch

通过web界面验证服务是否可以正常访问,端口为9200。
http://bigdata01:9200/

在这里插入图片描述
注意:需要关闭防火墙。

13、停止

停止ES服务。
使用kill命令停止。

[es@bigdata01 elasticsearch-7.13.4]$ jps
1849 Elasticsearch
[es@bigdata01 elasticsearch-7.13.4]$ kill 

14、查看日志

日志排查方式。
如果发现ES服务启动有问题,需要查看ES的日志。
ES的相关日志都在ES_HOME的logs目录下,ES服务的核心日志在elasticsearch.log日志文件中。

[root@bigdata01 elasticsearch-7.13.4]# cd logs/
[root@bigdata01 logs]# ll
total 208
-rw-rw-r--. 1 es es 0 Feb 26 10:48 elasticsearch_audit.json
-rw-rw-r--. 1 es es   554 Feb 26 11:20 elasticsearch_deprecation.json
-rw-rw-r--. 1 es es   332 Feb 26 11:20 elasticsearch_deprecation.log
-rw-rw-r--. 1 es es     0 Feb 26 10:48 elasticsearch_index_indexing_slowlog.json
-rw-rw-r--. 1 es es     0 Feb 26 10:48 elasticsearch_index_indexing_slowlog.log
-rw-rw-r--. 1 es es     0 Feb 26 10:48 elasticsearch_index_search_slowlog.json
-rw-rw-r--. 1 es es     0 Feb 26 10:48 elasticsearch_index_search_slowlog.log
-rw-rw-r--. 1 es es 23653 Feb 26 11:10 elasticsearch.log
-rw-rw-r--. 1 es es 42094 Feb 26 11:10 elasticsearch_server.json
-rw-rw-r--. 1 es es 37878 Feb 26 11:10 gc.log
-rw-rw-r--. 1 es es  1996 Feb 26 10:48 gc.log.00
-rw-rw-r--. 1 es es 85728 Feb 26 11:37 gc.log.01
-rw-rw-r--. 1 es es  1996 Feb 26 11:10 gc.log.02
  • 4
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
很抱歉,目前最新版本的 Elasticsearch 是 7.15.1,没有 8.5.3 版本。不过我可以为您介绍一下 Elasticsearch单机安装部署步骤。 1. 下载 Elasticsearch:您可以从 Elasticsearch 官方网站(https://www.elastic.co/downloads/elasticsearch)下载适合您操作系统的安装包。 2. 解压安装包:将下载的安装包解压到您选择的目录中。 3. 配置 Elasticsearch:进入解压后的目录,找到 `config` 文件夹,编辑 `elasticsearch.yml` 文件。您可以根据需要修改以下配置项: - `cluster.name`:集群名称,默认为 "elasticsearch"。 - `node.name`:节点名称,默认为随机生成的唯一标识。 - `path.data`:数据存储路径,默认为 "data" 文件夹。 - `path.logs`:日志存储路径,默认为 "logs" 文件夹。 4. 启动 Elasticsearch:在命令行中进入 Elasticsearch 的 bin 目录,执行以下命令启动 Elasticsearch: - Windows:`.\elasticsearch.bat` - Linux/MacOS:`./elasticsearch` 5. 验证安装:打开浏览器,访问 `http://localhost:9200`,如果看到类似以下信息表示 Elasticsearch 已成功启动: ``` { "name" : "your_node_name", "cluster_name" : "your_cluster_name", "cluster_uuid" : "your_cluster_uuid", "version" : { "number" : "7.15.1", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "unknown", "build_date" : "2021-10-07T21:56:19.031608185Z", "build_snapshot" : false, "lucene_version" : "8.9.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" } ``` 这样就完成了 Elasticsearch单机安装部署

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

做一个有趣的人Zz

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值