{"id":32,"date":"2023-08-01T15:17:11","date_gmt":"2023-08-01T07:17:11","guid":{"rendered":"https:\/\/www.weibone.ltd\/?p=32"},"modified":"2023-08-24T22:27:19","modified_gmt":"2023-08-24T14:27:19","slug":"elk-%e6%94%b6%e9%9b%86%e5%8d%8e%e4%b8%ba%e4%ba%91%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%97%a5%e5%bf%97","status":"publish","type":"post","link":"https:\/\/www.weibone.ltd\/?p=32","title":{"rendered":"ELK \u6536\u96c6\u534e\u4e3a\u4e91\u670d\u52a1\u5668\u65e5\u5fd7"},"content":{"rendered":"<p>\u534e\u4e3a\u4e91\u670d\u52a1\u5668\uff1a139.2.6.102<\/p>\n<p>ELK\u670d\u52a1\u5668\uff1a10.0.0.120<\/p>\n<p>KVM\u670d\u52a1\u5668\uff1a123.123.123.123<\/p>\n<p>\u6570\u636e\u6d41\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-33\" src=\"https:\/\/www.weibone.ltd\/wp-content\/uploads\/2023\/08\/\u6570\u636e\u6d41-300x218.png\" alt=\"\" width=\"300\" height=\"218\" srcset=\"https:\/\/www.weibone.ltd\/wp-content\/uploads\/2023\/08\/\u6570\u636e\u6d41-300x218.png 300w, https:\/\/www.weibone.ltd\/wp-content\/uploads\/2023\/08\/\u6570\u636e\u6d41-768x558.png 768w, https:\/\/www.weibone.ltd\/wp-content\/uploads\/2023\/08\/\u6570\u636e\u6d41.png 905w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u4e00\u3001\u914d\u7f6e\u534e\u4e3a\u4e91\u4e0a\u7684rsyslog\uff08Huawei Cloud EulerOS release 2.0\uff09<\/p>\n<pre><code class=\"language-shell\">[root@huawei ~]# vi \/etc\/rsyslog.conf\n#\u5728\u6587\u4ef6\u6700\u540e\u6dfb\u52a0\n# Send login log to ap server\n*.* @@123.123.123.123:514\n[root@huawei ~]# systemctl restart rsyslog<\/code><\/pre>\n<p>\u4e8c\u3001\u914d\u7f6eKVM\u670d\u52a1\u5668\uff08CentOS 7)<\/p>\n<p>1\u3001rsyslog<\/p>\n<pre><code class=\"language-shell\">[root@kvm ~]# vi \/etc\/rsyslog.conf\n#\u4f7f\u7528tcp\u7aef\u53e3\uff0c\u628a\u4ee5\u4e0b\u4e24\u884c\u7684\u6ce8\u91ca\u53bb\u6389\uff1a\nmodule(load=&quot;imtcp&quot;) # needs to be done just once\ninput(type=&quot;imtcp&quot; port=&quot;514&quot;)\n#\u5728#### RULES ####\u524d\u6dfb\u52a0\u6a21\u677f\uff1a\n$template RemoteHost,&quot;\/var\/log\/remote_system_%HOSTNAME%.log&quot;\n#\u5728# ### sample forwarding rule ###\u524d\u52a0\u4e0a\uff1a\n:fromhost-ip, isequal, &quot;139.2.6.102&quot; ?RemoteHost\n#\u5339\u914dip\u4e3a139.2.6.102\u7684\u65e5\u5fd7\u4fdd\u5b58\u5230\/var\/log\/remote_system_huawei.log\u3002\u6a21\u677f\u4e2d\u201c%HOSTNAME%\u201d\u81ea\u52a8\u66ff\u6362\u4e3a\u670d\u52a1\u5668\u540d\u3002\n<\/code><\/pre>\n<p>2\u3001\u5b89\u88c5filebeat<\/p>\n<pre><code class=\"language-shell\">[root@kvm ~]# rpm -ivh https:\/\/mirrors.tuna.tsinghua.edu.cn\/elasticstack\/8.x\/yum\/8.8.0\/filebeat-8.8.0-x86_64.rpm\n[root@kvm ~]# vi \/etc\/filebeat\/filebeat.yml\npaths:\n#- \/var\/log\/remote_system_huawei.log\n- \/var\/log\/*.log\n\nsetup.kibana:\n\n# Kibana Host\n# Scheme and port can be left out and will be set to the default (http and 5601)\n# In case you specify and additional path, the scheme is required: http:\/\/localhost:5601\/path\n# IPv6 addresses should always be defined as: https:\/\/[2001:db8::1]:5601\nhost: &quot;10.0.0.120:5601&quot;\n\n# ---------------------------- Elasticsearch Output ----------------------------\noutput.elasticsearch:\n# Array of hosts to connect to.\nhosts: [&quot;10.0.0.120:9200&quot;]\n\n# Protocol - either `http` (default) or `https`.\nprotocol: &quot;https&quot;\n\n# Authentication credentials - either API key or username\/password.\n#api_key: &quot;id:api_key&quot;\nusername: &quot;elastic&quot;\npassword: &quot;zwU1A=4h3hx3dDgtfyrK&quot;\nssl.certificate_authorities: [&quot;\/root\/http_ca.crt&quot;]\n[root@kvm ~]# systemctl start filebeat<\/code><\/pre>\n<p>3\u3001NAT 10.0.0.120:5601<\/p>\n<pre><code class=\"language-shell\">[root@kvm ~]# firewall-cmd --add-forward -port=port=5601:proto=tcp:toport=5601:toaddr=10.0.0.120 --permanent\n[root@kvm ~]# firewall-cmd --reload<\/code><\/pre>\n<p>\u4e09\u3001\u914d\u7f6eELK\u670d\u52a1\u5668\uff08Ubuntu 22.10)<\/p>\n<pre><code class=\"language-shell\">root@elk:~#\u00a0 apt -y update\n\nroot@elk:~# apt install -y wget openjdk-8-jdk\u00a0\n\nroot@elk:~# wget https:\/\/mirrors.tuna.tsinghua.edu.cn\/elasticstack\/8.x\/apt\/pool\/main\/e\/elasticsearch\/elasticsearch-8.8.2-amd64.deb\n\ndpkg -i elasticsearch-8.8.2-amd64.deb\n\nsystemctl daemon-reload\n\nsystemctl start elasticsearch\n\nwget https:\/\/mirrors.tuna.tsinghua.edu.cn\/elasticstack\/8.x\/apt\/pool\/main\/k\/kibana\/kibana-8.8.2-amd64.deb\n\ndpkg -i kibana-8.8.2-amd64.deb\n<\/code><\/pre>\n<h1>\u5b89\u88c5\u8fc7\u7a0b\u9700\u8981\u7528elasticsearch\u751f\u6210token\uff0c\u8bf7\u53c2\u8003\u5b98\u65b9\u6587\u6863\uff1a<\/h1>\n<p><a href=\"https:\/\/www.elastic.co\/guide\/en\/kibana\/8.8\/deb.html\">https:\/\/www.elastic.co\/guide\/en\/kibana\/8.8\/deb.html<\/a><\/p>\n<p>\u6700\u540e\u5206\u4eab\u4e00\u4e0bssh loging\u7684\u65e5\u5fd7\u5206\u6790<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-38\" src=\"https:\/\/www.weibone.ltd\/wp-content\/uploads\/2023\/08\/Image-839-300x95.png\" alt=\"\" width=\"300\" height=\"95\" srcset=\"https:\/\/www.weibone.ltd\/wp-content\/uploads\/2023\/08\/Image-839-300x95.png 300w, https:\/\/www.weibone.ltd\/wp-content\/uploads\/2023\/08\/Image-839-1024x325.png 1024w, https:\/\/www.weibone.ltd\/wp-content\/uploads\/2023\/08\/Image-839-768x244.png 768w, https:\/\/www.weibone.ltd\/wp-content\/uploads\/2023\/08\/Image-839-1536x488.png 1536w, https:\/\/www.weibone.ltd\/wp-content\/uploads\/2023\/08\/Image-839-2048x650.png 2048w, https:\/\/www.weibone.ltd\/wp-content\/uploads\/2023\/08\/Image-839-938x298.png 938w, https:\/\/www.weibone.ltd\/wp-content\/uploads\/2023\/08\/Image-839-1130x359.png 1130w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u534e\u4e3a\u4e91\u670d\u52a1\u5668\uff1a139.2.6.&hellip;<\/p>\n","protected":false},"author":1,"featured_media":155,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-32","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-elk","category-4"],"_links":{"self":[{"href":"https:\/\/www.weibone.ltd\/index.php?rest_route=\/wp\/v2\/posts\/32","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.weibone.ltd\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.weibone.ltd\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.weibone.ltd\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.weibone.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=32"}],"version-history":[{"count":7,"href":"https:\/\/www.weibone.ltd\/index.php?rest_route=\/wp\/v2\/posts\/32\/revisions"}],"predecessor-version":[{"id":117,"href":"https:\/\/www.weibone.ltd\/index.php?rest_route=\/wp\/v2\/posts\/32\/revisions\/117"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.weibone.ltd\/index.php?rest_route=\/wp\/v2\/media\/155"}],"wp:attachment":[{"href":"https:\/\/www.weibone.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weibone.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weibone.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}