侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

详解centos7虚拟机安装elasticsearch5.0.x-安装篇

linux  /  管理员 发布于 7年前   157

centos7虚拟机安装elasticsearch5.0.x-安装篇

请预先安装jdk详细步骤请参考:///softjc/193398.html

创建新用户(非root用户)

elasticsearch只能用非root启动,这里我创建了一个叫seven的用户

[root@localhost ~]# useradd seven[root@localhost ~]# passwd seven

下载elasticsearch

[root@localhost ~]# su seven[seven@localhost root]$ cd /home/seven[seven@localhost ~]$ mkdir download[seven@localhost ~]$ cd download[seven@localhost download]$ wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/5.0.0-alpha3/elasticsearch-5.0.0-alpha3.tar.gz

解压并运行elasticsearch

解压

[seven@localhost download]$ tar -zxvf elasticsearch-5.0.0-alpha3.tar.gz

移动到指定文件夹并重命名(方便管理)

[seven@localhost download]$ mv elasticsearch-5.0.0-alpha3 /usr/java/elasticsearch

修改访问elasticsearch的IP及端口

[seven@localhost config]$ vim /usr/java/elasticsearch/config/elasticsearch.yml

找到如下代码段,并取消network.host及http.port所在行的注释,修改IP及端口

# ---------------------------------- Network -----------------------------------## Set the bind address to a specific IP (IPv4 or IPv6):#network.host: 192.168.0.155## Set a custom port for HTTP:#http.port: 9200## For more information, see the documentation at:# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>

直接运行bin/elasticsearch文件启动elasticsearch

[seven@localhost bin]$ cd /usr/java/elasticsearch/bin/[seven@localhost bin]$ ./elasticsearch

启动时发现报错了。。。

[seven@localhost bin]$ ./elasticsearch[2016-06-28 13:49:27,899][INFO ][node      ] [Mondo] version[5.0.0-alpha3], pid[3671], build[cad959b/2016-05-26T08:25:57.564Z], OS[Linux/3.10.0-327.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1 .0_91/25.91-b14]2016-06-28 13:49:27,900][INFO ][node      ] [Mondo] initializing ...[2016-06-28 13:49:28,941][INFO ][plugins     ] [Mondo] modules [percolator, lang-mustache, lang-painless, ingest-grok, reindex, lang-expression, lang-groovy], plugins [][2016-06-28 13:49:28,963][INFO ][env      ] [Mondo] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [15.7gb], net total_space [17.4gb], spins? [unknown], types [rootfs][2016-06-28 13:49:28,963][INFO ][env      ] [Mondo] heap size [1.9gb], compressed ordinary object pointers [true][2016-06-28 13:49:31,980][INFO ][node      ] [Mondo] initialized[2016-06-28 13:49:31,980][INFO ][node      ] [Mondo] starting ...[2016-06-28 13:49:32,115][INFO ][transport    ] [Mondo] publish_address {192.168.0.155:9300}, bound_addresses {192.168.0.155:9300}Exception in thread "main" java.lang.RuntimeException: bootstrap checks failedinitial heap size [268435456] not equal to maximum heap size [2147483648]; this can cause resize pauses and prevents mlockall from locking the entire heapmax file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]please set [discovery.zen.minimum_master_nodes] to a majority of the number of master eligible nodes in your clustermax virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]  at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:125)  at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:85)  at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:65)  at org.elasticsearch.bootstrap.Bootstrap$5.validateNodeBeforeAcceptingRequests(Bootstrap.java:183)  at org.elasticsearch.node.Node.start(Node.java:337)  at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:198)  at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:257)  at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:96)  at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:91)  at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)  at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:91)  at org.elasticsearch.cli.Command.main(Command.java:53)  at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:70)  at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:63)Refer to the log for complete error details.[2016-06-28 13:49:32,144][INFO ][node      ] [Mondo] stopping ...[2016-06-28 13:49:32,198][INFO ][node      ] [Mondo] stopped[2016-06-28 13:49:32,198][INFO ][node      ] [Mondo] closing ...[2016-06-28 13:49:32,210][INFO ][node      ] [Mondo] closed

于是我临时提高了vm.max_map_count的大小

*此操作需要root权限

[root@localhost ~]# sysctl -w vm.max_map_count=262144

查看修改结果

[root@localhost ~]# sysctl -a|grep vm.max_map_countvm.max_map_count = 262144

或者永久性修改

[root@localhost ~]# cat /etc/sysctl.conf | grep -v "vm.max_map_count" > /tmp/system_sysctl.conf[root@localhost ~]# echo "vm.max_map_count=262144" >> /tmp/system_sysctl.conf[root@localhost ~]# mv /tmp/system_sysctl.conf /etc/sysctl.confmv:是否覆盖"/etc/sysctl.conf"? y[root@localhost ~]# cat /etc/sysctl.conf# System default settings live in /usr/lib/sysctl.d/00-system.conf.# To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file## For more information, see sysctl.conf(5) and sysctl.d(5).vm.max_map_count=262144[root@localhost ~]# sysctl -pvm.max_map_count = 262144

