{"id":43122,"date":"2024-10-04T17:47:22","date_gmt":"2024-10-04T09:47:22","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43122\/"},"modified":"2024-10-04T17:47:22","modified_gmt":"2024-10-04T09:47:22","slug":"centos-7-%e5%96%ae%e6%a9%9f%e9%83%a8%e7%bd%b2-elk","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43122\/","title":{"rendered":"CentOS 7 \u55ae\u6a5f\u90e8\u7f72 ELK"},"content":{"rendered":"<h1 id=\"centos-7-%e5%96%ae%e6%a9%9f%e9%83%a8%e7%bd%b2-elk-ZpfLELLfcS\">CentOS 7 \u55ae\u6a5f\u90e8\u7f72 ELK<\/h1>\n<p>ELK \u5806\u758a\u662f\u7531 Elasticsearch\u3001Logstash \u548c Kibana \u4e09\u500b\u958b\u6e90\u5de5\u5177\u7d44\u6210\u7684\u5f37\u5927\u65e5\u8a8c\u7ba1\u7406\u89e3\u6c7a\u65b9\u6848\u3002\u9019\u4e9b\u5de5\u5177\u80fd\u5920\u5354\u540c\u5de5\u4f5c\uff0c\u5e6b\u52a9\u7528\u6236\u6536\u96c6\u3001\u5206\u6790\u548c\u53ef\u8996\u5316\u65e5\u8a8c\u6578\u64da\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7 \u4e0a\u9032\u884c\u55ae\u6a5f\u90e8\u7f72 ELK \u5806\u758a\uff0c\u4e26\u63d0\u4f9b\u8a73\u7d30\u7684\u6b65\u9a5f\u548c\u793a\u4f8b\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-ZpfLELLfcS\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u78ba\u4fdd\u60a8\u7684 CentOS 7 \u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u66f4\u65b0\uff1a<\/p>\n<pre><code>sudo yum update -y<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5b89\u88dd Java\uff0c\u56e0\u70ba Elasticsearch \u548c Logstash \u90fd\u4f9d\u8cf4\u65bc Java\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd OpenJDK\uff1a<\/p>\n<pre><code>sudo yum install java-1.8.0-openjdk -y<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5 Java \u662f\u5426\u5b89\u88dd\u6210\u529f\uff1a<\/p>\n<pre><code>java -version<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-elasticsearch-ZpfLELLfcS\">\u5b89\u88dd Elasticsearch<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u6dfb\u52a0 Elasticsearch \u7684\u5b98\u65b9\u5b58\u5132\u5eab\u3002\u5275\u5efa\u4e00\u500b\u65b0\u7684 repo \u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/yum.repos.d\/elasticsearch.repo<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>[elasticsearch-7.x]\nname=Elasticsearch repository for 7.x packages\nbaseurl=https:\/\/artifacts.elastic.co\/packages\/7.x\/yum\ngpgcheck=1\ngpgkey=https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch\nenabled=1<\/code><\/pre>\n<p>\u4fdd\u5b58\u4e26\u9000\u51fa\u5f8c\uff0c\u60a8\u53ef\u4ee5\u5b89\u88dd Elasticsearch\uff1a<\/p>\n<pre><code>sudo yum install elasticsearch -y<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 Elasticsearch \u4e26\u8a2d\u7f6e\u70ba\u958b\u6a5f\u81ea\u555f\uff1a<\/p>\n<pre><code>sudo systemctl start elasticsearch\nsudo systemctl enable elasticsearch<\/code><\/pre>\n<p>\u60a8\u53ef\u4ee5\u901a\u904e\u8a2a\u554f <a href=\"http:\/\/localhost:9200\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/localhost:9200<\/a> \u4f86\u6aa2\u67e5 Elasticsearch \u662f\u5426\u904b\u884c\u6b63\u5e38\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-logstash-ZpfLELLfcS\">\u5b89\u88dd Logstash<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5b89\u88dd Logstash\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u5b89\u88dd\uff1a<\/p>\n<pre><code>sudo yum install logstash -y<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u5275\u5efa\u4e00\u500b\u7c21\u55ae\u7684\u914d\u7f6e\u6587\u4ef6\u4f86\u6e2c\u8a66 Logstash\u3002\u5275\u5efa\u4e00\u500b\u65b0\u7684\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/logstash\/conf.d\/logstash-simple.conf<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>input {\n  stdin { }\n}\n\noutput {\n  elasticsearch { \n    hosts =&gt; [\"localhost:9200\"] \n  }\n}<\/code><\/pre>\n<p>\u7136\u5f8c\u555f\u52d5 Logstash\uff1a<\/p>\n<pre><code>sudo systemctl start logstash\nsudo systemctl enable logstash<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-kibana-ZpfLELLfcS\">\u5b89\u88dd Kibana<\/h2>\n<p>\u6700\u5f8c\uff0c\u5b89\u88dd Kibana\u3002\u9996\u5148\uff0c\u6dfb\u52a0 Kibana \u7684\u5b98\u65b9\u5b58\u5132\u5eab\uff1a<\/p>\n<pre><code>sudo vi \/etc\/yum.repos.d\/kibana.repo<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>[kibana-7.x]\nname=Kibana repository for 7.x packages\nbaseurl=https:\/\/artifacts.elastic.co\/packages\/7.x\/yum\ngpgcheck=1\ngpgkey=https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch\nenabled=1<\/code><\/pre>\n<p>\u7136\u5f8c\u5b89\u88dd Kibana\uff1a<\/p>\n<pre><code>sudo yum install kibana -y<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 Kibana \u4e26\u8a2d\u7f6e\u70ba\u958b\u6a5f\u81ea\u555f\uff1a<\/p>\n<pre><code>sudo systemctl start kibana\nsudo systemctl enable kibana<\/code><\/pre>\n<p>\u60a8\u53ef\u4ee5\u901a\u904e\u8a2a\u554f <a href=\"http:\/\/localhost:5601\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/localhost:5601<\/a> \u4f86\u6aa2\u67e5 Kibana \u662f\u5426\u904b\u884c\u6b63\u5e38\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-ZpfLELLfcS\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u5df2\u7d93\u6210\u529f\u5728 CentOS 7 \u4e0a\u90e8\u7f72\u4e86 ELK \u5806\u758a\u3002\u9019\u500b\u5f37\u5927\u7684\u5de5\u5177\u7d44\u5408\u80fd\u5920\u5e6b\u52a9\u60a8\u6709\u6548\u5730\u7ba1\u7406\u548c\u5206\u6790\u65e5\u8a8c\u6578\u64da\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u904b\u884c\u74b0\u5883\uff0c\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u6216 <a href=\"https:\/\/server.hk\">\u4e91\u670d\u52a1\u5668<\/a> \u4f86\u63d0\u5347\u6027\u80fd\u548c\u7a69\u5b9a\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to deploy the ELK stack on CentOS 7 for efficient log management and analysis in a single-machine setup.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-43122","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=43122"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43122\/revisions"}],"predecessor-version":[{"id":43123,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43122\/revisions\/43123"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}