elk系列教程:docker中安裝配置elk

elasticSearchhtml

Docker安裝elasticsearch:java

docker pull docker.io/elasticsearch:7.2.0

啓動:node

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" --name es -d docker.io/elasticsearch:7.2.0

logstashmysql

Docker安裝logstashgit

docker pull docker.io/logstash:7.2.0

配置:github

運行容器:sql

docker run --name logstash -d -p 5044:5044 -p 9600:9600 logstash:7.2.0

建立配置文件目錄,設置權限:docker

mkdir -p /home/elk/logstash/config && \
chown -R 1000 /home/elk/logstash

拷貝配置文件:elasticsearch

docker cp logstash:/usr/share/logstash/config /home/elk/logstash/config

刪除容器:code

docker rm -f logstash

從新運行容器:

docker run --name logstash -d \
-p 5044:5044 \
-p 9600:9600 \
-v /home/elk/logstash/config:/usr/share/logstash/config \
-v /home/elk/logstash/jars/mysql-connector-java-5.1.47.jar:/usr/share/logstash/logstash-core/lib/jars/mysql-connector-java-5.1.47.jar \
-e xpack.monitoring.elasticsearch.hosts=http://192.168.52.131:9200 \
logstash:7.2.0 \
-f /usr/share/logstash/config/logstash-sample.conf

logstash-sample.conf配置:

input {
  jdbc {
    jdbc_driver_library => "mysql-connector-java-5.1.47.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://127.0.0.1:3306/sms_db"
    jdbc_user => "root"
    jdbc_password => "x5"
    schedule => "* * * * *"
    jdbc_default_timezone => "Asia/Shanghai"
    statement => "select * from sms_sendsms"
    use_column_value  => false
  }
}
output{
    elasticsearch{
        hosts => "192.168.44.129:9200" # ES鏈接
        index => "uum_user_log"      # ES索引名稱
        document_id => "%{id}"   # id對應ORACLE中主鍵字段
    }
}

注:驅動程序這裏我搞了很久都沒有搞定,後面看到官方的github裏面有人提問說將jar放到logstash容器裏面的/usr/share/logstash/logstash-core/lib/jars文件夾中,好像logstash默認就是讀取jars文件夾中的驅動,因此jdbc_driver_library 這個位置直接寫驅動名稱就好了,因此猜測啓動語句中,不包含第二條掛載語句的話,jdbc_driver_library => " ../../../config/ mysql-connector-java-5.1.47.jar"是否能夠這種掛載文件,本人未做校驗。

kibana

Docker安裝kibana

docker pull docker.io/kibana:7.2.0

配置:

docker run --name kibana -d \ -p 5601:5601 \ -e ELASTICSEARCH_HOSTS=http://192.168.52.131:9200 \ -v /home/elk/kibana/plugins:/usr/share/kibana/plugins:rw \ kibana:7.2.0

原文地址:https://www.35youth.cn/671.html

來源:三無青年博客
原文:http://www.35youth.cn/671.html
相關文章
相關標籤/搜索