请一定要更新JDK到最新版本

我们去官网https://www.elastic.co/cn/elasticsearch/下载最新版本的软件包并解压软件包。
然后启动运行elasticsearch

./bin/elasticsearch

首先会报一个错误:

[ERROR][o.e.b.Bootstrap] [01] Exception
java.lang.RuntimeException: can not run elasticsearch as root

这是因为我们不能以root用户进行运行导致的。我们只需新增一个用户赋予新用户启动elasticsearch的权限即可。

useradd esuser
passwd esuser
//先移动elasticsearch到usr/local/elasticsearch下
mv elasticsearch usr/local/elasticsearch
//然后进行赋权
chown -R esuser:esuser usr/local/elasticsearch
//之后切换到新建用户进行启动即可
su esuser
./usr/local/elasticsearch/bin/elasticsearch

启动报错,内容如下:

  ERROR: [3] bootstrap checks failed. You must address the points described in the following [3] lines before starting Elasticsearch.bootstrap check failure [1] of [3]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]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 configuredERROR: Elasticsearch did not exit normally - check the logs at /opt/elasticsearch/logs/elasticsearch.log

大致是说我们3个配置没有做,也对,刚下载解压后直接运行,肯定会有很多问题:

  1. bootstrap check failure 1 of [3]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

这个是说ElasticSearch进程的最大文件描述大小需要65535,而当前是4096,解决办法是修改 /etc/security/limits.conf 文件,在末尾加上(存在则修改,数值不能比要求的小):

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

如果limits.conf文件无法修改,可尝试修改文件权限之后再次修改,如还是不行,则可进行临时修改。命令如下:

