ELK平台搭建部署

时间:2022-02-01 18:32:12

 

一、获取安装包:

EKL官网:https://www.elastic.co/products

 

二、安装elasticsearch

2.1、解压安装包,在安装目录创建data和logs目录,并在配置文件中指定路径:

 elasticsearch.yml:

path.data: /data/local/elasticsearch/data
path.logs:
/data/local/elasticsearch/logs

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

network.host:
0.0.0.0

http.port:
9200
http.enabled: true

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

 

elasticsearch默认不允许root用户运行,创建elasticsearch用户,并将elasticsearch安装目录拥有着修改为elasticsearch。

修改几个文件:

2.2、/etc/security/limits.conf:

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

2.3、/etc/sysctl.conf,添加如下:

vm.max_map_count = 655360

2.4、/etc/security/limits.d/20-nproc.conf:

*          soft    nproc     4096

发生的错误:

ERROR: [1] bootstrap checks failed

禁止bootstrap检测:

修改elasticsearch.yml,添加如下:

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

以上修改后,若还提示错误,需要重启系统。

启动elasticsearch:

切换到elasticsearch用户,在安装目录/bin下直接运行:

./elasticsearch &

可以看到启动日志:

[2017-08-03T15:09:45,481][INFO ][o.e.p.PluginsService     ] [QaS1DC7] loaded module [aggs-matrix-stats]
[
2017-08-03T15:09:45,481][INFO ][o.e.p.PluginsService ] [QaS1DC7] loaded module [ingest-common]
[
2017-08-03T15:09:45,481][INFO ][o.e.p.PluginsService ] [QaS1DC7] loaded module [lang-expression]
[
2017-08-03T15:09:45,481][INFO ][o.e.p.PluginsService ] [QaS1DC7] loaded module [lang-groovy]
[
2017-08-03T15:09:45,481][INFO ][o.e.p.PluginsService ] [QaS1DC7] loaded module [lang-mustache]
[
2017-08-03T15:09:45,482][INFO ][o.e.p.PluginsService ] [QaS1DC7] loaded module [lang-painless]
[
2017-08-03T15:09:45,482][INFO ][o.e.p.PluginsService ] [QaS1DC7] loaded module [parent-join]
[
2017-08-03T15:09:45,482][INFO ][o.e.p.PluginsService ] [QaS1DC7] loaded module [percolator]
[
2017-08-03T15:09:45,482][INFO ][o.e.p.PluginsService ] [QaS1DC7] loaded module [reindex]
[
2017-08-03T15:09:45,482][INFO ][o.e.p.PluginsService ] [QaS1DC7] loaded module [transport-netty3]
[
2017-08-03T15:09:45,482][INFO ][o.e.p.PluginsService ] [QaS1DC7] loaded module [transport-netty4]
[
2017-08-03T15:09:45,483][INFO ][o.e.p.PluginsService ] [QaS1DC7] no plugins loaded
[
2017-08-03T15:09:47,328][INFO ][o.e.d.DiscoveryModule ] [QaS1DC7] using discovery type [zen]
[
2017-08-03T15:09:47,878][INFO ][o.e.n.Node ] initialized
[
2017-08-03T15:09:47,879][INFO ][o.e.n.Node ] [QaS1DC7] starting ...
[
2017-08-03T15:09:48,051][INFO ][o.e.t.TransportService ] [QaS1DC7] publish_address {192.168.1.23:9300}, bound_addresses {[::]:9300}
[
2017-08-03T15:09:48,061][INFO ][o.e.b.BootstrapChecks ] [QaS1DC7] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[
2017-08-03T15:09:51,113][INFO ][o.e.c.s.ClusterService ] [QaS1DC7] new_master {QaS1DC7}{QaS1DC7FQy6uyuZv4RCoEw}{9u0bZc88TCKmbcT1tOwdlw}{192.168.1.23}{192.168.1.23:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[
2017-08-03T15:09:51,132][INFO ][o.e.h.n.Netty4HttpServerTransport] [QaS1DC7] publish_address {192.168.1.23:9200}, bound_addresses {[::]:9200}
[
2017-08-03T15:09:51,132][INFO ][o.e.n.Node ] [QaS1DC7] started
[
2017-08-03T15:09:51,146][INFO ][o.e.g.GatewayService ] [QaS1DC7] recovered [0] indices into cluster_state

2.5、安装elasticsearch-head:

elasticsearch-head是干啥的?

答:elasticsearch-head是一个可视化的管理elasticsearch集群的工具。

获取软件包:

git clone git://github.com/mobz/elasticsearch-head.git

到elasticsearch-head目录下:

npm install

注:前提需要安装nodjs。

tar zxvf node-v6.10.3.tar.gz
cd node
.
/configure
make
make install

 

编辑Gruntfile.js文件,connect修改如下:

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

启动head:

/elasticsearch-head/node_modules/grunt/bin/grunt server