Elasticsearch安装和配置

本文涉及的产品
检索分析服务 Elasticsearch 版,2核4GB开发者规格 1个月
简介: Elasticsearch安装和配置

安装时一定要切换到普通用户(非root账号),减少错误发生。

下载地址

选择对应版本即可 https://www.elastic.co/downloads/elasticsearch ,这边官网下载太慢了,大家可以选择华为云 https://mirrors.huaweicloud.com/elasticsearch/7.6.0/ ,我这边是 ubuntu 就直接下载 linux 版本了。

elasticsearch 是要依赖 java 的,如果大家没有安装,下载高版本后自带。

目录结构说明

目录 配置文件 描述
bin 脚步文件,包括启动elasticsearch,安装插件,运行统计数据等
config elasticsearch.yml 集群配置文件,user,role based 相关配置
JDK Java运行环境
data path.data 数据文件
lib Java类库
logs path.log 日志文件
modules 包含所有ES模块
plugins 包含所有已安装插件
  • 修改JVM配置
vi config/jvm.options
# 默认配置是1GB
# 生产环境配置建议 
# 1. Xms和Xms设置成一样
# 2. Xmx不要超过机器内存的50%
# 3. 最好不要超过30GB 官网有说明
  • 启动elasticsearch
./bin/elasticsearch

安装Elasticsearch插件

  • 安装analysis-icu插件
./bin/elasticsearch-plugin install analysis-icu
  • 查看已安装插件
./bin/elasticsearch-plugin list
  • api查看 访问 host:9200/_cat/plugins


可以利用插件做备份、安全等,还是挺不错的。

安装错误处理

启动后访问不了9200端口?

  1. 如果采用云服务器,请先设置服务器的出入端口 确保9200已经允许出入
  2. 修改config/elasticsearch.yml中的network.host: 0.0.0.0 允许所有访问即可

报错elasticsearch启动报错Exception in thread "main" java.nio.file.AccessDeniedException

Exception in thread "main" java.nio.file.AccessDeniedException: /root/home/searchengine/elasticsearch/config/jvm.options
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
    at java.nio.file.Files.newByteChannel(Files.java:361)
    at java.nio.file.Files.newByteChannel(Files.java:407)
    at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
    at java.nio.file.Files.newInputStream(Files.java:152)
    at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:58

错误原因:使用非 root 用户启动ES,而该用户的文件权限不足而被拒绝执行。

解决方法: chown -R 用户名:用户名  文件(目录)名

can not run elasticsearch as root

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[2019-01-09T10:43:22,092][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [unknown] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:140) ~[elasticsearch-6.5.4.jar:6.5.4]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.5.4.jar:6.5.4]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.5.4.jar:6.5.4]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.5.4.jar:6.5.4]
    at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.5.4.jar:6.5.4]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.5.4.jar:6.5.4]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.5.4.jar:6.5.4]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
    at

报错很明显“can not run elasticsearch as root”,所以切换到普通用户重新来吧。

ERROR: [5] bootstrap checks failed

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

ERROR: [5] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [1024] for user [es] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[4]:  failed to install; check the logs and fix your configuration or disable system call filters at your own risk
[5]: 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
[2019-04-09T09:51:29,228][INFO ][o.e.n.Node               ] [localhost.localdomain] stopping ...
[2019-04-09T09:51:29,264][INFO ][o.e.n.Node               ] [localhost.localdomain] stopped
[2019-04-09T09:51:29,265][INFO ][o.e.n.Node               ] [localhost.localdomain] closing ...
[2019-04-09T09:51:29,320][INFO ][o.e.n.Node               ] [localhost.localdomain] closed
[2019-04-09T09:51:29,323][INFO ][o.e.x.m.p.NativeController] [localhost.localdomain] Native controller process has stopped - no new native processes can be started

切换root用户 vi /etc/security/limits.conf,在倒数第二行,修改如下

* soft nofile 65536
* hard nofile 65536

vi /etc/sysctl.conf 添加 vm.max_map_count=655360, 保存后执行 sysctl -p

ERROR: [1] bootstrap checks failed

[1]: 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

ERROR: [1] bootstrap checks failed
[1]: 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.yml 取消注释保留一个节点 cluster.initial_master_nodes:["node-1"] 这个的话,这里的 node-1 是上面一个默认的记得打开就可以了

ERROR: [3] bootstrap checks failed

[1]: max number of threads [1024] for user [es] is too low, increase to at least [4096]

ERROR: [3] bootstrap checks failed
[1]: max number of threads [1024] for user [es] is too low, increase to at least [4096]
[2]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
[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

vi /etc/security/limits.d/90-nproc.conf 修改为

*   soft    nproc     1024
*   soft    nproc     4096
相关实践学习
使用阿里云Elasticsearch体验信息检索加速
通过创建登录阿里云Elasticsearch集群,使用DataWorks将MySQL数据同步至Elasticsearch,体验多条件检索效果,简单展示数据同步和信息检索加速的过程和操作。
ElasticSearch 入门精讲
ElasticSearch是一个开源的、基于Lucene的、分布式、高扩展、高实时的搜索与数据分析引擎。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr(也是基于Lucene)。 ElasticSearch的实现原理主要分为以下几个步骤: 用户将数据提交到Elastic Search 数据库中 通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据 当用户搜索数据时候,再根据权重将结果排名、打分 将返回结果呈现给用户 Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
目录
相关文章
|
18天前
|
数据可视化 索引
elasticsearch head、kibana 安装和使用
elasticsearch head、kibana 安装和使用
|
30天前
|
存储 负载均衡 索引
linux7安装elasticsearch-7.4.0集群配置
linux7安装elasticsearch-7.4.0集群配置
113 0
|
2月前
|
Docker 索引 容器
Elasticsearch跨集群检索配置
Elasticsearch跨集群检索配置
45 1
|
2月前
|
存储 监控 搜索推荐
在生产环境中部署Elasticsearch:最佳实践和故障排除技巧——安装篇(一)
在生产环境中部署Elasticsearch:最佳实践和故障排除技巧——安装篇(一)
|
4月前
ElasticSearch-Head浏览器插件离线安装
ElasticSearch-Head浏览器插件离线安装
91 0
|
17天前
|
JSON Unix Linux
Elasticsearch如何安装
Elasticsearch如何安装
|
1天前
|
Java Maven 开发工具
【ElasticSearch 】IK 分词器安装
【ElasticSearch 】IK 分词器安装
|
1月前
|
监控 安全 Java
ElasticSearch在Windows上的下载与安装
ElasticSearch在Windows上的下载与安装
|
2月前
|
开发工具 Docker 容器
docker安装集群版ElasticSearch
docker安装集群版ElasticSearch
|
2月前
|
Java Docker 容器
Docker安装ElasticSearch
Docker如何安装ElasticSearch

热门文章

最新文章