Elasticsearch安装(Linux)
原创
©著作权归作者所有:来自51CTO博客作者后端码匠的原创作品,请联系作者获取转载授权,否则将追究法律责任
目录
简介
Elasticsearch 是一个分布式可扩展的实时搜索和分析引擎,一个建立在全文搜索引擎 Apache Lucene™ 基础上的搜索引擎.当然 Elasticsearch 并不仅仅是 Lucene 那么简单,它不仅包括了全文搜索功能,还可以进行以下工作:
- 分布式实时文件存储,并将每一个字段都编入索引,使其可以被搜索。
- 实时分析的分布式搜索引擎。
- 可以扩展到上百台服务器,处理PB级别的结构化或非结构化数据
面对这样复杂的搜索业务和数据量,使用传统数据库搜索就显得力不从心,一般我们都会使用全文检索技术,比如Solr,Elasticsearch。
Elastic官网:https://www.elastic.co/cn/
Elastic有一条完整的产品线及解决方案:Elasticsearch
、Kibana
、Logstash
等,前面说的三个就是大家常说的ELK技术栈。
Elasticsearch
(官网:https://www.elastic.co/cn/products/elasticsearch
)是Elastic Stack 的核心技术。详细介绍参考官网
Elasticsearch具备以下特点:
-
分布式
,无需人工搭建集群
(solr就需要人为配置,使用Zookeeper作为注册中心) -
Restful风格
,一切API都遵循Rest原则,容易上手近实时搜索,数据更新在Elasticsearch中几乎是完全同步的。
安装
官网下载,选择linux版本:
https://www.elastic.co/cn/products/elasticsearch
我下载完放在了 usr/dev文件夹下
解压
tar -zxvf elasticsearch-7.12.0-linux-x86_64.tar.gz
重命名
mv elasticsearch-7.12.0 elasticsearch
为elaticsearch创建用户并赋予相应权限
此时在 bin/dev
文件夹下
adduser es
passwd es
chown -R es:es elasticsearch/
chmod
文件目录
配置文件都在config
文件夹下
编辑elasticsearch.yml修改数据和日志目录
# 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:
#
cluster.name: my-application #默认是被注释的,并且默认有一个集群名
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1 #配置当前es节点名称(默认是被注释的,并且默认有一个节点名)
#
# 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: /home/es/data # 数据目录位置 注意把这两文件夹的权限给es用户
#
# Path to log files:
#
path.logs: /home/es/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: 0.0.0.0 #绑定的ip:默认只允许本机访问,修改为0.0.0.0后则可以远程访问
#
# 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"] #默认是被注释的 设置master节点列表 用逗号分隔
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
node.name: node-1 #配置当前es节点名称(默认是被注释的,并且默认有一个节点名)
cluster.name: my-application #默认是被注释的,并且默认有一个集群名
path.data: /home/es/data # 数据目录位置
path.logs: /home/es/logs # 日志目录位置
network.host: 0.0.0.0 #绑定的ip:默认只允许本机访问,修改为0.0.0.0后则可以远程访问
cluster.initial_master_nodes: [“node-1”, “node-2”] #默认是被注释的 设置master节点列表 用逗号分隔
启动
此时在elasticsearch文件夹下