当前位置:   article > 正文

es(Elasticsearch)安装使用(01es安装篇)

es安装

1.ES介绍

           Elasticsearch是一个基于Apache Lucene的开源搜索引擎。Lucene可以被认为是迄今为止最先进、性能最好的、功能最全的搜索引擎库。 特点: 分布式的实时文件存储,每个字段都被索引并可被搜索 分布式的实时分析搜索引擎--做不规则查询 可以扩展到上百台服务器,处理PB级结构化或非结构化数据 Elasticsearch也使用Java开发并使用Lucene作为其核心来实现所有索引和搜索的功能,但是它的目的是通过简单的RESTful API来隐藏Lucene的复杂性,从而让全文搜索变得简单。

同类产品

 Solr、ElasticSearch、 Solr、ES 1. 源自搜索引擎,侧重搜索与全文检索。 2. 数据规模从几百万到千万不等,数据量过亿的集群特别少。 有可能存在个别系统数据量过亿,但这并不是普遍现象(就像Oracle的表里的数据规模有可能超过Hive里一样,但需要小型机)。 Hermes 1. 一个基于大索引技术的海量数据实时检索分析平台。侧重数据分析。 2. 数据规模从几亿到万亿不等。最小的表也是千万级别。 在 腾讯17 台TS5机器,就可以处理每天450亿的数据(每条数据1kb左右),数据可以保存一个月之久。 Solr、ES区别 全文检索、搜索、分析。基于lucene Solr 利用 Zookeeper 进行分布式管理,而 Elasticsearch 自身带有分布式协调管理功能; Solr 支持更多格式的数据,而 Elasticsearch 仅支持json文件格式; Solr 官方提供的功能更多,而 Elasticsearch 本身更注重于核心功能,高级功能多有第三方插件提供; Solr 在传统的搜索应用中表现好于 Elasticsearch,但在处理实时搜索应用时效率明显低于 Elasticsearch-----附近的人 Lucene是一个开放源代码的全文检索引擎工具包,但它不是一个完整的全文检索引擎,而是一个全文检索引擎的架构,提供了完整的查询引擎和索引引擎,部分文本分析引擎 搜索引擎产品简介

采用倒排索引

文章推荐

es(Elasticsearch)安装使用(01es安装篇)_少年ing的博客-CSDN博客

 es(Elasticsearch)客户端Kibana安装使用(02Kibana安装篇)_少年ing的博客-CSDN博客

es(Elasticsearch)安装使用(03ik分词器安装篇)_少年ing的博客-CSDN博客

es(Elasticsearch)客户端Elasticsearch-head安装使用(04Elasticsearch-head安装篇)_少年ing的博客-CSDN博客

2.ES官网

ES官网: es官网

3.ES安装

版本声明

CenOS:7.5;
JDK:1.8;
Elasticsearch:7.6.1;

安装环境 centos 7.5   关闭了防火墙

依赖java jdk  1.8

下载安装包

官网下载安装包

官网地址:Past Releases of Elastic Stack Software | Elastic

某云盘下载 链接:https://pan.baidu.com/s/17SEfp1CgwA8s7XMJdyhBag
提取码:507j

一开始 下载最新包 8.3.3 和本地jdk 版本不符起不來具体原因没深入研究  又下载安装的7.6.1 版本

安装

解压到指定目录 /usr/local/  

tar -zxvf elasticsearch-7.6.1-linux-x86_64.tar.gz  -C /usr/local/

解压后

先采用默认配置 启动 看是否能启动成功    进入解压目录启动

关闭窗口 和 ctrl+c   停止es服务

./bin/elasticsearch

关闭窗口 和 ctrl+c   停止es服务 

守护进程启动 无启动信息   关闭 采用 kill -9 进程号方式

 ./bin/elasticsearch -d

 

    关闭 采用 kill -9 进程号方式

核验安装是否成功    如果是阿里云服务器 记得安全组打开9200端口 要不然外网也是无法访问

 查看9200端口是否启用、监听

netstat -nltp | grep 9200

查看安装信息

curl 127.0.0.1:9200

注意:ES需要使用两个端口

  • 9200:HTTP协议,restful api
  • 9300:tcp协议,使用java客户端使用9300端口连接 

 浏览器查看基本信息  ip:9200

 健康检查

ip:9200/_cat/health

 查看所有索引

ip:9200/_cat/indices

查看所有节点

ip:9200/_cat/nodes

