前言

最近看了elasticsearch出了7.x的版本,加上项目中用elasticsearch挺频繁,索性记录下学习的过程,一开始,准备在本机上面搭建ELK

搭建ELK——elasticsearch

第一步

选择合适的版下载本:https://www.elastic.co/cn/dow...

第二步

下载完成后解压后进入目录

➜  elasticsearch-7.2.0 ls
LICENSE.txt    NOTICE.txt     README.textile bin            config         data           jdk            lib            logs           modules        plugins

第三步

启动命令:

bin/elasticsearch

第四步

浏览器输入地址:http://localhost:9200
看到如下界面为安装成功

{
    "name": "zhangpeileideMacBook-Pro.local",
    "cluster_name": "elasticsearch",
    "cluster_uuid": "s_wuhCF5Q_-pf7iZ5NNxYg",
    "version": {
        "number": "7.2.0",
        "build_flavor": "default",
        "build_type": "tar",
        "build_hash": "508c38a",
        "build_date": "2019-06-20T15:54:18.811730Z",
        "build_snapshot": false,
        "lucene_version": "8.0.0",
        "minimum_wire_compatibility_version": "6.8.0",
        "minimum_index_compatibility_version": "6.0.0-beta1"
    },
    "tagline": "You Know, for Search"
}

搭建ELK——logstash

第一步:

选择合适的版本下载:https://www.elastic.co/cn/dow...

第二步:

进入解压后目录:

➜  logstash-7.2.0 ls
CONTRIBUTORS             Gemfile.lock             NOTICE.TXT               config                   lib                      logstash-core            modules                  vendor
Gemfile                  LICENSE.txt              bin                      data                     logs                     logstash-core-plugin-api tools                    x-pack

第三步

进入config目录后,修改logstash.conf文件如下

# Sample Logstash configuration for creating a simple
# Beats -> Logstash -> Elasticsearch pipeline.

input {
    file{
        path => "/Users/zhangpeilei/test.txt"
    }
}
output {
  elasticsearch {
    hosts => ["http://localhost:9200"]
    index => "test-%{+YYYY.MM.dd}"
    #user => "elastic"
    #password => "changeme"
  }
}

实现效果:将/Users/zhangpeilei/test.txt文件内容写入到ES

第四步

执行启动命令

bin/logstash -f config/logstash.conf

搭建ELK——Kibana

第一步

选择合适的版下载本:https://www.elastic.co/cn/dow...

第二步

进入解压后目录

➜  kibana-7.2.0-darwin-x86_64 ls
LICENSE.txt  NOTICE.txt   README.txt   bin          built_assets config       data         node         node_modules optimize     package.json plugins      src          target       webpackShims x-pack

第三步

配置文件config/kibana.yml修改这一行:elasticsearch.hosts: ["http://localhost:9200"]

第四步

启动:

bin/kibana

启动ELK

浏览器输入:http://localhost:5601
配置完索引后即可看到数据

clipboard.png

更多文章关注博客:https://www.zplxjj.com和公众号
clipboard.png


stone想静静
45 声望7 粉丝

春暖花痴开 傻傻创未来