Elasticsearch-6.3.2单机安装

本文围绕CentOS 7系统下Elasticsearch的使用展开。介绍了下载和解压步骤,针对启动可能出现的错误给出解决办法,如修改配置文件等。还说明了开机启动脚本的修改方法,最后给出虚拟机IP用于测试,并提供了相关参考链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

系统:CentOS 7

安装

下载
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.2.tar.gz
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.0-linux-x86_64.tar.gz

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.2.tar.gz   

解压

tar -zxvf elasticsearch-6.3.2.tar.gz
mv elasticsearch-6.3.2/  /home/sy/local/

运行

cd /home/sy/local/elasticsearch-6.3.2
./bin/elasticsearch

错误解决

如上述命令启动Elasticsearch,可能出现以下错误 [ 1 ] ^{[1]} [1]
+++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++

......
Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/elasticsearch-5.4.0/data/elasticsearch]] with lock id [0];
maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
......

解决办法
当我在开启多个elasticsearch 实例时,遇到上述异常,解决方法是:在 config/elasticsearch.yml文件中新增一个配置变量:

node.max_local_storage_nodes: 256  #replace 256 with another num that greater than 1

并修改:

network.host: 0.0.0.0
http.port: 9200

+++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++

......
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
......

第[1]个错误解决方法:
原因:无法创建本地文件问题,用户最大可创建文件数太小
解决方案:切换到root用户,编辑limits.conf配置文件, 添加类似如下内容:

vi /etc/security/limits.conf

添加如下内容:

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

备注* 代表Linux所有用户名称(比如 hadoop)
需要保存、退出、重新登录才可生效。

第[2]个错误解决方法:
原因:最大虚拟内存太小
方法一:运行命令,或者将该命令放入/etc/rc.local文件中,省去下次手动运行该命令。

# sysctl -w vm.max_map_count=262144

方法二:切换到root用户下,修改配置文件/etc/sysctl.conf,添加语句下面配置

vm.max_map_count=262144

运行命令# sysctl -p可以不用重启。

# sysctl -p

开机启动脚本

如果想每次启动虚拟机后,都能运行Elasticsearch,可以修改开机启动脚本。

vim /etc/rc.local
#elasticsearch
sysctl -w vm.max_map_count=262144
su - sy<<!  
/application/elasticsearch/bin/elasticsearch -d -p /application/elasticsearch/pid
!

测试

该虚拟机在Host-Only网络中的IP地址为 192.168.55.170。

$ curl 127.0.0.1:9200
$ curl 192.168.55.170:9200
{
    "name" : "yPseuAa",
    "cluster_name" : "elasticsearch",
    "cluster_uuid" : "Cnjo48S3QuiZrTWIANea_g",
    "version" : {
        "number" : "6.3.2",
        "build_flavor" : "default",
        "build_type" : "tar",
        "build_hash" : "053779d",
        "build_date" : "2018-07-20T05:20:23.451332Z",
        "build_snapshot" : false,
        "lucene_version" : "7.3.1",
        "minimum_wire_compatibility_version" : "5.6.0",
        "minimum_index_compatibility_version" : "5.0.0"
    },
    "tagline" : "You Know, for Search"
}

参考

[1] https://blog.youkuaiyun.com/lijiaz5033/article/details/73614617
[2] https://www.cnblogs.com/snailshadow/p/9190413.html
[3] https://www.cnblogs.com/zhi-leaf/p/8484337.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值