系統(tǒng)運(yùn)維
本文參考:https://www.cnblogs.com/yanshicheng/articles/9436373.html
創(chuàng)新互聯(lián)建站服務(wù)項(xiàng)目包括寶安網(wǎng)站建設(shè)、寶安網(wǎng)站制作、寶安網(wǎng)頁制作以及寶安網(wǎng)絡(luò)營(yíng)銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,寶安網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到寶安省份的部分城市,未來相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!? ? ? ? ? ? ? ?https://www.cnblogs.com/fawaikuangtu123/articles/10360264.html
1.logstash安裝(jdk提前安裝1.8)
rpm -ivh? logstash-6.6.2.rpm
2.上傳數(shù)據(jù)庫(kù)驅(qū)動(dòng)jar包
wget? https://dev.mysql.com/get/Downloads/Connector-J/Mysql-connector-java-5.1.48.tar.gz
mkdir?-p?/usr/share/logstash/vendor/jar/jdbc cd?/usr/share/logstash/vendor/jar/jdbc [root@localhost?soft]#?cd?/usr/share/logstash/vendor/jar/jdbc [root@localhost?jdbc]#?ll total?984 -rw-r--r--.?1?logstash?logstash?1006959?Jul?11?19:43?MYSQL-connector-java-5.1.48-bin.jar [root@localhost?jdbc]#
3.數(shù)據(jù)庫(kù)創(chuàng)建庫(kù) 并授權(quán)用戶
create?database?nginxlog; use?nginxlog; CREATE?TABLE?`consumerlog`?( ??`client_ip`?varchar(128)?DEFAULT?NULL, ??`log_time`?timestamp?NOT?NULL?DEFAULT?CURRENT_TIMESTAMP, ??`status`?int(6)?DEFAULT?NULL, ??`http_referer`?text, ??`AgentVersion`?varchar(512)?DEFAULT?NULL, )? grant?all??on??nginxlog.*?to??nginxlog@\'%\'??identified??by??\'123456\';
4.安裝?logstash-output-jdbc插件
vim?/usr/share/logstash/Gemfile #?source?https://rubygems.org??將國(guó)外的源注釋,換成國(guó)內(nèi)的 source?https://gems.ruby-china.com/
/usr/share/logstash/bin/logstash-plugin?install?logstash-output-jdbc Validating?logstash-output-jdbc Installing?logstash-output-jdbc Installation?successful ? /usr/share/logstash/bin/logstash-plugin?list?|?grep?jdbc logstash-input-jdbc logstash-output-jdbc
5.nginx日志格式設(shè)置
log_format???access_log_json?\'{client_ip:$remote_addr,log_time:$time_local,request:$request,status:$status,body_bytes_sent:$body_bytes_sent,http_referer:$http_referer,AgentVersion:$http_user_agent,upstream_addr:$upstream_addr,request_time:$request_time,upstream_response_time:$upstream_response_time}\';
6.
[root@localhost conf.d]# cat consumer_log.conf?
/etc/logstash/conf.d
input{ ??file{ ????path?=>?/usr/local/tengine-2.1.2/logs/sxt-consumer.log ????start_position?=>?beginning ????stat_interval?=>?2 ????codec?=>?json ??}? } ? filter?{ ????if?[status]?!=?200?{? ????????drop{} ????} } output{ ??jdbc{ ????connection_string?=>?jdbc:mysql://192.168.14.61/nginxlog?user=nginxlog&password=123456&useUnicode=true&characterEncoding=UTF8 ????statement?=>?[insert?into?consumerlog(client_ip,status,http_referer,AgentVersion)?VALUES(?,?,?,?),?client_ip,status,http_referer,AgentVersion] ?} }
7.啟動(dòng)logstash
systemctl start logstash
8.驗(yàn)證數(shù)據(jù)