{"id":401,"date":"2016-11-04T17:10:29","date_gmt":"2016-11-04T09:10:29","guid":{"rendered":"https:\/\/yyshell.com\/?p=401"},"modified":"2018-02-24T22:10:33","modified_gmt":"2018-02-24T14:10:33","slug":"centos7%e4%b8%8b%e4%bd%bf%e7%94%a8rsyslogloganalyzermariadb%e9%83%a8%e7%bd%b2%e6%97%a5%e5%bf%97%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/yyshell.com\/?p=401","title":{"rendered":"CentOS7\u4e0b\u4f7f\u7528rsyslog+LogAnalyzer+MariaDB\u90e8\u7f72\u65e5\u5fd7\u670d\u52a1\u5668"},"content":{"rendered":"<p>\u5728\u65e5\u5e38\u5de5\u4f5c\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u642d\u5efa\u4e13\u95e8\u7684\u65e5\u5fd7\u670d\u52a1\u5668\u6765\u8bb0\u5f55\u670d\u52a1\u5668\u4e0a\u5404\u7c7b\u64cd\u4f5c\u53ca\u7cfb\u7edf\u4fe1\u606f\u3002\u4e3a\u4ec0\u4e48\u4e0d\u7528\u670d\u52a1\u5668\u672c\u5730\u7684\u65e5\u5fd7\u5462\u3002\u60f3\u8c61\u4e00\u4e0b\uff0c\u5982\u679c\u4f60\u7684\u670d\u52a1\u5668\u88ab\u5165\u4fb5\u6216\u8005\u6709\u5176\u4ed6\u4eba\u8ba4\u4e3a\u7be1\u6539\u4e86\u4f60\u7684\u65e5\u5fd7\uff0c\u7cfb\u7edf\u672c\u5730\u7684\u65e5\u5fd7\u8fd8\u53ef\u4fe1\u5417\uff1f\u6240\u4ee5\uff0c\u6211\u4eec\u9700\u8981\u642d\u5efa\u4e13\u95e8\u7684\u65e5\u5fd7\u670d\u52a1\u5668\u6765\u8bb0\u5f55\u65e5\u5fd7\u4fe1\u606f\u3002<\/p>\n<p>\u6211\u4eec\u6b64\u6b21\u7684\u73af\u5883\u662f\u670d\u52a1\u7aef\uff1aCentOS7\u670d\u52a1\u5668IP\u5730\u5740\u662f192.168.42.15.\u4e3b\u673a\u540d\uff1aloganalyzer<br \/>\n\u65e5\u5fd7\u5ba2\u6237\u7aef\u7684IP:192.168.42.101 \u4e3b\u673a\u540d\uff1aclient<\/p>\n<h3>\u5b89\u88c5LAMP\u73af\u5883<\/h3>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# yum -y install mariadb-server php php-fpm php-mysql<\/pre>\n<p>\u6ce8\uff1a\u5b89\u88c5php\u662f\u4f1a\u81ea\u52a8\u628ahttpd\u4f5c\u4e3a\u4f9d\u8d56\u5b89\u88c5\u4e0a\u3002<\/p>\n<p>\u628a\u5173\u952e\u7684\u670d\u52a1\u8bbe\u7f6e\u4e3a\u5f00\u673a\u81ea\u542f\u52a8\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# systemctl enable httpd.service mariadb.service php-fpm.service<\/pre>\n<p>\u542f\u52a8MariaDB\u6570\u636e\u5e93\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# systemctl start mariadb.service<\/pre>\n<p>\u521d\u59cb\u5316\u6570\u636e\u5e93:<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# mysql_secure_installation<\/pre>\n<p>\u9ed8\u8ba4\u6ca1\u6709root\u5bc6\u7801\uff0c\u5728\u521d\u59cb\u5316\u8fc7\u7a0b\u4e2d\uff0c\u5efa\u8bae\u5927\u5bb6\u8bbe\u7f6e\u4e0broot\u5bc6\u7801\uff01<\/p>\n<p>\u6539\u4e0bApache httpd\u914d\u7f6e\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# vim \/etc\/httpd\/conf.modules.d\/00-mpm.conf<\/pre>\n<p>\u4e3b\u914d\u7f6e\u6539\u6210\u8fd9\u6837\uff1a<\/p>\n<pre class=\"lang:apache decode:true \">#LoadModule mpm_prefork_module modules\/mod_mpm_prefork.so\r\nLoadModule mpm_event_module modules\/mod_mpm_event.so<\/pre>\n<p>\u6539\u53d8\u4e0bApache\u52a0\u8f7dphp\u7684\u914d\u7f6e\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# vim \/etc\/httpd\/conf.d\/php.conf<\/pre>\n<pre class=\"lang:apache decode:true \">&lt;FilesMatch \\.php$&gt;\r\n    SetHandler \"proxy:unix:\/var\/run\/php-fpm\/php-fpm.sock|fcgi:\/\/localhost\/\"\r\n&lt;\/FilesMatch&gt;<\/pre>\n<p>\u6ce8\u91ca\u4e0b\u9762\u4e24\u884c\uff1a<\/p>\n<pre class=\"lang:apache decode:true \">#php_value session.save_handler \"files\"\r\n#php_value session.save_path    \"\/var\/lib\/php\/session\"<\/pre>\n<p>\u6539\u4e0bphp\u7684\u914d\u7f6e\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# vim \/etc\/php.ini<\/pre>\n<pre class=\"lang:ini decode:true \">date.timezone = Asia\/Shanghai\r\ncgi.fix_pathinfo=0<\/pre>\n<p>\u7ee7\u7eed\u4fee\u6539\u4e0b\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# vim \/etc\/php-fpm.d\/www.conf<\/pre>\n<p>\u6539\u6210\u8fd9\u6837\uff1a<\/p>\n<pre class=\"lang:ini decode:true \">listen = \/var\/run\/php-fpm\/php-fpm.sock\r\n;listen.allowed_clients = 127.0.0.1\r\nlisten.owner = apache\r\nlisten.group = apache\r\nlisten.mode = 0600<\/pre>\n<p>\u542f\u52a8php-fpm\u548chttpd\u670d\u52a1<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# systemctl start php-fpm.service\r\n[root@loganalyzer ~]# systemctl start httpd.service<\/pre>\n<p>\u9632\u706b\u5899\u653e\u884c\u4e0b\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer html]# firewall-cmd --permanent --add-service=http\r\n[root@loganalyzer html]# firewall-cmd --reload<\/pre>\n<p>\u81ea\u6b64\uff0cLAMP\u73af\u5883\u642d\u5efa\u5b8c\u6bd5\u3002<\/p>\n<h3>\u914d\u7f6e\u4e0brsyslog\u76f8\u5173\u7684\u6570\u636e\u5e93<\/h3>\n<p>\u51e0\u4e4e\u6240\u6709\u7684Linux\u53d1\u884c\u7248\u90fd\u9ed8\u8ba4\u5b89\u88c5\u4e86rsyslog\uff0c\u6240\u4ee5\u8fd9\u4e2a\u4e00\u822c\u5df2\u7ecf\u81ea\u5e26\u4e86\uff0c\u4e0d\u7528\u989d\u5916\u5b89\u88c5\u3002\u6211\u4eec\u5b89\u88c5\u4e0brsyslog-mysql\u8ba9MariaDB\u652f\u6301rsyslog<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# yum -y install rsyslog-mysql<\/pre>\n<p>\u914d\u7f6e\u4e0b\u6570\u636e\u5e93\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer loganalyzer-4.1.5]# cd \/usr\/share\/doc\/rsyslog-7.4.7\/<\/pre>\n<p>\u5bfc\u5165\u6570\u636e\u5e93\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer rsyslog-7.4.7]# mysql -uroot -p &lt; mysql-createDB.sql<\/pre>\n<p>\u8fdb\u5165MariaDB\u63a7\u5236\u53f0\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer rsyslog-7.4.7]# mysql -uroot -p<\/pre>\n<p>\u6388\u6743\u4e0b\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">MariaDB [(none)]&gt; grant all privileges on Syslog.* to rsyslog@localhost identified by 'rsyslog';<\/pre>\n<p>\u8fd9\u91cc\u628a\u6743\u9650\u6388\u4e88\u6570\u636e\u5e93\u7684rsyslog\u7528\u6237\uff0c\u5bc6\u7801\u4e3arsyslog\uff0c\u5b9e\u9645\u6210\u4ea7\u73af\u5883\u4e2d\u5efa\u8bae\u7528\u590d\u6742\u70b9\u7684\u5bc6\u7801\u3002<\/p>\n<p>\u914d\u7f6e\u670d\u52a1\u7aef\u652f\u6301rsyslog-mysql\u6a21\u5757\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# vim \/etc\/rsyslog.conf<\/pre>\n<p>\u5728#### MODULES ####\u4e0b\u9762\u589e\u52a0\u4e0b\u9762\u4e24\u884c\uff1a<\/p>\n<pre class=\"lang:ini decode:true \">$ModLoad ommysql\r\n*.* :ommysql:localhost,Syslog,rsyslog,rsyslog<\/pre>\n<p>Syslog\u4e3a\u6570\u636e\u5e93\uff0crsyslog\u4e3a\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u5982\u679c\u4f60\u7684\u6570\u636e\u5e93\u4e0d\u662f\u8fd9\u4e2a\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u8bf7\u6309\u7167\u4f60\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u586b\u5199\u3002<\/p>\n<p>\u4e0a\u9762\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u53d6\u6d88\u4e00\u4e9b\u6ce8\u91ca\uff0c\u6765\u542f\u7528\u4e00\u4e9b\u6a21\u5757\uff1a<\/p>\n<pre class=\"lang:ini decode:true \">$ModLoad immark  # provides --MARK-- message capability\r\n$ModLoad imudp\r\n$UDPServerRun 514<\/pre>\n<p>\u91cd\u542frsyslog\u670d\u52a1\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# systemctl restart rsyslog.service<\/pre>\n<p>\u5f00\u653ersyslog\u9632\u706b\u5899\u7aef\u53e3\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# firewall-cmd --permanent --add-port=514\/udp\r\n[root@loganalyzer ~]# firewall-cmd --reload<\/pre>\n<h3>\u5b89\u88c5LogAnalyzer<\/h3>\n<p>\u4e0b\u8f7d\u4e0bLogAnalyzer\u8f6f\u4ef6\uff0c\u76ee\u524d\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u662f4.1.5\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# curl -L -O http:\/\/download.adiscon.com\/loganalyzer\/loganalyzer-4.1.5.tar.gz<\/pre>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer ~]# tar xf loganalyzer-4.1.5.tar.gz\r\n[root@loganalyzer ~]# cd loganalyzer-4.1.5\/<\/pre>\n<p>\u5728Apache\u76ee\u5f55\u4e0b\u5efa\u7acb\u4e00\u4e2aloganalyzer\u4e13\u7528\u7684\u6587\u4ef6\u5939\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer loganalyzer-4.1.5]# mkdir \/var\/www\/html\/loganalyzer<\/pre>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer loganalyzer-4.1.5]# cp -avx src\/* \/var\/www\/html\/loganalyzer\/<\/pre>\n<p>\u628a\u6587\u4ef6\u6743\u9650\u8bbe\u7f6e\u4e0b\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer loganalyzer-4.1.5]# cd \/var\/www\/html\/\r\n[root@loganalyzer html]# chown -R apache:apache loganalyzer\/<\/pre>\n<p>\u5efa\u7acb\u7a7a\u7684\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">[root@loganalyzer html]# cd loganalyzer\/\r\n[root@loganalyzer loganalyzer]# touch config.php\r\n[root@loganalyzer loganalyzer]# chmod 644 config.php \r\n[root@loganalyzer loganalyzer]# chown apache:apache config.php<\/pre>\n<p>\u8bbe\u7f6eselinux\u6807\u7b7e<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer loganalyzer]# chcon -t httpd_sys_rw_content_t config.php<\/pre>\n<p>\u63a5\u4e0b\u6765\u5728\u6d4f\u89c8\u5668\u4e2d\u5f00\u59cb\u914d\u7f6e\uff0c\u6253\u5f00http:\/\/192.168.42.15\/loganalyzer\/install.php<\/p>\n<p><a href=\"https:\/\/yyshell.com\/wp-content\/uploads\/2016\/11\/loganalyzer1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-402 size-full\" src=\"https:\/\/yyshell.com\/wp-content\/uploads\/2016\/11\/loganalyzer1.png\" alt=\"\" width=\"975\" height=\"393\" \/><\/a>\u6309next\u68c0\u6d4b\u73af\u5883\uff0c\u6211\u4eec\u521a\u624d\u5df2\u7ecf\u88ab\u4e3b\u8981\u914d\u7f6e\u6587\u4ef6\u8bbe\u7f6e\u4e3a\u53ef\u5199\u4e86\uff0c\u6ca1\u95ee\u9898\uff0c\u7ee7\u7eednext<\/p>\n<p><a href=\"https:\/\/yyshell.com\/wp-content\/uploads\/2016\/11\/loganalyzer2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-404 size-full\" src=\"https:\/\/yyshell.com\/wp-content\/uploads\/2016\/11\/loganalyzer2.png\" alt=\"loganalyzer2\" width=\"959\" height=\"815\" \/><\/a>\u4e00\u8defnext\u5230\u914d\u7f6e\u7528\u6237\u73af\u8282\uff1a<br \/>\n<a href=\"https:\/\/yyshell.com\/wp-content\/uploads\/2016\/11\/loganalyzer3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-405 size-full\" src=\"https:\/\/yyshell.com\/wp-content\/uploads\/2016\/11\/loganalyzer3.png\" alt=\"loganalyzer3\" width=\"973\" height=\"460\" \/><\/a>\u914d\u7f6e\u4e0bsyslog\u6e90\uff1a<br \/>\n<a href=\"https:\/\/yyshell.com\/wp-content\/uploads\/2016\/11\/loganalyzer4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-407 size-full\" src=\"https:\/\/yyshell.com\/wp-content\/uploads\/2016\/11\/loganalyzer4.png\" alt=\"loganalyzer4\" width=\"959\" height=\"715\" \/><\/a>\u6ce8\u610f\uff0c\u8868\u540d\u79f0\u5927\u5c0f\u654f\u611f\uff0c\u540d\u79f0\u662fSystemEvents!\u5982\u679c\u4f60\u7684\u65e5\u5fd7\u4fe1\u606f\u7279\u522b\u591a\uff0cEnable Row Counting\u4f1a\u62d6\u6162\u4f60\u67e5\u8be2\u7684\u901f\u5ea6\uff0c\u8fd9\u4e2a\u76f8\u4fe1\u63a5\u89e6\u8fc7\u6570\u636e\u5e93\u67e5\u8be2\u7684\u7528\u6237\u90fd\u80fd\u7406\u89e3\u3002<\/p>\n<p>\u63a5\u4e0b\u6765netxt\u76f4\u5230\u5b8c\u6210\u3002<\/p>\n<p>\u5b8c\u6210\u540e\u53ef\u4ee5\u53ef\u4ee5\u5220\u9664\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684install.php\u6587\u4ef6\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@loganalyzer loganalyzer]# rm -f install.php<\/pre>\n<h3>\u5ba2\u6237\u7aef\u914d\u7f6e<\/h3>\n<p>\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">[root@client ~]# vim \/etc\/rsyslog.conf<\/pre>\n<p>\u5728\u6587\u4ef6\u6700\u540e\u4e00\u884c\u52a0\u4e0a\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">*.* @192.168.42.15<\/pre>\n<p>\u91cd\u542frsyslog\u670d\u52a1\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">[root@client ~]# service rsyslog restart<\/pre>\n<p>\u8981\u8ba9\u5ba2\u6237\u7aef\u6240\u6709\u6267\u884c\u7684\u547d\u4ee4\u90fd\u5199\u5165\u65e5\u5fd7\u4e2d\uff0c\u53ef\u4ee5\u8fd9\u6837\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">[root@client ~]# vim \/etc\/bashrc<\/pre>\n<p>\u5728\u5c3e\u90e8\u52a0\u4e0a\u5982\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">export PROMPT_COMMAND='{ msg=$(history 1 | { read x y; echo $y; });logger \"[euid=$(whoami)]\":$(who am i):[`pwd`]\"$msg\"; }'<\/pre>\n<p>\u4f7f\u6539\u53d8\u751f\u6548\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">[root@client ~]# . \/etc\/bashrc<\/pre>\n<p>\u6b64\u65f6\u5ba2\u6237\u7aef\u914d\u7f6e\u5b8c\u6bd5\u3002<\/p>\n<h3>\u5173\u4e8e\u4e2d\u6587\u65e5\u5fd7\u4e71\u7801\uff1a<\/h3>\n<p>\u53ef\u4ee5\u7528\u7ba1\u7406\u5458\u7528\u6237\u767b\u9646\u540e\uff0c\u8fdb\u5165Admin Center\uff0c\u5728Default character encoding\u9009\u62e9utf-8\u7f16\u7801\u5373\u53ef\u3002<\/p>\n<div id=\"icibaCirclePointer\" style=\"position: absolute; top: 832px; left: 278px;\"><\/div>\n<div id=\"icibaCirclePointer\" style=\"position: absolute; top: 1831px; left: -44px;\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u65e5\u5e38\u5de5\u4f5c\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u642d\u5efa\u4e13\u95e8\u7684\u65e5\u5fd7\u670d\u52a1\u5668\u6765\u8bb0\u5f55\u670d\u52a1\u5668\u4e0a\u5404\u7c7b\u64cd\u4f5c\u53ca\u7cfb\u7edf\u4fe1\u606f\u3002\u4e3a\u4ec0<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8,12,7],"tags":[45,37,58,60,59,27,57],"class_list":["post-401","post","type-post","status-publish","format-standard","hentry","category-linux","category-web","category-12","category-7","tag-centos6","tag-centos7","tag-httpd","tag-loganalyzer","tag-mariadb","tag-php","tag-rsyslog"],"_links":{"self":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=401"}],"version-history":[{"count":6,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/401\/revisions"}],"predecessor-version":[{"id":465,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/401\/revisions\/465"}],"wp:attachment":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}