架构师_程序员_码农网

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 6929|回复: 3

【实战】Centos 7 安装部署elasticsearch-6.5.2教程

[复制链接]
发表于 2018-12-11 16:45:13 | 显示全部楼层 |阅读模式
ElasticSearch简介

什么是ElasticSearch:

  • ElasticSearch是基于Apache Lucene构建的开源搜索引擎
  • 采用Java编写,提供了简单易用的RESTFul API
  • 轻松的横向扩展,可支持PB级的结构化或非结构化的数据处理


应用场景:

  • 海量数据分析引擎
  • 站内搜索引擎
  • 作为数据仓库

文档地址:https://www.elastic.co/guide/en/ ... etting-started.html

部署环境:

centos 7 x64位、elasticsearch 6.5.2版本、jdk 1.8.0.191

1:安装jdk 1.8.0

ElasticSearch对JRE的版本是敏感的,错误的版本,会导致ElasticSearch无法运行。

【实战】Centos 7 安装Java JDK教程
https://www.itsvse.com/thread-6169-1-1.html
(出处: 架构师_程序员)

2:下载并运行ElasticSearch 6.5.2

下载地址页面:https://www.elastic.co/downloads/elasticsearch

[root@VM_0_9_centos elasticsearch-6.5.2]# ./bin/elasticsearch
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
[2018-12-11T15:24:27,847][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.2.jar:6.5.2]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.5.2.jar:6.5.2]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.5.2.jar:6.5.2]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.5.2.jar:6.5.2]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.5.2.jar:6.5.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.5.2.jar:6.5.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.5.2.jar:6.5.2]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103) ~[elasticsearch-6.5.2.jar:6.5.2]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170) ~[elasticsearch-6.5.2.jar:6.5.2]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.5.2.jar:6.5.2]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.5.2.jar:6.5.2]
        ... 6 more

QQ截图20181211161354.jpg

Elasticsearch 要求不能使用超级用户root运行,所以我们随便建立一个账号,我这里就得用户为es

QQ截图20181211162346.jpg

如果没有没有error,就运行成功啦

新开一个终端,用curl访问


在确定服务器端口(9200)开启,elasticsearch启动的情况下(ps -ef | grep elasticsearch)可以在浏览器中访问

[root@VM_0_9_centos local]# curl 'http://localhost:9200/?pretty'
{
  "name" : "iUSRV4T",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "WCbka65VTd2TnM8gQvztqg",
  "version" : {
    "number" : "6.5.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "9434bed",
    "build_date" : "2018-11-29T23:58:20.891072Z",
    "build_snapshot" : false,
    "lucene_version" : "7.5.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

QQ截图20181211162417.jpg

3:通过外网访问elasticsearch

编辑elasticsearch的配置文件



找到network.host: 一行,去除#号,修改为:
QQ截图20181211163732.jpg

(network.host: [_local_, 172.30.6.1]   172.30.6.1为指定的ip地址,可以是多个。未测试)

重新启动elasticsearch即可,然后就可以外网访问http://ip:9200 界面了。
QQ截图20181211170339.jpg


可能遇到的错误:

错误一

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

max_map_count 的值是指一个进程最多可用于的内存映射区(memory map areas),在调用malloc会用到,由mmap/mprotect生成。

解决方法 提高vm.max_map_count 的大小:



QQ截图20181211163433.jpg

错误二

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

解决办法

修改后重新登录 es 用户,使用如下命令查看是否修改成功

错误三

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)

解决办法

阿里云上可能出现的问题:
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

解决方法:在elasticsearch配置中加入下面命令即可








上一篇:SEO核心技术纯白帽快速排名方法
下一篇:李开复:AI未来40课(9月12号最新)
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
 楼主| 发表于 2018-12-12 16:58:29 | 显示全部楼层
【实战】elasticsearch-6.5.2安装elasticsearch-head插件
https://www.itsvse.com/thread-6190-1-1.html
(出处: 架构师_程序员)
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
 楼主| 发表于 2020-1-10 09:27:13 | 显示全部楼层
磁盘空间使用量已经到了Es判断节点的磁盘空间的95%。然后索引会被设置为只读状态,写不进去。  昨天测试服务器插入10G数据,后面磁盘剩下5g,,早上过来写不进去了operation[0]: index returned 403 _index: ds_home_type: ds_homeg _id: f8z7j _version: 0 error: Type: cluster_block_exception Reason: "blocked by: [FORBIDDEN/12/index read-only / allow delete (api)]。
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
 楼主| 发表于 2021-12-21 17:00:35 | 显示全部楼层
将副本重置为0,如果数据重要性不是特别大,可以采用这个配置,以释放es写的压力。

码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

免责声明:
码农网所发布的一切软件、编程资料或者文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:help@itsvse.com

QQ|手机版|小黑屋|架构师 ( 鲁ICP备14021824号-2 )|网站地图

GMT+8, 2024-3-29 07:20

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表