rsyslog 瀛樺偍鍒?mysql

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了rsyslog 瀛樺偍鍒?mysql相关的知识,希望对你有一定的参考价值。

    1. 鏍囩锛?a href='http://www.mamicode.com/so/1/kth' title='kth'>kth   admin   httpd鏈嶅姟   鍑虹幇   blank   rest   theme   pre   鏁版嵁   

      杈撳嚭Host1/2鐨勭郴缁熸棩蹇? 璁板綍鍒癿ysql鏈嶅姟鍣ㄦ暟鎹簱涓? 骞跺彂甯僱oganalyzer

      缁撴瀯鍏崇郴濡備笅鍥?

      鎶€鏈垎浜浘鐗? src=

       

      鍑嗗宸ヤ綔:

      1. VMware

      2. CentOS 7 鏈€灏忕郴缁熷畨瑁呴暅鍍?/h3>

      3. loganalyzer婧愮爜鍖?涓嬭浇

      4. 瀹夎涓夊彴涓绘満, 鎷疯礉loganalyzer鍒癕ariaDB涓绘満

      IP鍦板潃涓庝富鏈哄搴斿叧绯昏〃:

      MariaDB涓绘満 192.168.142.128/24
      HOST1 192.168.142.135/24
      HOST2 192.168.142.141/24

       

       

       

      MariaDB鏈嶅姟鍣ㄦ搷浣?

      1. yum -y install mariadb mariadb-server httpd php php-mysql php-gd
        #瀹夎mysql鏈嶅姟绔? httpd鏈嶅姟绔? php --> php-gd 鏄?loganalyzer 闇€瑕佷娇鐢ㄧ殑
        systemctl start mariadb
      2. 鐧婚檰mysql 
        1. mysql -uroot -p  鐧婚檰;
        2. GRANT ALL ON Syslog.* TO 鈥?/span>sysloguser鈥?/span>@鈥?/span>192.168.142.%鈥?/span> INDENTIFIED BY 鈥?/span>123456鈥?/span>; FLUSH PRIVILEGES;

          寤虹珛 rsyslog 鏁版嵁搴撹处鍙峰苟鎺堟潈;

          • 娉ㄦ剰: 姝ゅSyslog鏁版嵁搴撳苟涓嶉渶瑕佹垜浠嚜宸卞缓绔? 鍦℉OST1/2涓婂畨瑁卹syslog-mysql鍚? 浼氭湁涓€涓?sql 鑴氭湰, 璇ユ暟鎹簱鍙婅〃鐢?姝よ剼鏈?寤虹珛, 鍚庢枃鏈夋彁鍒?/h4>

      3. 缂栬緫mysql閰嶇疆鏂囦欢
      4. vim /etc/my.cnf
        
        ###娣诲姞濡備笅椤圭洰
        
        skip_name_resolve = on
        innodb_file_per_table = on
        
        ####淇濆瓨閫€鍑? 閲嶅惎鏈嶅姟
        systemctl restart mariadb

         

      HOST1/2 鎿嶄綔:

      1. yum -y install rsyslog-mysql mariadb
        # 瀹夎mysql妯″潡, 瀹夎mysql瀹㈡埛绔?br />mysql -usysloguser -p123456 -h192.168.142.128
        # 娴嬭瘯鏄惁鍙互杩炴帴涓?--> 濡傛灉杩炴帴澶辫触, 鍦╩ariadb鏈嶅姟鍣ㄧ閲嶅仛鎺堟潈; 妫€鏌ユ湇鍔″櫒鐨勯槻鐏鍜宻elinux鏄惁鍏抽棴

         

      2. 鏌ョ湅rsyslog-mysql 杩欎釜鍖呯浉鍏虫枃浠剁瓑:

        [[email protected] ~]# rpm -ql rsyslog-mysql
        /usr/lib64/rsyslog/ommysql.so --> rsyslog妯″潡
        /usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql --> 姝ql鑴氭湰鍗充负涓婃枃鎻愬埌鐨? rsyslog-mysql杩欎釜鍖呮彁渚涚殑 寤哄簱鑴氭湰

         

      3. 閫氳繃杈撳叆閲嶅畾鍚戠殑鏂瑰紡, 瀹夎涓婅堪sql鑴氭湰: 
        mysql -usysloguser -h192.168.142.128 -p < /usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql

        妫€鏌ュ簱寤虹珛鏄惁鎴愬姛:鎶€鏈垎浜浘鐗? src=

         

      4. 缂栬緫 /etc/rsyslog.conf 閰嶇疆鏂囦欢
        vim /etc/rsyslog.conf
            ####MODULES####
            $ModLoad ommysql      --> 鍔犺浇ommysql妯″潡浠ユ敮鎸佸姛鑳?
        
            ####RULES####
            *.info;mail.none;       :ommysql:192.168.142.128,Syslog,sysloguser,123456

         

      5. 閲嶅惎rsyslog鏈嶅姟 systemctl restart rsyslog 

       鍥炲埌MariaDB鏈嶅姟鍣? 閮ㄧ讲 loganalyzer 

      • mysql -uroot -p -->杩炴帴鏌ョ湅鏄惁璁板綍鎴愬姛
      MariaDB [(none)]> use Syslog
      MariaDB [Syslog]> SELECT * FROM SystemEventsG;

      鎶€鏈垎浜浘鐗? src=

      鎶€鏈垎浜浘鐗? src=

       

      1. 娴嬭瘯httpd, php, php-mysql 鏄惁閰嶇疆鎴愬姛 --> 鍙傝涓婁竴绡?
        • 杩欓噷纰板埌涓€涓棶棰橈細sysloguser 1045鎷掔粷鐧婚檰;root鍙互鐧婚檰; 瑙e喅鍔炴硶: 鍒犻櫎鎵€鏈夌┖瀵嗙爜鐢ㄦ埛;
          -21-[[email protected]]16:07 ~ # mysql -usysloguser -h192.168.142.128 -p
          Enter password: 
          ERROR 1045 (28000): Access denied for user 鈥?/span>sysloguser鈥?/span>@鈥?/span>vm鈥?/span> (using password: YES)

          鎶€鏈垎浜浘鐗? src=

           

      2. 閮ㄧ讲loganalyzer
        1. 涓嬭浇璧勬簮鍖? 瑙e帇鎶€鏈垎浜浘鐗? src=

           

        2. 鎴戜滑闇€瑕?./contrib 涓嬬殑涓や釜鑴氭湰, 浠ュ強./src 涓嬬殑鍏ㄩ儴鏂囦欢
          -44-[[email protected]]16:18 ~/loganalyzer-4.1.6 # ls
          ChangeLog  contrib  COPYING  doc  INSTALL  src
          -45-[[email protected]]16:18 ~/loganalyzer-4.1.6 # cp -r ./src /var/www/html/log
          -46-[[email protected]]16:20 ~/loganalyzer-4.1.6 # cd /var/www/html/log
          -47-[[email protected]]16:20 /var/www/html/log # ls
          admin               chartgenerator.php  cron         export.php   include      js         reportgenerator.php  statistics.php  userchange.php
          asktheoracle.php    classes             css          favicon.ico  index.php    lang       reports.php          templates
          BitstreamVeraFonts  convert.php         details.php  images       install.php  login.php  search.php           themes
          -48-[[email protected]]16:20 /var/www/html/log # cd -
          /root/loganalyzer-4.1.6
          -49-[[email protected]]16:20 ~/loganalyzer-4.1.6 # ls
          ChangeLog  contrib  COPYING  doc  INSTALL  src
          -50-[[email protected]]16:20 ~/loganalyzer-4.1.6 # cp ./contrib/*.sh /var/www/html/log
          -51-[[email protected]]16:21 ~/loganalyzer-4.1.6 # cd -
          /var/www/html/log
          -52-[[email protected]]16:21 /var/www/html/log # ls
          admin               chartgenerator.php  convert.php  details.php  images     install.php  login.php            search.php      templates
          asktheoracle.php    classes             cron         export.php   include    js           reportgenerator.php  secure.sh       themes
          BitstreamVeraFonts  configure.sh        css          favicon.ico  index.php  lang         reports.php          statistics.php  userchange.php
          -53-[[email protected]]16:21 /var/www/html/log # chmod +x *.sh
          -54-[[email protected]]16:21 /var/www/html/log # ./configure.sh 
          -55-[[email protected]]16:21 /var/www/html/log # ./secure.sh 
          -56-[[email protected]]16:21 /var/www/html/log # chmod -x *.sh
          -57-[[email protected]]16:21 /var/www/html/log # touch config.php;chmod 666 config.php

           

        3. 鐩存帴璁块棶192.168.142.128/log 
          • 鎶€鏈垎浜浘鐗? src=

             

        4. 鐩存帴鐐瑰嚮Click here   寮€濮嬪畨瑁?/strong>
        5. 鍦ㄧ涓夋(Step 3),鍙互鍕鹃€? 骞朵娇鐢╩ysql鍋?loganalyzer 鐨勭敤鎴锋暟鎹簱; 鎴戜滑杩欓噷鍋氭祴璇曞氨鐩存帴璺宠繃浜?img alt="鎶€鏈垎浜浘鐗? src="http://image.mamicode.com/info/201806/20180617173716653579.png" />

           

        6. Step 7鎶€鏈垎浜浘鐗? src=

          • 璇峰姟蹇呬娇鐢╟hrome, 鐐瑰嚮MYSQL Native鍚? IE/ EDGE/ 360娴忚鍣ㄤ笉浼氬脊鍑轰笅闈㈢殑鏁版嵁搴撻€夐」妗?

        7. 鎼炲畾鎶€鏈垎浜浘鐗? src=

           

       

       


       

      鎬荤粨: 

      1. 浣跨敤绾磥鐨勮櫄鎷熸満瀹夎; 杩欐鍋锋噿, 涓婃鐢ㄥ畬httpd瀹為獙鍚庢帴鐫€浣跨敤, 鍑虹幇浜唌ysql鎶ラ敊鐨勯棶棰?

      2. 360娴忚鍣ㄥ瀮鍦? 娴垂鎴戝崐涓皬鏃?

      3. 涓嶈鎬曠帺鍧忎簡, 澶т笉浜嗛噸瑁? 鍙嶆ks鏂囦欢鍋氬ソ浜? 瑁呯郴缁熷張涓嶇敤鍜卞姩鎵?/a>

       

    2. 以上是关于rsyslog 瀛樺偍鍒?mysql的主要内容,如果未能解决你的问题,请参考以下文章

      MySQL瀛樺偍娴烽噺鏁版嵁鐨勬渶鍚庝竴鎷涳細鍒嗗簱鍒嗚〃

      SqlServer楂樼骇鐗规€?-瀛樺偍杩囩▼

      OwnCloud寤虹珛灞炰簬鑷繁绉佹湁鐨勪簯瀛樺偍缃戠洏

      鏈懆鐩存挱棰勫憡 | 涓棿浠?Kafka 浼佷笟搴旂敤瀹炴垬銆丏M8 鏁版嵁瀛樺偍绠$悊

      绋嬪簭鎬ц兘浼樺寲涔嬬綉缁滀紶杈撲笌鏁版嵁瀛樺偍浼樺寲锛堜簲锛変笅

      琛ㄦ牸瀛樺偍Tablestore缁撳悎Spark鐨勪簯涓婃祦鎵逛竴浣撳ぇ鏁版嵁鏋舵瀯