ELK安装步骤

作者: pgz_lq | 来源:发表于2018-07-03 20:06 被阅读107次

    ES安装

    1. 配置jdk环境

        (建议放在/usr/local下解压,如果启动完ES服务后,查看服务状态时,出现在某些路径下没有java的情况【which: no java in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)】,建议/usr/local作为jdk路径),vim /etc/profile (打开环境配置文件,在文件最后写入如下代码)

    export JAVA_HOME=jdk路径

    export CLASSPATH=.:$JAVA_HOME/lib.tools.jar

    export PATH=$JAVA_HOME/bin:$PATH

    2.yum 安装ES

    1.下载并安装ES的yum公钥

        rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch

    2.配置ES的yum源

        vim /etc/yum.repos.d/elasticsearch.repo

        输入下面内容

        [elasticsearch-2.x]

        name=Elasticsearch repository for 2.x packages

        baseurl=http://packages.elastic.co/elasticsearch/2.x/centos gpgcheck=1 gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch enabled=1

    3.安装ES 

        yum install elasticsearch此步骤之前如需更新yum缓存请执行yum makecache

    4.修改配置文件/usr/lib/systemd/system/elasticsearch.service 和/etc/sysconfig/elasticsearch

        1.在/etc/sysconfig/elasticsearch中的ES_JAVA_OPTS被引用之前赋值 ES_JAVA_OPTS="-Des.insecure.allow.root=true",注意要打开CONF_DIR=/etc/elasticsearch的注释,其他配置路经可自由配置

        2.在/usr/lib/systemd/system/elasticsearch.service中配置环境变量的路径

    5.在配置完配置文件后执行 systemctl daemon-reload以重载所有修改过的配置文件

        Systemd 默认从目录/etc/systemd/system/读取配置文件。但是,里面存放的大部分文件都是符号链接,指向目录/usr/lib/systemd/system/,真正的配置文件存放在那个目录。

    6.执行systemctl enable elasticsearch.service 使其在上面两个目录之间,建立符号链接

    7.开启ES服务

        执行命令 systemctl start elasticsearch 

    8.查看服务状态

        执行命令 systemctl status elasticsearch 

    9.运行测试 

        执行命令curl -X GET localhost:9200 显示如下内容:

        {

          "name" : "Quentin Beck",

          "cluster_name" : "elasticsearch",

          "cluster_uuid" : "2m5kmMSRR22xF0P_nx0tLw",

          "version" : {

            "number" : "2.4.6",

            "build_hash" : "5376dca9f70f3abef96a77f4bb22720ace8240fd",

            "build_timestamp" : "2017-07-18T12:17:44Z",

            "build_snapshot" : false,

            "lucene_version" : "5.5.4"

          },

          "tagline" : "You Know, for Search"

    }

    10.配置IP访问ES 

        打开/etc/elasticsearch/elasticsearch.yml

        vim /etc/elasticsearch/elasticsearch.yml

        修改配置如下内容

    11.ElasticSearch_Head配置

            切换路径到插件执行文件位置:->  cd  /usr/share/elasticsearch/bin

            执行命令: ->./plugin install mobz/elasticsearch-head

      常规EK路径有:

        1.service启动路径  /usr/lib/systemd/system/elasticsearch.service

        2.sevice配置路径  /etc/sysconfig/elasticsearch

        3.EK配置路径        /etc/elasticsearch

        3.bin启动EK路径    /usr/share/elasticsearch/bin/elasticsearch

        4.日志存储路径   /var/log/elasticsearch

        5.数据存储路径      /var/lib/elasticsearch


    Logstash安装

    1.下载安装包 

        执行命令:-> wget https://artifacts.elastic.co/downloads/logstash/logstash-6.2.4.tar.gz

    2.解压安装包 

        执行命令:-> tar -xf logstash-6.2.4.tar.gz

    3.添加启动配置文件

    在目录/root/logstash-2.3.4下创建目录conf和文件conf/logstash-json.conf编辑如下内容

    input{

    tcp { 

    mode => "server" 

    host => "0.0.0.0" 

    port => 4567 

    codec => json_lines 

    }

    filter{

    json{

    source => "message"

    }

    }

    output{

    elasticsearch {

        hosts  => "localhost:9200"

      index  => "faw_vk"

    document_type => "%{[message_type]}"

    stdout { codec => rubydebug}

    }

    4. 执行启动

        切换位置到 /root/logstash-6.2.4/bin(安装包解压文件夹位置下的bin目录)

        执行命令:->nohup ./logstash -f ../conf/logstash-json.conf  &    【-f时后跟规则文件】

        调试:在等待输入框中输入随便输入字符

    5.安装插件

    执行命令:->nohup ./logstash-plugin install logstash-codec-json_lines &

    6.常见问题

    1.当ES没有停止工作,但日志却不记录、可能是Logstash停止了工作,此时需要重新启动Logstash


    Kibana安装

    1.下载安装包 

    执行命令:-> wget https://download.elastic.co/kibana/kibana/kibana-4.5.4-linux-x64.tar.gz

    2.解压安装包 

    执行命令: ->tar -xf kibana-4.5.4-linux-x64.tar.gz

    3.修改配置

        切换位置到 /root/kibana-4.5.4-linux-x64/config

        执行命令-> vim kibana.yml

        开启并设置IP和端口号

    4.执行启动

        切换位置到 /root/kibana-4.5.4-linux-x64/bin(安装包解压文件夹位置下的bin目录)

        执行命令:->nohup ./kibana&  启动Kibana

    相关文章

      网友评论

      • pgz_lq:第一次写文章,请多指教
        pgz_lq:@旁观者945 :kissing_heart::kissing_heart::kissing_heart:

      本文标题:ELK安装步骤

      本文链接:https://www.haomeiwen.com/subject/kqijuftx.html