Elasticsearch&logstash&filebeat&kibana&x-pack搭建

来源:互联网 发布:mysql编程题及答案 编辑:程序博客网 时间:2024/05/01 10:55

filebeat安装

  1. 下载filebeat安装包,filebeat-5.5.2-linux-x86_64.tar.gz
  2. 解压 tar-zxvf filebeat-5.5.2-linux-x86_64.tar.gz
  3. 修改filebeat.yml配置文件如下:

    filebeat.prospectors:input_type: logpaths:- /path/fail.logdocument_type: type1input_type: logpaths:- /path/full.logdocument_type: type2fields:tail_files: "true"output.logstash:hosts: ["ip1:5043","ip2:5043"]loadbalance: "true"
  4. 启动filebeat

    如果非第一次启动则删除%FILEBEAT_HOME%/data/registry 文件rm data/registry启动脚本./filebeat -e -c filebeat.yml -d "publish"或者后台启动nohup ./filebeat -e -c filebeat.yml -d "publish" >output 2>&1 &

安装logstash

  1. 下载logstash安装包:logstash-5.5.2.tar.gz
  2. 解压:tar -zxvf logstash-5.5.2.tar.gz
  3. 修改logstash.conf 配置文件如下:
input {    beats{            port=>"5043"        }}output {    if [type] == "type1"{    elasticsearch {            hosts => ["ip1:9200","ip2:9200"]            index => "logstash-type1-%{+YYYY.MM.dd}"            document_type => "type1"        }    }    if [type] == "type2"{    elasticsearch {            hosts => ["ip1:9200","ip2:9200"]            index => "logstash-type2-%{+YYYY.MM.dd}"            document_type => "type2"        }    }}
  1. 启动logstash
启动脚本bin/logstash -f logstash.conf --config.reload.automatic或者后台启动脚本nohup bin/logstash -f logstash.conf --config.reload.automatic >nohup.out 2>&1 &

安装elasticsearch

  1. 下载安装包: elasticsearch-5.5.2.tar.gz
  2. 解压: tar -zxvf elasticsearch-5.5.2.tar.gz
  3. 修改elasticsearch.yml 配置如下
cluster.name: cluster1node.name: c1-node-1http.cors.enabled: truehttp.cors.allow-origin: "*"path.data: /es-path/datapath.logs: /es-path/logsbootstrap.memory_lock: falsenetwork.host: ip //如果是远程机器访问该es应用,则需要配置ip而不是localhosthttp.port: 9200discovery.zen.ping.unicast.hosts: ["ip1","ip2"]discovery.zen.minimum_master_nodes: 5action.auto_create_index: +*xpack.security.enabled: false
  1. 启动脚本
$ ./bin/elasticsearch -p ./e-pid -d

安装kibana

  1. 下载安装包 : kibana-5.5.2-linux-x86_64.tar.gz
  2. 解压 tar -zxvf kibana-5.5.2-linux-x86_64.tar.gz
  3. 修改kibana.yml配置如下:
server.port: 8601server.host: "ip"elasticsearch.url: "http://ip:9200" //elsaticsearch 服务ip和端口xpack.security.enabled: false
  1. 启动kibana
nohup ./bin/kibana >nohup.out 2>&1 &

安装x-pack [该软件是收费的]

  1. 下载:x-pack-5.5.2.zip
  2. 切换到elasticsearch下:%ES_HOME/%下面。
    执行如下命令: bin/elasticsearch-plugin install file:///path/to/file/x-pack-5.5.2.zip即可。
  3. 切换到kibana下:KI_HOME下面。
    4.执行同样的命令:bin/elasticsearch-plugin install file:///path/to/file/x-pack-5.5.2.zip即可。

注意:

  1. 如果有远程机器相互访问,以上ip部分最好设置为机器的ip地址,避免使用localhost或者127.0.0.1
  2. 如果使用x-pack,默认是开启security功能,所以你需要在logstash部分设置用户名和密码才能让logstash和elasticsearch连接上。因为本人是在测试环境内部使用所以就省去了安全功能。如上所示,分别在elasticsearch.yml和kibana.yml中添加如下语句:
    xpack.security.enabled: false
  3. 使用x-pack会自动建立index,所以我们需要修改elasticsearch.yml文件如下:action.auto_create_index: +*
    这里我的设置几乎没有限制,任何名字的索引都可以建立。
阅读全文
0 0
原创粉丝点击