ulimit -n 65535 //临时修改最大打开文件数
ulimit -Hn 4096 //临时修改最大进程数
  1. bootstrap check failure [2] of [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

这是说最大虚拟内存太小(vm.max_map_count配置),至少需要262144,当前为65530,解决办法是修改 /etc/sysctl.conf 文件,在末尾加上(存在则修改,数值不能比要求的小):

vm.max_map_count=262144//随后执行以下命令,立即生效
/sbin/sysctl -p
  1. 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

这是说我们没有对ElasticSearch发现进行配置,至少需要配置discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes中的一个:

  • discovery.seed_hosts:集群节点列表,每个值应采用host:port或host的形式(其中port默认为设置transport.profiles.default.port,如果未设置则返回transport.port)
  • discovery.seed_providers:集群节点列表的提供者,作用就是获取discovery.seed_hosts,比如使用文件指定节点列表
  • cluster.initial_master_nodes:初始化时master节点的选举列表,一般使用node.name(节点名称)配置指定,配置旨在第一次启动有效,启动之后会保存,下次启动会读取保存的数据

比如这里我全部的配置如下(config/elasticsearch.yml),更多配置参考官网:https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html

    # 启动地址,如果不配置,只能本地访问network.host: 0.0.0.0# 节点名称node.name: node-name# 节点列表discovery.seed_hosts: ["你的子服务器ip"]# 初始化时master节点的选举列表cluster.initial_master_nodes: [ "node-name" ]# 集群名称cluster.name: cluster-name# 对外提供服务的端口http.port: 9200# 内部服务端口transport.port: 9300    # 跨域支持http.cors.enabled: true# 跨域访问允许的域名地址(正则)http.cors.allow-origin: /.*/#设置索引数据的存储路径path.data: /usr/local/elasticsearch/data#设置日志的存储路径path.logs: /usr/local/elasticsearch/logs#设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点discovery.zen.ping.unicast.hosts: ["127.0.0.1","你的ip:9200"]
注:如果还报上面1、2的异常,那可能需要重启一下系统了。

接着启动,结果提示jdk版本不对,原来我自己配置了环境变量JAVA_HOME,而ElasticSearch就是用了这个环境变量对应的java来运行,即发现jdk版本不对,另外还warning,JAVA_HOME环境变量已经弃用了,使用ES_JAVA_HOME代替:

  warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOMEFuture versions of Elasticsearch will require Java 11; your Java version from [/opt/jdk1.8.0_202/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.

因为ElasticSearch包中包含了JDK,所以我们可以直接使用,有两种使用办法:

1、添加环境变量ES_JAVA_HOME指向ElasticSearch包中包含了JDK目录

2、修改bin/elasticsearch-env中代码,我们注释掉JAVA_HOME部分的判断:

一切配置完成之后,重启服务器并启动elasticsearch。访问你的elasticsearch地址,如http://192.168.0.1:9200,如果出现以下json串就表示安装成功啦!

{"name": "node-1","cluster_name": "linlianlai","cluster_uuid": "YBKSt_D3SGywU7YyJ3Xeog","version": {"number": "7.16.0","build_flavor": "default","build_type": "tar","build_hash": "6fc81662312141fe7691d7c1c91b8658ac17aa0d","build_date": "2021-12-02T15:46:35.697268109Z","build_snapshot": false,"lucene_version": "8.10.1","minimum_wire_compatibility_version": "6.8.0","minimum_index_compatibility_version": "6.0.0-beta1"},"tagline": "You Know, for Search"
}

一文教懂你关于Elasticsearch的安装配置相关推荐

  1. Web基础配置篇(十二): Elasticsearch的安装配置及入门使用

    Web基础配置篇(十二): Elasticsearch的安装配置及入门使用 一.概述 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RE ...

  2. snmp的团体名配置_小白都能看懂的Linux系统下安装配置Zabbix

    实验环境: 操作系统:Centos 7.6 服务器ip:192.168.10.100 运行用户:root 网络环境:Internet Zabbix是一个基于web界面的提供分布式系统监控及网络功能的企 ...

  3. elasticsearch 安装配置

    ------------20211208---------es允许远程访问-------------------------- 在本地启动Elasticsearch后,发现只能用localhost和1 ...

  4. ELK日志平台一 ElasticSearch的安装

    一.安装 ElasticSearch的版本号从 1.X → 2.X →  5.X  →  6.X 其中ES 5.X开始支持的jdk最低版本为jdk1.8 官网下载地址:https://www.elas ...

  5. 最新版elasticsearch的安装踩坑

    elasticearch是目前最流行的实时的分布式搜索和分析引擎,水平扩展能力非常强,提供restful接口简化使用难度. 文档 学习一个技术最好的方式就是阅读官方文档,英语没有那么好的最好方式就是看 ...

  6. Elasticsearch 安装配置 外网访问 及 后台启动

    本文转自http://www.jianshu.com/p/658961f707d8 作者:咪博士 感谢咪博士分享 Elasticsearch的安装总体来说还是相当简单的,当然中间也会有些小坑.不过大家 ...

  7. ElasticSearch docker安装

    文章目录 五.安装ElasticSearch 5.1. 修改服务器配置 5.2. 创建容器并启动 ES 5.3. 查看启动日志 5.4. 进入镜像 5.5. 修改cluster-name 5.6. 安 ...

  8. Elasticsearch单机安装Version7.10.1

    1.说明 Elasticsearch单机安装, 基于Elasticsearch的7.10.1版本, 在Linux上安装Elasticsearch单机, 使用安装包elasticsearch-7.10. ...

  9. Elasticsearch单机安装

    Elasticsearch单机安装, 基于Elasticsearch6.2.2版本, 在Linux上安装Elasticsearch单机. 1.安装规划 vi /etc/hosts 10.43.159. ...

最新文章

  1. VS2013 解决方案文件结构分析
  2. Storyboard更改layer层属性
  3. mysql配置文件构成以及具体的配置demo
  4. 1071 mysql_mysql 出现1071错误怎么办
  5. 【论文解读】Yoshua Bengio最新修改版论文:迈向生物学上可信的深度学习
  6. sass笔记-1|Sass是如何帮你又快又好地搞定CSS的
  7. Snap Shots 出了新东西
  8. 竞争者都是 飞鸽传书 高手
  9. Spring Security 5.0.0正式发布
  10. 这些小工具让你的Android开发更高效
  11. Struts2升级版本至2.5.10,高危漏洞又来了
  12. vivox50支持鸿蒙,vivo X50系列极致轻薄的机身下,还有哪些功能和亮点?
  13. Java实现Map转List
  14. Win10插入U盘无反应,但是U盘是正常的解决方法
  15. redis下载(windows版)
  16. return 和return:redirect:/**
  17. SAP FICO 解析成本要素类别
  18. 使用Python解析JSON
  19. c语言dht网络爬虫,用Node.js实现一个DHT网络爬虫,一步一步完成一个BT搜索引擎(一)...
  20. pyspark--创建DataFrame

热门文章

  1. 对钙铀云母放射强度的测量
  2. R 语言 双坐标轴做法
  3. findBug 错误修改指南
  4. 从公式到代码理解opencv和基于opencv实现的fastest pattern mathing的关系
  5. 10_linux内核定时器实验
  6. 知道了域名怎么查备案号
  7. STS 编辑器与Myeclipse工作空间冲突问题
  8. JAVA 两个变量值的交换
  9. 自动编码器(AE、SDA、SDAE)的理解
  10. 【教程搬运】最好的GAN系列教程在这里。