配置文件

 外网不能访问 修改配置文件

  1. # ======================== Elasticsearch Configuration =========================
  2. #
  3. # NOTE: Elasticsearch comes with reasonable defaults for most settings.
  4. # Before you set out to tweak and tune the configuration, make sure you
  5. # understand what are you trying to accomplish and the consequences.
  6. #
  7. # The primary way of configuring a node is via this file. This template lists
  8. # the most important settings you may want to configure for a production cluster.
  9. #
  10. # Please consult the documentation for further information on configuration options:
  11. # https://www.elastic.co/guide/en/elasticsearch/reference/index.html
  12. #
  13. # ---------------------------------- Cluster -----------------------------------
  14. #
  15. # Use a descriptive name for your cluster:
  16. #
  17. cluster.name: my-application
  18. #
  19. # ------------------------------------ Node ------------------------------------
  20. #
  21. # Use a descriptive name for the node:
  22. #
  23. node.name: node-1
  24. #
  25. # Add custom attributes to the node:
  26. #
  27. #node.attr.rack: r1
  28. #
  29. # ----------------------------------- Paths ------------------------------------
  30. #
  31. # Path to directory where to store the data (separate multiple locations by comma):
  32. #
  33. #path.data: /path/to/data
  34. #
  35. # Path to log files:
  36. #
  37. #path.logs: /path/to/logs
  38. #
  39. # ----------------------------------- Memory -----------------------------------
  40. #
  41. # Lock the memory on startup:
  42. #
  43. bootstrap.memory_lock: false
  44. #
  45. # Make sure that the heap size is set to about half the memory available
  46. # on the system and that the owner of the process is allowed to use this
  47. # limit.
  48. #
  49. # Elasticsearch performs poorly when the system is swapping the memory.
  50. #
  51. # ---------------------------------- Network -----------------------------------
  52. #
  53. # Set the bind address to a specific IP (IPv4 or IPv6):
  54. #
  55. network.host: 127.0.0.1
  56. network.bind_host: 0.0.0.0
  57. network.publish_host: 127.0.0.1
  58. #
  59. # Set a custom port for HTTP:
  60. #
  61. http.port: 9200
  62. #
  63. # For more information, consult the network module documentation.
  64. #
  65. # --------------------------------- Discovery ----------------------------------
  66. #
  67. # Pass an initial list of hosts to perform discovery when this node is started:
  68. # The default list of hosts is ["127.0.0.1", "[::1]"]
  69. #
  70. discovery.seed_hosts: ["127.0.0.1"]
  71. #
  72. # Bootstrap the cluster using an initial set of master-eligible nodes:
  73. #
  74. cluster.initial_master_nodes: ["node-1"]
  75. #
  76. # For more information, consult the discovery and cluster formation module documentation.
  77. #
  78. # ---------------------------------- Gateway -----------------------------------
  79. #
  80. # Block initial recovery after a full cluster restart until N nodes are started:
  81. #
  82. #gateway.recover_after_nodes: 3
  83. #
  84. # For more information, consult the gateway module documentation.
  85. #
  86. # ---------------------------------- Various -----------------------------------
  87. #
  88. # Require explicit names when deleting indices:
  89. #
  90. #action.destructive_requires_name: true

4.安裝中出现的错误处理

 1.1 java.lang.RuntimeException: can not run elasticsearch as root

不能用root启动  创建es用户  使用root账户创建es用户  已创建es用户 此处记录下创建es2

   给es用户授权,目录elasticsearch-7.6.1 (重要) 切换es命令来启动

sudo chown -R  es:es elasticsearch-7.6.1/

切换es用户 启动

3.切换es账号,启动服务
su es
./bin/elasticsearch

后台运行,否则客户端退出了,服务就停止了。
./bin/elasticsearch -d
出现started时启动完成

关闭ES服务
kill pid

说明:
Elasticsearch端口9300、9200,其中:
9300是tcp通讯端口,集群ES节点之间通讯使用,9200是http协议的RESTful接口

问题2 需要使用jdk11 我安装的是1.8  不想换jdk 使用es默认的 改配置

future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/jdk1.8.0_1/jre] does not meet this requirement

使用ES7版本时,启动或者执行ES命令,提示上面错误信息。这是由于ES7使用的高版本的jdk。如果不想升级服务的jdk,可以通过修改elasticsearch-env配置文件,使用ES内置的jdk来解决上面的问题

vim elasticsearch-env

# now set the path to java
if [ ! -z "$JAVA_HOME" ]; then
  JAVA="$ES_HOME/jdk/bin/java"
  JAVA_TYPE="JAVA_HOME"
else
  if [ "$(uname -s)" = "Darwin" ]; then
    # macOS has a different structure
    JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java"
  else
    JAVA="$ES_HOME/jdk/bin/java"
  fi  
  JAVA_TYPE="bundled jdk"
fi

 3. 解决内存不足问题,启动的时候卡住的原因了,warning: ignoring JAVA_HOME=/usr/local/jdk1.8.0_131; using bundled JDK

 vim jvm.options

 4.max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

bootstrap check failure [1] of [3]: max number of threads [2048] for user [es] is too low, increase to at least [4096]
bootstrap check failure [2] of [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
bootstrap check failure [3] of [3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

使用root账户 修改配置

1.修改limits.conf

vim /etc/security/limits.conf

 最后添加

* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
* soft stack 65535
* hard stack 65535

  ulimilt -a    发现没生效

退出root账户登录重登后生效;su root

 2. 修改 sysctl.conf     vm.max_map_count >= 262144

vim /etc/sysctl.conf

 在最下面添加 

vm.max_map_count=2655350

 保存,然后重新加载参数:

sysctl -p

目录介绍

目录结构说明
• home目录 :使用$ES_HOME表示,如上图,就是 /usr/local/elasticsearch
• bin/ : 位置 $ES_HOME/bin,包含了elasticsearch和elasticsearch-plugin等脚本
• conf/ :位置 $ES_HOME/config,包含了 配置文件 elasticsearch.yml 和 log4j2.properties,使用 path.conf 指定
• data/ :位置 $ES_HOME/data,包含了每个index/shard的数据文件,可以指定多个位置,使用 path.data 指定
• logs/ : 位置 $ES_HOME/logs,使用 path.logs 指定
• plguins/ : 位置$ES_HOME/plugins
• repo/ :使用 path.repo指定,没有默认位置,表示共享文件系统repository的位置。可以指定多个位置。
• script/ :位置$ES_HOME/scripts,使用 path.scripts 指定。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/887984
推荐阅读
相关标签
  

闽ICP备14008679号