Docker installer Logstash

Logstash


Logstash est une infrastructure de collecte et de traitement de journaux légère qui peut facilement collecter des journaux dispersés et diversifiés, effectuer un traitement personnalisé, puis les transférer vers un emplacement spécifié, tel qu'un serveur ou un fichier.


Docker installe Logstash.



1: Trouvez le miroir: recherche de docker Logstash.

docker search Logstash




2: Téléchargez le miroir:

 

docker pull logstash:5.6


Remarque: Pour afficher la version du miroir et du TAG, vous devez afficher l'adresse sur le hub docker comme suit: https://hub.docker.com Après avoir entré, recherchez dans la zone de recherche dans le coin supérieur gauche du page



3: Vérifiez l'image que nous avons téléchargée: images du docker



4: Courir


Référence: https://blog.csdn.net/qq_33547169/article/details/86629261



Créer un dossier (pour monter des fichiers de conteneur)

mkdir /usr/local/logstash/config


Créer des fichiers de configuration associés


logstash.yml (un fichier vide fera l'affaire)
log4j2.properties

logger.elasticsearchoutput.name = logstash.outputs.elasticsearch

logger.elasticsearchoutput.level = debug


pipelines.yml (la petite barre est très importante)

- pipeline.id: my-logstash  
  path.config: "/usr/share/logstash/config/*.conf"  
  pipeline.workers: 3


* fichier .conf

input {    
        jdbc {      
                # mysql jdbc connection string to our backup databse  后面的test 对应mysql中的test数据库      
                jdbc_connection_string =>  "jdbc:mysql://127.0.0.1:3306/tensquare_article?characterEncoding=UTF8"      
                # the user we wish to excute our statement as      
                jdbc_user => "root"      
                jdbc_password => "123456"      
                # the path to our downloaded jdbc driver        
                jdbc_driver_library => "D:/logstash‐5.6.8/mysqletc/mysqlconnector‐java‐5.1.46.jar"      
                # the name of the driver class for mysql      
                jdbc_driver_class => "com.mysql.jdbc.Driver"      
                jdbc_paging_enabled => "true"      
                jdbc_page_size => "50000"      
                #以下对应着要执行的sql的绝对路径。      
                statement => "select id,title,content from tb_article"      
                #定时字段 各字段含义(由左至右)分、时、天、月、年,全部为*默认含义为 每分钟都更新        
                schedule => "* * * * *"    
                }  
        } 
output {    
        elasticsearch {      
                #ESIP地址与端口      
                hosts => "localhost:9200"       
                #ES索引名称(自己定义的)      
                index => "tensquare"      
                #自增ID编号      
                document_id => "%{id}"      
                document_type => "article"    
                }    
                stdout {        
                #以JSON格式输出        
                codec => json_lines    
                        }  
                }

Démarrez et exécutez:

docker run -d -p 5044:5044 -p 9600:9600 -it -v /usr/local/logstash/config/:/usr/share/logstash/config/  logstash:5.6



 

 

Je suppose que tu aimes

Origine blog.csdn.net/qq_22596931/article/details/115322058
conseillé
Classement