我是靠谱客的博主 彪壮摩托,最近开发中收集的这篇文章主要介绍centos7安装elasticsearch-6.6.0,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

1 下载elasticsearch-6.6.0

[liucf@node1 softfile]$  wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.0.tar.gz
[liucf@node1 softfile]$  wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.0.tar.gz
--2021-09-19 22:42:55--  https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.0.tar.gz
Resolving artifacts.elastic.co (artifacts.elastic.co)... 34.120.127.130, 2600:1901:0:1d7::
Connecting to artifacts.elastic.co (artifacts.elastic.co)|34.120.127.130|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 114106988 (109M) [application/x-gzip]
Saving to: ‘elasticsearch-6.6.0.tar.gz’

100%[============================================================================================>] 114,106,988  958KB/s   in 1m 57s 

2021-09-19 22:44:52 (950 KB/s) - ‘elasticsearch-6.6.0.tar.gz’ saved [114106988/114106988]

[liucf@node1 softfile]$ 

 2 解压

tar -zxvf elasticsearch-6.6.0.tar.gz -C ../soft

3 修改elasticsearch配置文件

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: liucf-es
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /home/liucf/soft/elasticsearch-6.6.0/data
#
# Path to log files:
#
path.logs: /home/liucf/soft/elasticsearch-6.6.0/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- 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: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

4 启动elasticsearch

[liucf@node1 bin]$ /home/liucf/soft/elasticsearch-6.6.0/bin/elasticsearch -d
[liucf@node1 bin]$ jps
2517 JobHistoryServer
106148 Elasticsearch  ##可以看到已经启动起来了
2280 NameNode
2377 ResourceManager
106155 Jps
2988 QuorumPeerMain
8605 Kafka
[liucf@node1 bin]$ jps ##再次jps 查看Elasticsearch  的进程死掉了
2517 JobHistoryServer
2280 NameNode
2377 ResourceManager
106250 Jps
2988 QuorumPeerMain
8605 Kafka

那么为什么起来之后有挂掉了呢

查看日志

cd /home/liucf/soft/elasticsearch-6.6.0/logs
[liucf@node1 logs]$ cat liucf-es.log
...
[2021-09-19T23:05:08,139][INFO ][o.e.p.PluginsService     ] [node1] no plugins loaded
[2021-09-19T23:05:12,173][INFO ][o.e.x.s.a.s.FileRolesStore] [node1] parsed [0] roles from file [/home/liucf/soft/elasticsearch-6.6.0/config/roles.yml]
[2021-09-19T23:05:12,752][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [node1] [controller/106179] [Main.cc@109] controller (64 bit): Version 6.6.0 (Build bbb4919f4d17a5) Copyright (c) 2019 Elasticsearch BV
[2021-09-19T23:05:13,748][DEBUG][o.e.a.ActionModule       ] [node1] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2021-09-19T23:05:14,401][INFO ][o.e.d.DiscoveryModule    ] [node1] using discovery type [zen] and host providers [settings]
[2021-09-19T23:05:15,966][INFO ][o.e.n.Node               ] [node1] initialized
[2021-09-19T23:05:15,966][INFO ][o.e.n.Node               ] [node1] starting ...
[2021-09-19T23:05:16,142][INFO ][o.e.t.TransportService   ] [node1] publish_address {192.168.109.151:9300}, bound_addresses {[::]:9300}
[2021-09-19T23:05:16,153][INFO ][o.e.b.BootstrapChecks    ] [node1] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2021-09-19T23:05:16,155][ERROR][o.e.b.Bootstrap          ] [node1] node validation exception
[3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: memory locking requested for elasticsearch process but memory is not locked
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2021-09-19T23:05:16,158][INFO ][o.e.n.Node               ] [node1] stopping ...
[2021-09-19T23:05:16,183][INFO ][o.e.n.Node               ] [node1] stopped
[2021-09-19T23:05:16,183][INFO ][o.e.n.Node               ] [node1] closing ...
[2021-09-19T23:05:16,193][INFO ][o.e.n.Node               ] [node1] closed

可见主要问题是:

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: memory locking requested for elasticsearch process but memory is not locked
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

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

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

修改/etc/security/limits.conf文件,增加配置,用户退出后重新登录生效

[liucf@node1 softfile]$ sudo vim /etc/security/limits.conf
..
#@student        -       maxlogins       4
* soft nofile 65536
* hard nofile 65536

# End of file

..

验证:

## 退出用户重新登录后
[liucf@node1 ~]$ ulimit -Hn
65536
[liucf@node1 ~]$ ulimit -Sn
65536

针对[2]: memory locking requested for elasticsearch process but memory is not locked

关闭

bootstrap.memory_lock: false

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

在/etc/sysctl.conf文件最后添加一行

vm.max_map_count=262144

[liucf@node1 ~]$ sudo vim /etc/sysctl.conf
[sudo] password for liucf: 

# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
vm.max_map_count=262144

执行/sbin/sysctl -p 立即生效

[liucf@node1 ~]$ sudo /sbin/sysctl -p 
vm.max_map_count = 262144
[liucf@node1 ~]$ 

重新启动elasticsearch

 /home/liucf/soft/elasticsearch-6.6.0/bin/elasticsearch -d

然后问题解决了

5 验证elasticsearch启动效果

 

最后

以上就是彪壮摩托为你收集整理的centos7安装elasticsearch-6.6.0的全部内容,希望文章能够帮你解决centos7安装elasticsearch-6.6.0所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(33)

评论列表共有 0 条评论

立即
投稿
返回
顶部