ElasticSearch单节点模式的搭建

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ElasticSearch单节点模式的搭建相关的知识,希望对你有一定的参考价值。

环境CentOS7
安装了JDK1.8
这里用的elasticsearch5.2.2为例,你也可以用5.6.1或者更高的版本

1.最好以非root用户解压ElasticSearch,如果用root用户,要不然以后还要将文件的权限以及组转移给非foot用户
1)解压elasticsearch-5.2.2.tar.gz到/opt/module目录下
[[email protected] ~]# su asy
[[email protected] root]$ tar -zxvf elasticsearch-5.2.2.tar.gz -C /opt/module
2)在/opt/module/elasticsearch-5.2.2路径下创建data和logs文件夹
mkdir data
mkdir logs

如果你用root账号,请先添加一个非root账号,因为elaticsearch不能用root账号运行
user add asy
chown -R asy:asy /opt/module/elasticsearch-5.2.2/

3)root账号修改配置文件/opt/module/elasticsearch-5.2.2/config/elasticsearch.yml
[[email protected] config]# pwd
/opt/module/elasticsearch-5.2.2/config
[[email protected] config]# vi elasticsearch.yml
修改以下参数

---------------------------------- Cluster -------------------------------------

cluster.name: Asy

------------------------------------ Node --------------------------------------(三个不能一样)

node.name: node-1

----------------------------------- Paths ---------------------------------------

path.data: /opt/module/elasticsearch-5.2.2/data
path.logs: /opt/module/elasticsearch-5.2.2/logs

----------------------------------- Memory -----------------------------------

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

---------------------------------- Network ------------------------------------

network.host: hdp21
http.port: 9200

--------------------------------- Discovery ------------------------------------

discovery.zen.ping.unicast.hosts: ["hdp21"]

path.data
path.logs data和logs的路径

network.host ip地址或者host域名地址
http.port端口号

5)配置linux系统环境(参考:
(1)编辑limits.conf 添加类似如下内容
[[email protected] config]# vi /etc/security/limits.conf
添加如下内容:

  • soft nofile 65536
  • hard nofile 131072
  • soft nproc 2048
  • hard nproc 4096
    (2)进入limits.d目录下修改配置文件。
    [[email protected] config]# vi /etc/security/limits.d/20-nproc.conf
    修改如下内容:如果超过2048则不用修改
  • soft nproc 1024
    #修改为
  • soft nproc 2048
    (3)修改配置sysctl.conf
    [[email protected] config]# vi /etc/sysctl.conf
    添加下面配置:
    vm.max_map_count=655360

退回到上一级目录
并执行命令:
[[email protected] config]# cd ..
[[email protected] elasticsearch-5.2.2]# pwd
/opt/module/elasticsearch-5.2.2

[[email protected] elasticsearch-5.2.2]# sysctl -p
然后,重新启动elasticsearch,即可启动成功。
6)启动elasticsearch
[[email protected] elasticsearch-5.2.2]$ bin/elasticsearch
后台启动方式
[[email protected] elasticsearch-5.2.2]$ bin/elasticsearch-d
7)测试elasticsearch
[[email protected] ~]# curl http://hdp21:9200
{
"name" : "node1",
"cluster_name" : "Asy",
"cluster_uuid" : "8T7xJ-NLTbmYHOPKa3a4tA",
"version" : {
"number" : "5.2.2",
"build_hash" : "f9d9b74",
"build_date" : "2017-02-24T17:26:45.835Z",
"build_snapshot" : false,
"lucene_version" : "6.4.1"
},
"tagline" : "You Know, for Search"
}

执行bin/elasticsearch的时候
如果有 max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] 的报错

这个对应v/etc/security/limits.conf

  • soft nofile 65536
    已经修改了,怎么不生效呢?
    重新进入该非 root user即可

Google浏览器调试Elastic Search
打开更多工具,扩展程序并且打开开发者模式
将elasticsearch-head.crx拖入浏览器窗口成功完成插件的安装
输入http://192.168.234.21:9200/
其中192.168.234.21为linux主机的IP地址,9200为端口号
技术分享图片

以上是关于ElasticSearch单节点模式的搭建的主要内容,如果未能解决你的问题,请参考以下文章

ElasticSearch多节点模式的搭建

Elasticsearch(简介及其单节点搭建)

elk+redis+filebeat

记录一下Elasticsearch+Filebeat+Kibana搭建过程(单节点)

elasticsearch 分布式集群搭建

elasticsearch集群搭建