centos下elk5.4.0部署

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ricardo_leite/article/details/72732225

基础框架安装

1. 安装jdk1.8

  • 查看Linux内核版本:uname -a
  • 下载jdk(x64):
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz
  • 解压后,设置环境变量:
JAVA_HOME=/usr/local/java/jdk1.8.0_121
PATH=\$JAVA_HOME/bin:\$PATH
CLASSPATH=\$JAVA_HOME/jre/lib/ext:\$JAVA_HOME/lib/tools.jar
export PATH JAVA_HOME CLASSPATH

2. 安装elasticsearch

  • 编辑limits.conf 文件
    vi /etc/security/limits.conf
    soft nofile 65536
    hard nofile 65536

  • vi /etc/security/limits.d/90-nproc.conf
    soft nproc 2048

  • vi /etc/sysctl.conf添加下面配置:
    vm.max_map_count=655360
    sysctl -p

    vi /config/jvm.options(配置初始化堆内存和最大堆内存)
    -Xms2g
    -Xmx2g

  • elasticsearch.yml配置
    network.bind_host: 0.0.0.0
    网络配置(否则elasticsearch只能本机访问,其他机器无法访问)
    cluster.name: meb-es
    node.name: ip-10-00-00-01-node1
    node.master: false

    指定该节点是否有资格被选举成为node,默认是true,es是默认集群中的第一台机器为master,如果这台机挂了就会重新选举master。
    node.data: true
    指定该节点是否存储索引数据,默认为true。
    path.data: /gomeo2o/data/elasticsearch
    path.logs: /gomeo2o/logs/elasticsearch
    network.host: 10.00.00.01
    http.port: 9200
    discovery.zen.ping.unicast.hosts: ["10.00.00.01", "10.00.00.02", "10.00.00.03"]

    设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点。

  • 启动后的检查
    http://localhost:9200/?pretty

3. 安装kibana

  • 下载安装kibana(官方建议kibana与elasticsearch使用的版本号一致)
    wget https://artifacts.elastic.co/downloads/kibana/kibana-5.4.0-linux-x86_64.tar.gz
    sha1sum kibana-5.4.0-linux-x86_64.tar.gz
    tar -xzf kibana-5.4.0-linux-x86_64.tar.gz
    cd kibana/

  • 下载安装darwin
    wget https://artifacts.elastic.co/downloads/kibana/kibana-5.4.0-darwin-x86_64.tar.gz
    shasum kibana-5.4.0-darwin-x86_64.tar.gz
    也可以sha1sum kibana-5.4.0-darwin-x86_64.tar.gz
    tar -xzf kibana-5.4.0-darwin-x86_64.tar.gz
    cd kibana/

  • 基础配置kibana.yml
    server.port: 5601
    默认端口5601
    server.host: "10.00.00.01"
    服务地址,默认是localhost,即其他机器不能访问。
    server.name: "meb-kibana"
    elasticsearch.url: "http://10.00.00.01:9200"

    es地址
    kibana.index: ".kibana"
    kibana会去es里查找该index,如果没有则创建这个索引,用来对搜索进行打分

    扫描二维码关注公众号,回复: 5965901 查看本文章
  • 安装x-pack
    bin/elasticsearch-plugin install x-pack
    bin/kibana-plugin install x-pack

  • 启动和停止
    ./bin/kibana
    后台启动nohup ./bin/kibana &

4. 安装logstash

  • 下载并解压
    wget https://artifacts.elastic.co/downloads/logstash/logstash-5.4.0.zip
    unzip logstash-5.4.0.zip /usr/local

  • 运行logstash(验证logstash是否安装成功)
    ./bin/logstash -e 'input { stdin { } } output { stdout {} }'
    -e命令是通过命令行的方式指定logstash的配置
    在控制台看到“Pipeline main started”之后,输入hello wolrd,即可看到输出结果:

2013-11-21T01:22:14.405+0000 0.0.0.0 hello world
  • 配置logstash
    在任意位置新建配置文件service-product.conf:
input {
  file {
    path => "/xxx/logs/xxx/xxx*.log"
    start_position => beginning
  }
}
output {
  elasticsearch { hosts => ["10.00.00.01:9200"]
  #index => "xxx-product-%{+YYYY.MM.dd}"
  #这里如果不设置索引名字,elasticsearch会默认创建名称为logstash-YYYY-MM-DD的索引
 }
  stdout { codec => rubydebug }
}
重新运行logstash:
./bin/logstash -f ./config/service-product.conf
-f指定刚才创建的配置文件地址

至此搭建完成

filebeat配置(可以不配置,直接使用logstash收集)

在数据来源的机器上配置日志收集

  • 下载日志配置文件
    在官网上下载配置文件
    wget https://download.elastic.co/demos/logstash/gettingstarted/logstash-tutorial.log.gz
    解压后得到logstash-tutorial.log

  • filebeat安装配置
    在典型案例中,filebeat应该和logstash分为不同的机器进行部署

    curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.4.0-x86_64.rpm
    sudo rpm -vi filebeat-5.4.0-x86_64.rpm

    配置filebeat
    修改/etc/filebeat/filebeat.yml
    (logstash-tutorial.log是上面下载的log文件)

filebeat.prospectors:
- input_type: log
  paths:
    - /path/to/file/logstash-tutorial.log 
output.logstash:
  hosts: ["localhost:5043"]

猜你喜欢

转载自blog.csdn.net/ricardo_leite/article/details/72732225