elasticsearch-7.3.1集群搭建

1、es介绍
ElasticSearch是一个基于Lucene的搜索服务器。提供了分布式多用户的全文搜索引擎,用Java语言开发的,Apache许可条款下的开放源码发布,是一种流行的企业级搜索引擎。
包含如下特性:
分布式高可用搜索引擎:每个索引都可以配置分片的数量。每个分片都有一个或多个副本且分片都支持读写
多租户:支持多个索引以及索引级配置,如碎片数、索引存储等。
提供各种API:包括HTTP Restful API,原生Java API。 Restful风格,容易上手
面向文档:可以通过定义模式来定制索引过程。
可靠,异步写入,可长期持久存储。
近实时性强:数据更新在Elasticsearch中几乎是完全同步的
建在lucene之上:每个分片都是一个全完整的lucene索引,Lucene的所有功能都很容易通过简单的配置/插件看到
操作具有一致性:单文档级操作具有原子性、一致性、独立性和持久性。
2、es7.X新特性
es7.X开始,默认自带 JDK,不用担心环境冲突,下载安装即可用。
默认节点名称为主机名:仍可在elasticsearch.yml中显式配置,实际业务场景中,以主机名区分不同节点比随机起名字更便于甄别,不易混淆。
默认分片数改为number_of_shards值为1,不再是5
es7.X没有 Type 了,包括 API 层面的。
hits.total返回对象,而非仅结果值。
Kibana 支持全局开启“黑暗”模式。
查询相关性速度优化,Weak-AND算法在Term Query查询场景有3700%的性能提升。
间隔查询(Intervals queries)
引入新的集群协调子系统。
升级 Elasticsearch 7,0 ,不再内存溢出。
时间戳纳秒级支持,提升数据精度。
二、下载
下载网址:
https://www.elastic.co/cn/downloads/elasticsearch
在这里插入图片描述
在这里插入图片描述
三、安装与配置
1、准备机器
ip host es
192.168.128.35 master 1
192.168.128.36 slave1 1
192.168.128.37 slave2 1
2、下载安装
(1)建立安装目录
在master、slave1、slave2分别放到安装目录/usr/local
(2)把下载的es压缩包上传到master下的 /usr/local
(3)在master上解压 $ tar -zxvf elasticsearch-7.3.1-linux-x86_64.tar
(4)在每个节点创建用户es(可加密)
创建用户 $ useradd es 设置密码$ echo “123456” | passwd --stdin es
(5)给es用户赋权限 $ chown -R es:es elasticsearch-7.3.1
(6)分发slave1、slave2的/usr/local下
$ scp -r elasticsearch-7.3.1 slave1:/usr/local
$ scp -r elasticsearch-7.3.1 slave2:/usr/local
3、配置elasticsearch.yml
master的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:
#
cluster.name: my-elasticsearch
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: master
node.master: true
node.data: false
#
# 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: /data/elasticsearch/data
#
# Path to log files:
#
path.logs: /data/elasticsearch/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 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.128.35
#
# Set a custom port for HTTP:
#
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: ["192.168.128.35", "192.168.128.36","192.168.128.37"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["192.168.128.35"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#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
#是否支持跨域
http.cors.enabled: true
#*表示支持所有域名
http.cors.allow-origin: "*"

slave1、slave2修改如下,slave2替换下相关项即可

# ======================== 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:
#
cluster.name: my-elasticsearch
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: slave1
node.master: false
node.data: true
#
# 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: /data/elasticsearch/data
#
# Path to log files:
#
path.logs: /data/elasticsearch/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 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.128.36
#
# Set a custom port for HTTP:
#
#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: ["192.168.128.35", "192.168.128.36","192.168.128.37"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["192.168.128.35"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#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
#是否支持跨域
http.cors.enabled: true
#*表示支持所有域名
http.cors.allow-origin: "*"

四、启动es集群
在创建的用户下进行
分别在master、slave1、slave2三个节点中执行命令 $ /usr/local/elasticsearch-7.3.1/bin/elasticsearch -d启动集群,确认启动成功后,启动日志没有报错后,在浏器中输入 http://192.168.128.35:9200/即可。
五、常见错误
启动es过程中失败,日志报如下错误:
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
编辑 $ vim /etc/security/limits.conf,调整增加参数

  •           soft    nofile          65536
    
  •           hard    nofile          65536
    
  •           soft    nproc           4096
    
  •           hard    nproc           4096
    

[2]: max number of threads [1024] for user [es] is too low, increase to at least [4096]
编辑 $ vim /etc/security/limits.d/90-nproc.conf,调整参数

  •      soft    nproc     4096
    

执行 $ sysctl -p 生效
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
编辑 $ vim /etc/sysctl.conf,增加参数
vm.max_map_count=262144
[4]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
编辑 $ vim elasticsearch.yml,增加参数
bootstrap.system_call_filter: false
至此 elasticsearch集群搭建成功。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值