centos下elasticsearch相关插件(ik,kibana,filebeat,logstash)安装

版权声明:转载请注明出处 https://blog.csdn.net/wushichao0325/article/details/84826073

centos下elasticsearch相关插件(ik,kibana,filebeat,logstash)安装

一:安装ik分词器

分词是全文索引中非常重要的部分,Elasticsearch是不支持中文分词的,ik分词器支持中文
1.下载elasticsearch-analysis-ik
下载地址: https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.5.1/elasticsearch-analysis-ik-6.5.1.zip
注:v6.5.1必须保证与elasticsearch版本一致
2.安装ik分词器
直接解压elasticsearch-analysis-ik-6.5.1.zip,并将解压后的文件目录elasticsearch-analysis-ik-6.5.1放到elasticsearch的安装目录下的plugins下,然后重启elasticsearch即可
3.测试ik分词器

curl -XGET -H 'Content-Type: application/json' 'http://localhost:9200/_analyze?pretty' -d '{
"analyzer" : "ik_max_word",
"text": "中华人民共和国国歌"
}'

二:安装kibana

1.下载安装kibana
(1)cd到要下载到文件夹位置

cd /usr/local

(2)使用wget或者从官网https://www.elastic.co/cn/downloads/kibana下载rpm版本的安装包

wget https://artifacts.elastic.co/downloads/kibana/kibana-6.5.1-x86_64.rpm

(3)使用rpm安装

rpm -ivh kibana-6.5.1-x86_64.rpm

使用rpm安装后为yum安装的默认路径,具体参考:https://www.cnblogs.com/kerrycode/p/6924153.html
2.修改kibana配置文件
vim /etc/kibana/kibana.yml

server.port: 5601 #连接kibana的端口
server.host: 0.0.0.0 #可以外网连接
elasticsearch.url: http:localhost:9200#具体为你elasticsearch服务的连接
#如果你的elasticsearch有登录验证则需要配置:
elasticsearch.username: "user"
elasticsearch.password: "pwd"

注:配置属性时“:”后面务必加上空格再写。
3.启动kibana

#开启
service kibana start
#查询状态
service kibana status

三:filebeat安装

1.下载filebeat包

wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.5.1-x86_64.rpm

2.安装filebeat

rpm -vi filebeat-6.5.1-x86_64.rpm

3.编辑配置文件
vim /etc/filebeat/filebeat.yml

setup.kibana:
  host: "localhost:5601"
output.elasticsearch:
  hosts: ["localhost:9200"]
  #username: "elastic"
  #password: "changeme"

4.启用和配置elasticsearch模块
vim /etc/filebeat/modules.d/elasticsearch.yml

filebeat modules enable elasticsearch

5.开启filebeat

filebeat setup
service filebeat start

四:安装logstash

1.下载logstash.rpm安装包

wget https://artifacts.elastic.co/downloads/logstash/logstash-6.5.1.rpm

或者到官网下载:https://www.elastic.co/downloads/logstash
2.安装logstash

rpm -vi logstash-6.5.1.rpm

3.创建conf文件
cd 到/etc/logstash/conf.d
在conf.d文件夹下以.conf为后缀的任何名字的文件
内容如下:

input {
   file{
       path=> "/usr/local/nginx/logs/cml.log"    ##nginx生成日志的目录
       type=> "cml"          ##索引的类型
       start_position=> "beginning"     ##一开始就输入原来的日志信息
  }
  stdin{}
}
filter{
 grok {
       match => {
        "message" =>"(?<remote_IP>\d+.\d+.\d+.\d+)\s-\s-\s\[(?<DATA>\d+/\w+/\d+:\d+:\d+:\d+)[[:space:]](?<time_zone>\+\d+)\]\s\"(?<action>\w+)%{URIPATHPARAM:request} (?<Version>\w+/\d+.\d+)\"\s(?<status>\w+)\s(?<web_size>\w+)\s\"(?<language>\S+)\"\s"
##自定义grok
       }
}
 
}
output{
       elasticsearch{
       action=> "index"
       hosts=> "localhost:9200"      ##输出到elasticsearch上面
       index=> "log-%{+yyyy.MM.dd}"     ##生成一个log-时间的索引
       }
  stdout {codec=>rubydebug}    ##在终端上输出方便检测
}

4.启动logstash

initctl start logstash
或
systemctl start logstash.service

猜你喜欢

转载自blog.csdn.net/wushichao0325/article/details/84826073