logstash配置⽂件详解_ELK搭建与使⽤详解
1.环境部署
安装软件 主机名 IP地址 内存需求 Elasticsearch mes 192.168.13.142 ⾄少3G Logstash log 192.168.13.143 ⾄少2G head,Kibana head-kib 192.168.13.139 ⾄少2G 地址与版本
Elasticsearch: 6.5.4 #/downloads/elasticsearch/elasticsearch-6.5.
Logstash: 6.5.4 #/downloads/logstash/logstash-6.5.
Kibana: 6.5.4 #/downloads/kibana/kibana-6.5.4-linux-x86_
Kafka: 2.11-2.1 #/dist/kafka/2.1.0/kafka_2.11-2.
Filebeat: 6.5.4
相应的版本最好下载对应的插件
相关地址: 官⽹地址
2.Elasticsearch部署
系统类型:Centos7.5
节点IP:172.16.13.142
软件版本:、elasticsearch-6.5.
1.安装配置jdk
JDK下载地址
[root@mes ~]# tar xzf -C /usr/local/ #解压
[root@mes ~]# cd /usr/local/
[root@mes local]# mv jdk1.8.0_211/ java
[root@mes local]# echo '
JAVA_HOME=/usr/local/java
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME PATH
' >>/etc/profile
[root@mes local]# source /etc/profile
[root@mes local]# java -version #出现版本号就代表jdk配置成功
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
linux安装jdk rpm安装Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
2.安装配置ES
[root@mes ~]# useradd elsearch #创建运⾏⽤户
[root@mes ~]# echo "123456" | passwd --stdin "elsearch" #设置密码
[root@mes ~]# tar xzf elasticsearch-6.5. -C /usr/local/
[root@mes ~]# cd /usr/local/elasticsearch-6.5.4/config/
[root@mes config]# l.bak #备份
[root@mes config]# l
# 在最后⼀⾏添加如下内容
cluster.name: elk
node.name: elkyjssjm
node.master: true
node.data: true
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
<_lock: false
bootstrap.system_call_filter: false
network.host: 0.0.0.0
http.port: 9200
#ping.unicast.hosts: ["192.168.246.234", "192.168.246.231","192.168.246.235"]
#inimum_master_nodes: 2
#ping_timeout: 150s
#fd.ping_retries: 10
#ansport.ping_timeout: 60s
参数详解
cluster.name 集名称,各节点配成相同的集名称。
node.name 节点名称,各节点配置不同。
node.master 指⽰某个节点是否符合成为主节点的条件。
node.data 指⽰节点是否为数据节点。数据节点包含并管理索引的⼀部分。
path.data 数据存储⽬录。
path.logs ⽇志存储⽬录。
<_lock 内存锁定,是否禁⽤交换。
bootstrap.system_call_filter 系统调⽤过滤器。
network.host 绑定节点IP。
http.port 端⼝。
设置JVM堆⼤⼩,⼀般设置为内存的⼀半,但最少2G
[root@mes ~]# sed -i 's/-Xms1g/-Xms2g/' /usr/local/elasticsearch-6.5.4/config/jvm.options
[root@mes ~]# sed -i 's/-Xmx1g/-Xmx2g/' /usr/local/elasticsearch-6.5.4/config/jvm.options
创建ES数据及⽇志存储⽬录并修改属主和属组,与上⾯配置⽂件中的路径⼀⼀对应
[root@mes ~]# mkdir -p /data/elasticsearch/data
[root@mes ~]# mkdir -p /data/elasticsearch/logs
[root@mes ~]# chown -R elsearch:elsearch /data/elasticsearch #给刚刚创建的⽬录修改属主和属组
[root@mes ~]# chown -R elsearch:elsearch /usr/local/elasticsearch-6.5.4
1.增加最⼤进程数
[root@mes ~]# vim /etc/f
#在⽂件最后⾯添加如下内容
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
================================================================
解释:
soft xxx : 代表警告的设定,可以超过这个设定值,但是超过后会有警告。
hard xxx : 代表严格的设定,不允许超过这个设定的值。
nofile : 是每个进程可以打开的⽂件数的限制
nproc : 是操作系统级别对每个⽤户创建的进程数的限制
================================================================
2.增加最⼤内存映射数
[root@mes ~]# vim /f
#添加如下
vm.max_map_count=262144 #elasticsearch⽤户拥有的内存权限太⼩,⾄少需要262144;
vm.swappiness=0 #表⽰最⼤限度使⽤物理内存,在内存不⾜的情况下,然后才是swap空间
[root@mes ~]# su - elsearch
Last login: Sat Aug 3 19:48:59 CST 2019 on pts/0
[root@mes ~]$ cd /usr/local/elasticsearch-6.5.4/
[root@mes elasticsearch-6.5.4]$ ./bin/elasticsearch #先启动看看报错不,需要多等⼀会
终⽌之后(等cpu降下来再终⽌)
[root@mes elasticsearch-6.5.4]$ nohup ./bin/elasticsearch & #放后台启动
[1] 11462
nohup: ignoring input and appending output to ‘nohup.out’
[root@mes elasticsearch-6.5.4]$ tail -f nohup.out #看⼀下是否启动
或者:
su - elsearch -c "cd /usr/local/elasticsearch-6.5.4 && nohup bin/elasticsearch &"
3.head,Kibana安装配置
系统类型:Centos7.5
节点IP:172.16.13.139
软件版本:node-v4.4.、elasticsearch-head-master.zip、phantomjs-2.1.1-linux-x86_64.tar.bz2、kibana-6.5.4-linux-x86_ 1.head及其插件的安装配置
[root@head-kib ~]# wget /mirrors/node/latest-v4.x/node-v4.4.
[root@head-kib ~]# tar -zxf node-v4.4. –C /usr/local
[root@head-kib ~]# vim /etc/profile
#在最后添加如下变量
NODE_HOME=/usr/local/node-v4.4.7-linux-x64
PATH=$NODE_HOME/bin:$PATH
export NODE_HOME PATH
[root@head-kib ~]# source /etc/profile
[root@head-kib ~]# node --version #检查node版本号
v4.4.7
2.下载head插件grunt
[root@head-kib ~]# wget github/mobz/elasticsearch-head/archive/master.zip
[root@head-kib ~]# cp elasticsearch-head-master.zip /usr/local/
[root@head-kib ~]# yum -y install unzip
[root@head-kib local]# cd /usr/local
[root@head-kib local]# unzip elasticsearch-head-master.zip
[root@head-kib local]# cd elasticsearch-head-master/
[root@head-kib elasticsearch-head-master]# npm config set registry registry. #改源地址,要不然下⾯的安装时间会特别长[root@head-kib elasticsearch-head-master]# npm install -g grunt-cli #安装grunt
[root@head-kib elasticsearch-head-master]# grunt --version #检查grunt版本号
grunt-cli v1.3.2
[root@head-kib elasticsearch-head-master]# vim /usr/local/elasticsearch-head-master/Gruntfile.js
#在95⾏左右
[root@head-kib elasticsearch-head-master]# vim /usr/local/elasticsearch-head-master/_site/app.js
#在4374⾏左右
3.下载head必要的⽂件
[root@head-kib ~]# wget github/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2 [root@head-kib ~]# yum -y install bzip2
[root@head-kib ~]# tar -jxf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /tmp/ #解压
4.运⾏head
[root@head-kib ~]# cd /usr/local/elasticsearch-head-master/
[root@head-kib elasticsearch-head-master]# npm config set registry registry.
[root@head-kib elasticsearch-head-master]# npm install
...
grunt-contrib-jasmine@1.0.3 node_modules/grunt-contrib-jasmine
├── sprintf-js@1.0.3
├── lodash@2.4.2
├── es5-shim@4.5.13
├── chalk@1.1.3 (escape-string-regexp@1.0.5, supports-color@2.0.0, ansi-styles@2.2.1, strip-ansi@3.0.1, has-ansi@2.0.0)├── jasmine-core@2.99.1
├── rimraf@2.6.3 (glob@7.1.4)
└── grunt-lib-phantomjs@1.1.0 (eventemitter2@0.4.14, semver@5.7.0, temporary@0.0.8, phan
[root@head-kib elasticsearch-head-master]# nohup grunt server &
[root@head-kib elasticsearch-head-master]# tail -f nohup.out
Running "connect:server" (connect) task
Started connect web server on localhost:9100
2.Kibana部署
1.安装和配置
[root@head-kib ~]# tar zvxf kibana-6.5.4-linux-x86_ -C /usr/local/
[root@head-kib ~]# cd /usr/local/kibana-6.5.4-linux-x86_64/config/
[root@head-kib config]# l
#在末尾添加以下内容
server.port: 5601
server.host: "192.168.13.139" #本机
elasticsearch.url: "192.168.13.142:9200" #ES节点
kibana.index: ".kibana"
====================================================================================
server.port kibana 服务端⼝,默认5601
server.host kibana 主机IP地址,默认localhost
elasticsearch.url ⽤来做查询的ES节点的URL,默认localhost:9200
kibana.index kibana在Elasticsearch中使⽤索引来存储保存的searches, visualizations和dashboards,默认.kibana
=====================================================================================
2.启动
[root@head-kib config]# cd ..
[root@head-kib kibana-6.5.4-linux-x86_64]# nohup ./bin/kibana &
[1] 12054
[root@head-kib kibana-6.5.4-linux-x86_64]# nohup: ignoring input and appending output to ‘nohup.out’
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论