elasticsearch5.5+head+kibana 集群搭建

elasticsearch5.5 集群搭建

环境

elasticsearch5.x需要jdk1.8指出,如果使用jdk1.7可以下载2.4.5
最新版本
2.4.5
本文搭建集群使用的版本为5.5,系统为CenterOS
本文搭建的环境所有节点同时是主节点和数据节点,集群较大时可以将主节点和数据节点分开,保证集群的稳定运行
官方文档

配置

节点配置如下

cluster.name: bwjf_dev
node.name: master

network.host: 192.168.5.185
http.port: 9200

http.cors.enabled: true
http.cors.allow-origin: "*"

node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["192.168.5.185:9200","192.168.5.186:9200","192.168.5.187:9200"]

discovery.zen.minimum_master_nodes=2

#CenterOS需要加入以下配置
bootstrap.memory_lock: false
bootstrap.system_call_filter: false

cluster.name:集群名字
node.name:节点名字,不能和其他节点重复
network.host:当前地址
http.port:端口号,默认为9200
node.master:设置为True(默认)的时候,它有资格被选作为主节点,控制整个集群
node.data:在一个节点上node.data设置为True(默认)的时候。该节点保存数据和执行数据相关的操作,如增删改查,搜索,和聚合
discovery.zen.ping.unicast.hosts:配置为主节点地址(node.master=true)
discovery.zen.minimum_master_nodes:设置这个值的原则是:(主节点数 / 2)+ 1,原因参考Elasticsearch节点类型
最后两项因为CenterOS不支持,改为false,正常情况下推荐使用默认配置
elasticsearch配置文件详解
需要修改的配置有三项:node.name,network.host

除以上配置外,还需要根据“遇到的问题”一节中来配置系统参数,以免浪费时间在启动重启上

启动

/usr/hadoop/application/elasticsearch/bin/elasticsearch -d

#日志
tail -fn 100 /usr/hadoop/application/elasticsearch/logs/bwjf_dev.log

-d为后台启动

遇到的问题

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

原因:无法创建本地文件问题,用户最大可创建文件数太小
解决方案:切换到root用户,编辑/etc/security/limits.conf配置文件, 添加如下内容

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

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

max number of threads [1024] for user [hadoop] is too low, increase to at least [2048]

原因:无法创建本地线程问题,用户最大可创建线程数太小
解决方案:切换到root用户,修改/etc/security/limits.d/90-nproc.conf 配置文件
找到如下内容:

* soft nproc 1024
#修改为
* soft nproc 2048

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

原因:最大虚拟内存太小
解决方案:切换到root用户下,修改配置文件/etc/sysctl.conf
添加下面配置:vm.max_map_count=655360
并执行命令:sysctl -p
然后重新启动elasticsearch,即可启动成功。

elasticsearch集群管理工具head插件

elasticsearch-head采用单节点部署

安装

1、安装nodejs和npm:yum -y install nodejs npm
2、下载代码并安装

git clone https://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head/
npm install

修改配置

1、修改elasticsearch.yml,增加跨域的配置(需要重启es才能生效)。可以参考git上的文档加入登录验证

http.cors.enabled: true
http.cors.allow-origin: "*"

2、编辑head/Gruntfile.js,修改服务器监听地址,增加hostname属性,将其值设置为*。

connect: {
        hostname: '*',
        server: {
                options: {
                        port: 9100,
                        base: '.',
                        keepalive: true
                }
        }
}

3、编辑head/_site/app.js,修改head连接es的地址,将localhost修改为es的IP地址,在head机器上有elasticsearch则不需要修改

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.5.185:9200";

启动

cd elasticsearch-head
npm run start

kibana集群搭建

kibana采用单节点部署

安装

本文使用kibana-5.5.0-linux-x86_64.tar.gz安装,其他安装方法可以参考Install Kibana

配置

文件位于$KIBANA_HOME/config/kibana.yml,具体配置项含义参考Kibana Configuration Settings

#当前服务端地址,默认值"localhost"
server.host: "localhost"
#服务端端口号,默认5601
server.port: 5601
#elasticsearch地址,默认值"http://localhost:9200"
elasticsearch.url: "http://localhost:9200"

我配置时使用localhost时,kibana报无法连接错误,根据Kibana Fails to connect to Elasticsearch after the install of SearchGuard所述,可以在kibana系统上使用命令测试,如果返回结果,才可以使用。

[hadoop@ceshi185 bin]$ curl -k -s http://192.168.5.185:9200
{
  "name" : "node-185",
  "cluster_name" : "bwjf_dev",
  "cluster_uuid" : "gY9TIJvlROC-sVqNPYtTZw",
  "version" : {
    "number" : "5.5.0",
    "build_hash" : "260387d",
    "build_date" : "2017-06-30T23:16:05.735Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.0"
  },
  "tagline" : "You Know, for Search"
}

最终我的配置如下

server.host: "192.168.5.185"
elasticsearch.url: "http://192.168.5.185:9200"

启动

./bin/kibana

猜你喜欢

转载自blog.csdn.net/zh350229319/article/details/75370522