上面还有一个错误是关于jvm内存分配的问题heap size [268435456] not equal to maximum heap size [2147483648],需要修改的jvm配置

[seven@localhost bin]$ vim /usr/java/elasticsearch/config/jvm.options

将-Xmx2g改成-Xmx256m,也就是heap size [268435456] /1024/1024的值

又有新的错误。。。

Exception in thread "main" java.lang.RuntimeException: bootstrap checks failedinitial heap size [268435456] not equal to maximum heap size [2147483648]; this can cause resize pauses and prevents mlockall from locking the entire heapmax file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]memory locking requested for elasticsearch process but memory is not locked  at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:125)  at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:85)  at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:65)  at org.elasticsearch.bootstrap.Bootstrap$5.validateNodeBeforeAcceptingRequests(Bootstrap.java:183)  at org.elasticsearch.node.Node.start(Node.java:337)  at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:198)  at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:257)  at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:96)  at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:91)  at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)  at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:91)  at org.elasticsearch.cli.Command.main(Command.java:53)  at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:70)  at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:63)Refer to the log for complete error details.[2016-06-28 14:55:49,770][INFO ][node      ] [Goldbug] stopping ...[2016-06-28 14:55:49,875][INFO ][node      ] [Goldbug] stopped[2016-06-28 14:55:49,875][INFO ][node      ] [Goldbug] closing ...[2016-06-28 14:55:49,887][INFO ][node      ] [Goldbug] closed

这个问题折腾了我一下午,最后还是找到了解决方案,同样回到config/elasticsearch.yml文件,找到如下配置,开放discovery.zen.ping.unicast.hosts及discovery.zen.minimum_master_nodes

# --------------------------------- Discovery ----------------------------------## Pass an initial list of hosts to perform discovery when new node is started:# The default list of hosts is ["127.0.0.1", "[::1]"]#discovery.zen.ping.unicast.hosts: ["192.168.0.155"]## Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):#discovery.zen.minimum_master_nodes: 3## For more information, see the documentation at:# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>

然后修改max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]这个错误(切换到root操作)

[root@localhost ~]# cp /etc/security/limits.conf /etc/security/limits.conf.bak[root@localhost ~]# cat /etc/security/limits.conf | grep -v "seven" > /tmp/system_limits.conf[root@localhost ~]# echo "seven hard nofile 65536" >> /tmp/system_limits.conf [root@localhost ~]# echo "seven soft nofile 65536" >> /tmp/system_limits.conf [root@localhost ~]# mv /tmp/system_limits.conf /etc/security/limits.conf

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

[seven@localhost ~]$ ulimit -Hn65536

接下来就可以启动elasticsearch了,启动完成使用浏览器访问http://192.168.0.155:9200

{ "name" : "Vampire by Night", "cluster_name" : "elasticsearch", "version" : { "number" : "5.0.0-alpha3", "build_hash" : "cad959b", "build_date" : "2016-05-26T08:25:57.564Z", "build_snapshot" : false, "lucene_version" : "6.0.0" }, "tagline" : "You Know, for Search"}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。


  • 上一条:
    Centos下编译Linux内核的具体实现方法
    下一条:
    详解linux后台运行和关闭、查看后台任务
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • 在Linux系统中使用Iptables实现流量转发功能流程步骤(0个评论)
    • vim学习笔记-入门级需要了解的一些快捷键(0个评论)
    • 在centos7系统中实现分区并格式化挂载一块硬盘到/data目录流程步骤(0个评论)
    • 在Linux系统种查看某一个进程所占用的内存命令(0个评论)
    • Linux中grep命令中的10种高级用法浅析(0个评论)
    • 近期文章
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 欧盟关于强迫劳动的规定的官方举报渠道及官方举报网站(0个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf文件功能(0个评论)
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • 在go + gin中gorm实现指定搜索/区间搜索分页列表功能接口实例(0个评论)
    • 在go语言中实现IP/CIDR的ip和netmask互转及IP段形式互转及ip是否存在IP/CIDR(0个评论)
    • PHP 8.4 Alpha 1现已发布!(0个评论)
    • Laravel 11.15版本发布 - Eloquent Builder中添加的泛型(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2016-11
    • 2017-07
    • 2017-10
    • 2017-11
    • 2018-01
    • 2018-02
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2021-02
    • 2021-03
    • 2021-04
    • 2021-06
    • 2021-07
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-11
    • 2021-12
    • 2022-01
    • 2022-03
    • 2022-04
    • 2022-08
    • 2022-11
    • 2022-12
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-06
    • 2023-07
    • 2023-10
    • 2023-12
    • 2024-01
    • 2024-04
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客