2.3 Logstash掃描課程計(jì)劃媒資
Logstash定時(shí)掃描課程媒資信息表,并將課程媒資信息寫(xiě)入索引庫(kù)。
‘ 2.3.1 創(chuàng)建索引
1、創(chuàng)建xc_course_media索引
2、并向此索引創(chuàng)建如下映射
Post http://localhost:9200/xc_course_media/doc/_mapping
我們一直強(qiáng)調(diào)成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)對(duì)于企業(yè)的重要性,如果您也覺(jué)得重要,那么就需要我們慎重對(duì)待,選擇一個(gè)安全靠譜的網(wǎng)站建設(shè)公司,企業(yè)網(wǎng)站我們建議是要么不做,要么就做好,讓網(wǎng)站能真正成為企業(yè)發(fā)展過(guò)程中的有力推手。專業(yè)的建站公司不一定是大公司,成都創(chuàng)新互聯(lián)作為專業(yè)的網(wǎng)絡(luò)公司選擇我們就是放心。
[mw_shl_code=applescript,true]{ "properties" : {
"courseid" : {
"type" : "keyword"
},
"teachplan_id" : {
"type" : "keyword"
},
"media_id" : {
"type" : "keyword"
},
"media_url" : {
"index" : false,[/mw_shl_code][mw_shl_code=applescript,true]
"type" : "text"
},
"media_fileoriginalname" : {
"index" : false,
"type" : "text"
}
} }[/mw_shl_code]
2.3.2 創(chuàng)建Logstash模板文件
在logstach的con?g目錄創(chuàng)建xc_course_media_template.json,內(nèi)容如下:
本教程的xc_course_media_template.json目錄是:D:/ElasticSearch/logstash7.2.1/con?g/xc_course_media_template.json
[mw_shl_code=applescript,true]{
"mappings" : {
"doc" : {
"properties" : {
"courseid" : {
"type" : "keyword"
},
"teachplan_id" : {
"type" : "keyword"
},
"media_id" : {
"type" : "keyword"
},
"media_url" : {
"index" : false,
"type" : "text"
},
"media_fileoriginalname" : {
"index" : false,
"type" : "text"
}
}
},
"template" : "xc_course_media" }[/mw_shl_code]
2.3.3 配置MySQL.conf
在logstash的con?g目錄下配置mysql_course_media.conf文件供logstash使用,logstash會(huì)根據(jù) mysql_course_media.conf文件的配置的地址從MySQL中讀取數(shù)據(jù)向ES中寫(xiě)入索引。 參考https://www.elastic.co/guide/en/ ... ns-inputs-jdbc.html
配置輸入數(shù)據(jù)源和輸出數(shù)據(jù)源。
[mw_shl_code=applescript,true]
2.3.4 啟動(dòng)logstash.bat
啟動(dòng)logstash.bat采集teachplan_media_pub中的數(shù)據(jù),向ES寫(xiě)入索引。
input {
stdin {
} jdbc {
jdbc_connection_string => "jdbc:mysql://localhost:3306/xc_course? useUnicode=true&characterEncoding=utf‐8&useSSL=true&serverTimezone=UTC" # the user we wish to excute our statement as
jdbc_user => "root" jdbc_password => mysql
# the path to our downloaded jdbc driver
jdbc_driver_library => "F:/develop/maven/repository3/mysql/mysql‐connector‐java/5.1.41/mysqlconnector‐java‐5.1.41.jar" # the name of the driver class for mysql jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
#要執(zhí)行的sql文件
#statement_filepath => "/conf/course.sql"
statement => "select * from teachplan_media_pub where timestamp >
date_add(:sql_last_value,INTERVAL 8 HOUR)"
#定時(shí)配置 schedule => "* * * * *" record_last_run => true last_run_metadata_path => "D:/ElasticSearch/logstash‐6.2.1/config/xc_course_media_metadata" } }
output {
elasticsearch {
#ES的ip地址和端口
hosts => "localhost:9200"
#hosts => ["localhost:9200","localhost:9202","localhost:9203"]
#ES索引庫(kù)名稱 index => "xc_course_media" document_id => "%{id}"
document_type => "doc"
template =>"D:/ElasticSearch/logstash‐6.2.1/config/xc_course_media_template.json" template_name =>"xc_course_media" template_overwrite =>"true" } stdout { #日志輸出 codec => json_lines } }[/mw_shl_code]
網(wǎng)站名稱:Java的新項(xiàng)目學(xué)成在線筆記-day15(五)
分享路徑:http://chinadenli.net/article16/jiisdg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動(dòng)網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、定制網(wǎng)站、域名注冊(cè)、面包屑導(dǎo)航、網(wǎng)站收錄
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
全網(wǎng)營(yíng)銷(xiāo)推廣知識(shí)