Elasticsearch 安装和配置

简介

Elasticsearch(ES)是一个基于Lucene构建的分布式、高性能、高可用、可伸缩、近实时的分析和搜索引擎。

es安装

节点规划

节点角色
node2es,kibana
node3es
node4es

创建普通用户

es可以接受用户输入的脚本执行,出于安全,不能以root用户启动es,这里创建elk普通用户。

useradd elk
passwd elk

下载

[elk@node2 ~]$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.3.1.zip
[elk@node2 ~]$ unzip elasticsearch-5.3.1.zip

配置

配置文件

es的配置文件在elasticsearch-5.3.1/config文件夹下。

elasticsearch.yml 配置es
jvm.options 配置es的jvm
log4j2.properties 配置es的日志
配置node2
#创建索引数据存储位置
[elk@node2 elasticsearch-5.3.1]$ mkdir -p es-data/data
#创建日志存储位置
[elk@node2 elasticsearch-5.3.1]$ mkdir -p es-data/logs
#配置elasticsearch.yml
#集群名称
cluster.name: my-es
#节点名称
node.name: es-node1
#索引存储位置
path.data: /home/elk/elasticsearch-5.3.1/es-data/data
#日志存储位置
path.logs: /home/elk/elasticsearch-5.3.1/es-data/logs
#绑定的网卡IP
network.host:node2
#http端口
http.port: 9200
#新节点IP
discovery.zen.ping.unicast.hosts: [node2,node3,node4]
配置node3
[elk@node2 ~]$ scp -r elasticsearch-5.3.1 elk@node3:~
#配置elasticsearch.yml
node.name: es-node2
network.host: node3
配置node4
[elk@node2 ~]$ scp -r elasticsearch-5.3.1 elk@node4:~
#配置elasticsearch.yml
node.name: es-node3
network.host: node4

启动与异常

启动
[root@node2 elasticsearch-5.3.1]# bin/elasticsearch #后台启动bin/elasticsearch -d
异常1
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
#原因
系统不支持SecComp,而ES默认bootstrap.system_call_filter为true进行检测,导致检测失败,ES不能启动。
#解决在elasticsearch.yml 添加如下配置
bootstrap.system_call_filter: false
异常2

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

切换到root用户下,vi /etc/security/limits.conf,添加如下配置
* soft nofile 65536
* hard nofile 131072
异常3

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

切换到root用户下,vi /etc/security/limits.d/90-nproc.conf,修改如下配置
* soft nproc 1024 修改为 * soft nproc 2048
异常4

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

切换到root用户下,vi /etc/sysctl.conf
vm.max_map_count = 655360
执行命令 sysctl -p
检查是否启动成功
通过9200端口访问:http://node2:9200/,可得到如下结果。同理可访问:http://node3:9200/、http://node4:9200/
{
name: "es-node1",#当前节点名称
cluster_name: "my-es", #es集群名称
cluster_uuid: "F7k7eJ0KQ7ucUynWDfQBkQ",
version: {
number: "5.3.1", #es版本号
build_hash: "5f9cf58",
build_date: "2017-04-17T15:52:53.846Z",
build_snapshot: false,
lucene_version: "6.4.2"
},
tagline: "You Know, for Search"
}

安装head插件

es 5.x版本不能直接用elasticsearch-5.3.1/bin install mobz/elasticsearch-head安装head插件。 [Githup elasticsearch-head] (https://github.com/mobz/elasticsearch-head)提供了多种方式如手动安装、Docker、Google应用商店等安装elasticsearch-head 插件,这里选用最简单的,在Google应用商店直接搜索并添加ElasticSearch Head扩展即可。

es_head.png

安装kibana

kibana可以基于浏览器对ES中的数据搜索和分析。

下载解压

[elk@node2 ~]$ wget https://artifacts.elastic.co/downloads/kibana/kibana-5.3.3-linux-x86_64.tar.gz
[elk@node2 ~]$ tar -zxvf kibana-5.3.3-linux-x86_64.tar.gz

配置

kibana.yml:
server.host: "node2"
elasticsearch.url: "http://node2:9200"

启动

[elk@node2 kibana-5.3.3-linux-x86_64]$ bin/kibana

验证

http://node2:5601
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值