欢迎投稿

今日深度:

Elasticsearch02:ES安装部署【单机】,首先下载ES的安装包

Elasticsearch02:ES安装部署【单机】,首先下载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

www.htsjk.Com true http://www.htsjk.com/Elasticsearch/45773.html NewsArticle Elasticsearch02:ES安装部署【单机】,首先下载ES的安装包 一、ES安装部署【单机】 1、下载 ES支持单机和集群在使用层面是完全一样的。 首先下载ES的安装包目前ES最新版本是7.x在这使用...
评论暂时关闭