{"id":63676,"date":"2023-07-20T13:51:18","date_gmt":"2023-07-20T05:51:18","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=63676"},"modified":"2023-07-20T13:51:18","modified_gmt":"2023-07-20T05:51:18","slug":"elastic-stack-conf-install","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/elastic-stack-conf-install.html","title":{"rendered":"Centos7\u4e0a\u5b89\u88c5\u4e0e\u914d\u7f6eElastic Stack"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nElasticsearch\u662f\u57fa\u4e8e Lucene \u7531 Java \u5f00\u53d1\u7684\u5f00\u6e90\u641c\u7d22\u5f15\u64ce\uff0c\u662f\u7528\u4e8e\u7ba1\u7406\u4e8b\u4ef6\u548c\u65e5\u5fd7\u7684\u5f00\u6e90\u5de5\u5177\uff0cLogstash \u5c06\u6536\u96c6\u60a8\u7684\u65e5\u5fd7\u6570\u636e\uff0c\u5c06\u6570\u636e\u8f6c\u6362\u4e3a JSON \u6587\u6863\uff0c\u5e76\u5c06\u5176\u5b58\u50a8\u5728 Elasticsearch \u4e2d\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u5c06\u5411\u60a8\u5c55\u793a\u5982\u4f55\u5728 CentOS 7 \u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u548c\u914d\u7f6e Elastic Stack \u4ee5\u76d1\u89c6\u670d\u52a1\u5668\u65e5\u5fd7\u3002 \u7136\u540e\uff0c\u6211\u5c06\u5411\u60a8\u5c55\u793a\u5982\u4f55\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e3a CentOS 7 \u548c Ubuntu 16 \u7684\u5ba2\u6237\u7aef\u4e0a\u5b89\u88c5 \u201cElastic beats\u201d\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
Elastic Stack\u7b80\u4ecb<\/strong><\/div>\n
\u5de5\u5177\u540d\u79f0\u4ecb\u7ecd<\/strong><\/span><\/div>\n

Elasticsearch<\/span>\u662f\u57fa\u4e8e Lucene \u7531 Java \u5f00\u53d1\u7684\u5f00\u6e90\u641c\u7d22\u5f15\u64ce\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5206\u5e03\u5f0f\u3001\u591a\u79df\u6237\u7684\u5168\u6587\u641c\u7d22\u5f15\u64ce\uff08\u591a\u79df\u6237\u662f\u6307\u591a\u79df\u6237\u6280\u672f\uff0c\u662f\u4e00\u79cd\u8f6f\u4ef6\u67b6\u6784\u6280\u672f\uff0c\u7528\u6765\u63a2\u8ba8\u4e0e\u5b9e\u73b0\u5982\u4f55\u5728\u591a\u7528\u6237\u7684\u73af\u5883\u4e0b\u5171\u7528\u76f8\u540c\u7684\u7cfb\u7edf\u6216\u7a0b\u5e8f\u7ec4\u4ef6\uff0c\u5e76\u4e14\u4ecd\u53ef\u786e\u4fdd\u5404\u7528\u6237\u95f4\u6570\u636e\u7684\u9694\u79bb\u6027\u3002\uff09\uff0c\u5e76\u5e26\u6709 HTTP \u4eea\u8868\u76d8\u7684 Web \u754c\u9762\uff08Kibana\uff09\u3002\u6570\u636e\u4f1a\u88ab Elasticsearch \u67e5\u8be2\u3001\u68c0\u7d22\uff0c\u5e76\u4e14\u4f7f\u7528 JSON \u6587\u6863\u65b9\u6848\u5b58\u50a8\u3002Elasticsearch \u662f\u4e00\u4e2a\u53ef\u6269\u5c55\u7684\u641c\u7d22\u5f15\u64ce\uff0c\u53ef\u7528\u4e8e\u641c\u7d22\u6240\u6709\u7c7b\u578b\u7684\u6587\u672c\u6587\u6863\uff0c\u5305\u62ec\u65e5\u5fd7\u6587\u4ef6\u3002Elasticsearch \u662f Elastic Stack \u7684\u6838\u5fc3\uff0cElastic Stack \u4e5f\u88ab\u79f0\u4e3a ELK Stack\u3002<\/p>\n

Logstash<\/span>\u662f\u7528\u4e8e\u7ba1\u7406\u4e8b\u4ef6\u548c\u65e5\u5fd7\u7684\u5f00\u6e90\u5de5\u5177\u3002\u5b83\u4e3a\u6570\u636e\u6536\u96c6\u63d0\u4f9b\u5b9e\u65f6\u4f20\u9012\u9014\u5f84\u3002 Logstash \u5c06\u6536\u96c6\u60a8\u7684\u65e5\u5fd7\u6570\u636e\uff0c\u5c06\u6570\u636e\u8f6c\u6362\u4e3a JSON \u6587\u6863\uff0c\u5e76\u5c06\u5176\u5b58\u50a8\u5728 Elasticsearch \u4e2d\u3002<\/p>\n

Kibana<\/span>\u662f Elasticsearch \u7684\u5f00\u6e90\u6570\u636e\u53ef\u89c6\u5316\u5de5\u5177\u3002Kibana \u63d0\u4f9b\u4e86\u4e00\u4e2a\u6f02\u4eae\u7684\u4eea\u8868\u76d8 Web \u754c\u9762\u3002 \u4f60\u53ef\u4ee5\u7528\u5b83\u6765\u7ba1\u7406\u548c\u53ef\u89c6\u5316\u6765\u81ea Elasticsearch \u7684\u6570\u636e\u3002 \u5b83\u4e0d\u4ec5\u7f8e\u4e3d\uff0c\u800c\u4e14\u5f3a\u5927\u3002<\/p>\n

\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u5c06\u5411\u60a8\u5c55\u793a\u5982\u4f55\u5728 CentOS 7 \u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u548c\u914d\u7f6e Elastic Stack \u4ee5\u76d1\u89c6\u670d\u52a1\u5668\u65e5\u5fd7\u3002 \u7136\u540e\uff0c\u6211\u5c06\u5411\u60a8\u5c55\u793a\u5982\u4f55\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e3a CentOS 7 \u548c Ubuntu 16 \u7684\u5ba2\u6237\u7aef\u4e0a\u5b89\u88c5 \u201cElastic beats\u201d\u3002<\/p>\n

Elastic Stack\u6240\u9700\u73af\u5883\u6761\u4ef6<\/strong><\/span><\/div>\n
64 \u4f4d\u7684 CentOS 7\uff0c4 GB \u5185\u5b58 - elk \u4e3b\u63a7\u673a\r\n64 \u4f4d\u7684 CentOS 7 \uff0c1 GB \u5185\u5b58 - \u5ba2\u6237\u7aef 1\r\n64 \u4f4d\u7684 Ubuntu 16 \uff0c1 GB \u5185\u5b58 - \u5ba2\u6237\u7aef 2\r\n<\/pre>\n
\u6b65\u9aa4 1 - \u64cd\u4f5c\u7cfb\u7edf\u521d\u59cb\u5316<\/strong><\/div>\n
\u7981\u7528 CentOS 7 \u670d\u52a1\u5668\u4e0a\u7684 SELinux<\/strong><\/span><\/div>\n

\u6211\u4eec\u5c06\u7981\u7528 CentOS 7 \u670d\u52a1\u5668\u4e0a\u7684 SELinux\u3002 \u7f16\u8f91 SELinux \u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n

vim \/etc\/sysconfig\/selinux\r\n\r\n\u5c06 SELINUX \u7684\u503c\u4ece enforcing\u6539\u6210disabled\r\nSELINUX=disabled\r\n\u7136\u540e\u91cd\u542f\u670d\u52a1\u5668\uff1a\r\nreboot\r\n\u518d\u6b21\u767b\u5f55\u670d\u52a1\u5668\u5e76\u68c0\u67e5 SELinux \u72b6\u6001\u3002\r\ngetenforce\r\ndisabled\r\n<\/pre>\n
\u6b65\u9aa4 2 - \u5b89\u88c5 Java\u73af\u5883<\/strong><\/div>\n

\u90e8\u7f72 Elastic stack \u4f9d\u8d56\u4e8eJava\uff0cElasticsearch \u9700\u8981 Java 8 \u7248\u672c\uff0c\u63a8\u8350\u4f7f\u7528 Oracle JDK 1.8 \u3002\u4ece\u5b98\u65b9\u7684 Oracle rpm \u5305\u5b89\u88c5 Java 8\u3002<\/p>\n

wget http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/8u77-b02\/jdk-8u77-linux-x64.rpm\r\n                                     \\\\\u4e0b\u8f7djava8\u7684\u7248\u672c\r\nrpm -ivh jdk-8u77-linux-x64.rpm       \\\\rpm\u5b89\u88c5jdk\u73af\u5883\r\njava -version                          \\\\\u67e5\u770bjava\u7684\u7248\u672c  \u68c0\u67e5\u80fd\u5426\u5de5\u4f5c\r\n<\/pre>\n
\u6b65\u9aa4 3 - \u5b89\u88c5\u548c\u914d\u7f6e Elasticsearch<\/strong><\/div>\n

\u5728\u6b64\u6b65\u9aa4\u4e2d\uff0c\u6211\u4eec\u5c06\u5b89\u88c5\u548c\u914d\u7f6e Elasticsearch\u3002 \u4ece elastic.co \u7f51\u7ad9\u63d0\u4f9b\u7684 rpm \u5305\u5b89\u88c5 Elasticsearch\uff0c\u5e76\u5c06\u5176\u914d\u7f6e\u8fd0\u884c\u5728 localhost \u4e0a\uff08\u4ee5\u786e\u4fdd\u8be5\u7a0b\u5e8f\u5b89\u5168\uff0c\u800c\u4e14\u4e0d\u80fd\u4ece\u5916\u90e8\u8bbf\u95ee\uff09\u3002<\/p>\n

\u5c06 elastic.co \u7684\u5bc6\u94a5\u6dfb\u52a0\u5230\u670d\u52a1\u5668<\/strong><\/span><\/div>\n

elastic.co\u7f51\u7ad9\u662f\u4e00\u4e2ahttps\u7684\u7f51\u7ad9\uff08\u79c1\u6709\u8bc1\u4e66\uff09\uff0c\u6211\u4eec\u9700\u8981\u6dfb\u52a0\u8bc1\u4e66\u79d8\u94a5\u624d\u80fd\u5b89\u5168\u7684\u987a\u5229\u4e0b\u8f7d\u3002<\/p>\n

rpm --import https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch\r\n<\/pre>\n
\u4e0b\u8f7d\u5b89\u88c5 Elasticsearch 5.1<\/strong><\/span><\/div>\n
wget https:\/\/artifacts.elastic.co\/downloads\/elasticsearch\/elasticsearch-5.1.1.rpm\r\nrpm -ivh elasticsearch-5.1.1.rpm\r\n<\/pre>\n
\u5b89\u88c5\u5b8c\u6210\u540e\u6211\u4eec\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6<\/strong><\/span><\/div>\n

\u914d\u7f6e\u6587\u4ef6\u540d\u79f0\uff1aelasticsaerch.yml<\/p>\n

cd \/etc\/elasticsearch\/\r\nvim elasticsearch.yml\r\n\r\nbootstrap.memory_lock: true  \r\n                 \\\\\u53bb\u6389\u7b2c 40 \u884c\u7684\u6ce8\u91ca\uff0c\u542f\u7528 Elasticsearch \u7684\u5185\u5b58\u9501\u3002\u8fd9\u5c06\u7981\u7528 Elasticsearch \u7684\u5185\u5b58\u4ea4\u6362\u3002\r\n\r\nnetwork.host: localhost\r\nhttp.port: 9200\r\n                  \\\\\u5728 Network \u5757\u4e2d\uff0c\u53d6\u6d88\u6ce8\u91ca network.host \u548c http.port \u884c\u3002\r\n<\/pre>\n

\u7f16\u8f91 elasticsearch.service \u6587\u4ef6\u7684\u5185\u5b58\u9501\u914d\u7f6e\u3002<\/p>\n

vim \/usr\/lib\/systemd\/system\/elasticsearch.service\r\nMAX_LOCKED_MEMORY=unlimited\r\n                  \\\\\u53bb\u6389\u7b2c 60 \u884c\u7684\u6ce8\u91ca\uff0c\u786e\u4fdd\u8be5\u503c\u4e3a unlimited\u3002\r\n<\/pre>\n
\u8bbe\u7f6e\u670d\u52a1\u542f\u52a8<\/strong><\/span><\/div>\n

Elasticsearch\u76d1\u542c\u7aef\u53e3\u53f79200\uff0c\u542f\u7528 CentOS \u670d\u52a1\u5668\u4e0a\u542f\u7528mlockall \u6765\u7981\u7528\u5185\u5b58\u4ea4\u6362\uff0c\u8bbe\u7f6eElasticsearch\u5f00\u673a\u81ea\u542f\u52a8\uff0c\u7136\u540e\u542f\u52a8\u670d\u52a1\u3002<\/p>\n

sudo systemctl daemon-reload\r\nsudo systemctl enable elasticsearch\r\nsudo systemctl start elasticsearch\r\n<\/pre>\n

\u68c0\u67e5\u5bf9\u5916\u76d1\u542c\u7aef\u53e3\uff1a<\/p>\n

netstat -plntu\r\n<\/pre>\n

\"\"
\n\u5185\u5b58\u9501\u542f\u7528 mlockall\uff0c\u68c0\u67e5 Elasticsearch \u662f\u5426\u6b63\u5728\u8fd0\u884c\u3002<\/p>\n

curl -XGET 'localhost:9200\/_nodes?filter_path=**.mlockall&pretty'\r\ncurl -XGET 'localhost:9200\/?pretty'\r\n<\/pre>\n

\"\"<\/p>\n

\u6b65\u9aa4 4 - \u5b89\u88c5\u548c\u914d\u7f6e Kibana \u548c Nginx<\/strong><\/div>\n

\u5148\u5b89\u88c5Kibana\uff0c\u7136\u540e\u5b89\u88c5nginx\uff0c\u6700\u540e\u8bbe\u7f6enginx\u53cd\u5411\u4ee3\u7406kibana<\/p>\n

\u5b89\u88c5\u5e76\u914d\u7f6eKibana<\/strong><\/span><\/div>\n
wget https:\/\/artifacts.elastic.co\/downloads\/kibana\/kibana-5.1.1-x86_64.rpm\r\nrpm -ivh kibana-5.1.1-x86_64.rpm<\/pre>\n

\u7f16\u8f91 Kibana \u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n

vim \/etc\/kibana\/kibana.yml\r\n                 \u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u627e\u7684\u4e00\u4e0b\u4e09\u884c\uff0c\u4fee\u6539\u914d\u7f6e\r\n\r\nserver.port: 5601\r\nserver.host: \"localhost\"\r\nelasticsearch.url: \"http:\/\/localhost:9200\"\r\n<\/pre>\n

\u5c06 Kibana \u8bbe\u4e3a\u5f00\u673a\u542f\u52a8<\/p>\n

sudo systemctl enable kibana\r\nsudo systemctl start kibana\r\n<\/pre>\n

\u68c0\u67e5Kibana \u5bf9\u5916\u76d1\u542c\u7aef\u53e3 5601 \u786e\u4fdd\u5176\u6b63\u5e38\u542f\u52a8\u3002<\/p>\n

netstat -plntu\r\n<\/pre>\n

\"\"<\/p>\n

\u5b89\u88c5\u5e76\u914d\u7f6enginx\u670d\u52a1\u5668<\/strong><\/span><\/div>\n
yum -y install epel-release\r\n             nginx \u670d\u52a1\u7684yum\u5305\u5728epel\u5305\u4e2d\u53ef\u4ee5\u627e\u7684  \u76f4\u63a5yum\u5b89\u88c5\r\nyum -y install nginx httpd-tools\r\n<\/pre>\n

httpd-tools \u8f6f\u4ef6\u5305\u5305\u542b Web \u670d\u52a1\u5668\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u4e3a Kibana \u6dfb\u52a0 htpasswd \u57fa\u7840\u8ba4\u8bc1\u3002<\/p>\n

\u7f16\u8f91 Nginx \u914d\u7f6e\u6587\u4ef6\u5e76\u5220\u9664 server {}\u6a21\u5757\uff0c\u8fd9\u6837\u6211\u4eec\u6dfb\u52a0\u65b0\u7684\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u3002<\/p>\n

cd \/etc\/nginx\/\r\nvim nginx.conf\r\n                         \\\\\u5220\u9664 server { } \u5757\u3002\r\n<\/pre>\n

\"\"
\n\u521b\u5efakibana.conf\u7684\u865a\u62df\u4e3b\u673a\uff1a<\/p>\n

vim \/etc\/nginx\/conf.d\/kibana.conf\r\nserver {\r\n    listen 80;\r\n    server_name elk-stack.co;\r\n    auth_basic \"Restricted Access\";\r\n    auth_basic_user_file \/etc\/nginx\/.kibana-user;\r\n    location \/ {\r\n        proxy_pass http:\/\/localhost:5601;\r\n        proxy_http_version 1.1;\r\n        proxy_set_header Upgrade $http_upgrade;\r\n        proxy_set_header Connection 'upgrade';\r\n        proxy_set_header Host $host;\r\n        proxy_cache_bypass $http_upgrade;\r\n    }\r\n}\r\n<\/pre>\n

\u4f7f\u7528 htpasswd \u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u57fa\u672c\u8ba4\u8bc1\u6587\u4ef6\u3002<\/p>\n

sudo htpasswd -c \/etc\/nginx\/.kibana-user admin\r\n\u201c\u8f93\u5165\u4f60\u7684\u5bc6\u7801\u201d\r\n<\/pre>\n

\u542f\u52a8 Nginx\u3002<\/p>\n

nginx -t\r\nsystemctl enable nginx\r\nsystemctl start nginx\r\n<\/pre>\n

\"\"<\/p>\n

\u6b65\u9aa4 5 - \u5b89\u88c5\u548c\u914d\u7f6e Logstash<\/strong><\/div>\n

\u5728\u6b64\u6b65\u9aa4\u4e2d\uff0c\u6211\u4eec\u5c06\u5b89\u88c5 Logstash\uff0c\u5e76\u5c06\u5176\u914d\u7f6e\u4e3a\uff1a\u4ece\u914d\u7f6e\u4e86 filebeat \u7684 logstash \u5ba2\u6237\u7aef\u91cc\u96c6\u4e2d\u5316\u670d\u52a1\u5668\u7684\u65e5\u5fd7\uff0c\u7136\u540e\u8fc7\u6ee4\u548c\u8f6c\u6362 Syslog \u6570\u636e\uff0c\u5e76\u5c06\u5176\u79fb\u52a8\u5230\u5b58\u50a8\u4e2d\u5fc3\uff08Elasticsearch\uff09\u4e2d\u3002<\/p>\n

\u4e0b\u8f7d Logstash \u5e76\u4f7f\u7528 rpm \u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n

wget https:\/\/artifacts.elastic.co\/downloads\/logstash\/logstash-5.1.1.rpm\r\nrpm -ivh logstash-5.1.1.rpm\r\n<\/pre>\n

\u751f\u6210\u65b0\u7684 SSL \u8bc1\u4e66\u6587\u4ef6\uff0c\u4ee5\u4fbf\u5ba2\u6237\u7aef\u53ef\u4ee5\u8bc6\u522b elastic \u670d\u52a1\u7aef\u3002<\/p>\n

cd \/etc\/pki\/tls \r\n                 \\\\ \u8fdb\u5165 tls \u76ee\u5f55\u5e76\u7f16\u8f91 openssl.cnf \u6587\u4ef6\u3002\r\nvim openssl.cnf\r\n\r\n\u5728 [v3_ca] \u90e8\u5206\u6dfb\u52a0\u670d\u52a1\u5668\u6807\u8bc6\u3002\r\n\r\n[ v3_ca ]\r\n# Server IP Address\r\nsubjectAltName = IP: 10.0.15.10\r\n<\/pre>\n

\u4f7f\u7528 openssl \u547d\u4ee4\u751f\u6210\u8bc1\u4e66\u6587\u4ef6\u3002<\/p>\n

openssl req -config \/etc\/pki\/tls\/openssl.cnf -x509 -days 3650 -batch -nodes -newkey rsa:2048 -keyout \/etc\/pki\/tls\/private\/logstash-forwarder.key -out \/etc\/pki\/tls\/certs\/logstash-forwarder.crt\r\n<\/pre>\n

\u8bc1\u4e66\u6587\u4ef6\u53ef\u4ee5\u5728 \/etc\/pki\/tls\/certs\/ \u548c \/etc\/pki\/tls\/private\/ \u76ee\u5f55\u4e2d\u627e\u5230\u3002<\/p>\n

\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f1a\u4e3a Logstash \u521b\u5efa\u65b0\u7684\u914d\u7f6e\u6587\u4ef6\u3002\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 filebeat-input.conf \u6587\u4ef6\u6765\u4e3a filebeat \u914d\u7f6e\u65e5\u5fd7\u6e90\uff0c\u7136\u540e\u521b\u5efa\u4e00\u4e2a syslog-filter.conf \u914d\u7f6e\u6587\u4ef6\u6765\u5904\u7406 syslog\uff0c\u518d\u521b\u5efa\u4e00\u4e2a output-elasticsearch.conf \u6587\u4ef6\u6765\u5b9a\u4e49\u8f93\u51fa\u65e5\u5fd7\u6570\u636e\u5230 Elasticsearch\u3002<\/p>\n

\u8f6c\u5230 logstash \u914d\u7f6e\u76ee\u5f55\uff0c\u5e76\u5728 conf.d \u5b50\u76ee\u5f55\u4e2d\u521b\u5efa\u65b0\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n

\r\ncd \/etc\/logstash\/\r\nvim conf.d\/filebeat-input.conf\r\n              \u8f93\u5165\u914d\u7f6e\uff0c\u7c98\u8d34\u4ee5\u4e0b\u914d\u7f6e\uff1a\r\n\r\ninput {\r\nbeats {\r\nport => 5443\r\nssl => true\r\nssl_certificate => \"\/etc\/pki\/tls\/certs\/logstash-forwarder.crt\"\r\nssl_key => \"\/etc\/pki\/tls\/private\/logstash-forwarder.key\"\r\n}\r\n}\r\n<\/pre>\n

\u521b\u5efa syslog-filter.conf \u6587\u4ef6<\/p>\n

vim conf.d\/syslog-filter.conf\r\n\u7c98\u8d34\u4ee5\u4e0b\u914d\u7f6e\uff1a\r\n\r\nfilter {\r\nif [type] == \"syslog\" {\r\ngrok {\r\nmatch => { \"message\" => \"%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\\[%{POSINT:syslog_pid}\\])?: %{GREEDYDATA:syslog_message}\" }\r\nadd_field => [ \"received_at\", \"%{@timestamp}\" ]\r\nadd_field => [ \"received_from\", \"%{host}\" ]\r\n}\r\ndate {\r\nmatch => [ \"syslog_timestamp\", \"MMM d HH:mm:ss\", \"MMM dd HH:mm:ss\" ]\r\n}\r\n}\r\n}\r\n\u6211\u4eec\u4f7f\u7528\u540d\u4e3a grok \u7684\u8fc7\u6ee4\u5668\u63d2\u4ef6\u6765\u89e3\u6790 syslog \u6587\u4ef6\u3002\r\n<\/pre>\n

\u521b\u5efa\u8f93\u51fa\u914d\u7f6e\u6587\u4ef6 output-elasticsearch.conf\u3002<\/p>\n

vim conf.d\/output-elasticsearch.conf\r\n\r\n\r\noutput {\r\nelasticsearch { hosts => [\"localhost:9200\"]\r\nhosts => \"localhost:9200\"\r\nmanage_template => false\r\nindex => \"%{[@metadata][beat]}-%{+YYYY.MM.dd}\"\r\ndocument_type => \"%{[@metadata][type]}\"\r\n}\r\n}\r\n<\/pre>\n

\u542f\u52a8logstash\u670d\u52a1<\/p>\n

sudo systemctl enable logstash\r\nsudo systemctl start logstash\r\n<\/pre>\n

\"\"<\/p>\n

\u6b65\u9aa4 6 - \u5728 CentOS \u5ba2\u6237\u7aef\u4e0a\u5b89\u88c5\u5e76\u914d\u7f6e Filebeat<\/strong><\/div>\n

Beat \u4f5c\u4e3a\u6570\u636e\u53d1\u9001\u4eba\u7684\u89d2\u8272\uff0c\u662f\u4e00\u79cd\u53ef\u4ee5\u5b89\u88c5\u5728\u5ba2\u6237\u7aef\u8282\u70b9\u4e0a\u7684\u8f7b\u91cf\u7ea7\u4ee3\u7406\uff0c\u5c06\u5927\u91cf\u6570\u636e\u4ece\u5ba2\u6237\u673a\u53d1\u9001\u5230 Logstash \u6216 Elasticsearch \u670d\u52a1\u5668\u3002\u6709 4 \u79cd beat\uff0cFilebeat \u7528\u4e8e\u53d1\u9001\u201c\u65e5\u5fd7\u6587\u4ef6\u201d\uff0cMetricbeat \u7528\u4e8e\u53d1\u9001\u201c\u6307\u6807\u201d\uff0cPacketbeat \u7528\u4e8e\u53d1\u9001\u201c\u7f51\u7edc\u6570\u636e\u201d\uff0cWinlogbeat \u7528\u4e8e\u53d1\u9001 Windows \u5ba2\u6237\u7aef\u7684\u201c\u4e8b\u4ef6\u65e5\u5fd7\u201d\u3002<\/p>\n

\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u5c06\u5411\u60a8\u5c55\u793a\u5982\u4f55\u5b89\u88c5\u548c\u914d\u7f6e Filebeat\uff0c\u901a\u8fc7 SSL \u8fde\u63a5\u5c06\u6570\u636e\u65e5\u5fd7\u6587\u4ef6\u4f20\u8f93\u5230 Logstash \u670d\u52a1\u5668\u3002<\/p>\n

\u767b\u5f55\u5230\u5ba2\u6237\u7aef1\u7684\u670d\u52a1\u5668\u4e0a\u3002 \u7136\u540e\u5c06\u8bc1\u4e66\u6587\u4ef6\u4ece elastic \u670d\u52a1\u5668\u590d\u5236\u5230\u5ba2\u6237\u7aef1\u7684\u670d\u52a1\u5668\u4e0a\u3002<\/p>\n

ssh root@client1IP\r\nscp root@elk-serverIP:~\/logstash-forwarder.crt .\r\n.....\r\n\r\nsudo mkdir -p \/etc\/pki\/tls\/certs\/\r\nmv ~\/logstash-forwarder.crt \/etc\/pki\/tls\/certs\/\r\n<\/pre>\n

\u63a5\u4e0b\u6765\uff0c\u5728\u5ba2\u6237\u7aef 1 \u670d\u52a1\u5668\u4e0a\u5bfc\u5165 elastic \u5bc6\u94a5\u3002<\/p>\n

rpm --import https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch\r\n\u4e0b\u8f7d Filebeat \u5e76\u4e14\u7528 rpm \u547d\u4ee4\u5b89\u88c5\u3002\r\n\r\nwget https:\/\/artifacts.elastic.co\/downloads\/beats\/filebeat\/filebeat-5.1.1-x86_64.rpm\r\nrpm -ivh filebeat-5.1.1-x86_64.rpm\r\n<\/pre>\n

Filebeat \u5df2\u7ecf\u5b89\u88c5\u597d\u4e86\uff0c\u8bf7\u8f6c\u5230\u914d\u7f6e\u76ee\u5f55\u5e76\u7f16\u8f91 filebeat.yml \u6587\u4ef6\u3002<\/p>\n

cd \/etc\/filebeat\/\r\nvim filebeat.yml\r\n      \\\\ \u5728\u7b2c 21 \u884c\u7684\u8def\u5f84\u90e8\u5206\uff0c\u6dfb\u52a0\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\u3002 \u6211\u4eec\u5c06\u521b\u5efa\u4e24\u4e2a\u6587\u4ef6\uff0c\u8bb0\u5f55 ssh \u6d3b\u52a8\u7684 \/var\/log\/secure \u6587\u4ef6 \uff0c\u4ee5\u53ca\u670d\u52a1\u5668\u65e5\u5fd7 \/var\/log\/messages :\r\npaths:\r\n- \/var\/log\/secure\r\n- \/var\/log\/messages\r\n                                \\\\\u5728\u7b2c 26 \u884c\u6dfb\u52a0\u4e00\u4e2a\u65b0\u914d\u7f6e\u6765\u5b9a\u4e49 syslog \u7c7b\u578b\u7684\u6587\u4ef6:\r\ndocument-type: syslog\r\n\r\n\r\n                                     \\\\\u5728 83 \u884c\u548c 85 \u884c\u6dfb\u52a0\u6ce8\u91ca\u6765\u7981\u7528 Elasticsearch \u8f93\u51fa,\u66f4\u6539\u4e3a Logshtash:\r\n-------------------------------------------------------------------------------------\r\n#-------------------------- Elasticsearch output ------------------------------\r\n#output.elasticsearch:\r\n# Array of hosts to connect to.\r\n# hosts: [\"localhost:9200\"]\r\n--------------------------------------------------------------------------------------\r\n\r\n------------------\u73b0\u5728\u6dfb\u52a0\u65b0\u7684 logstash \u8f93\u51fa\u914d\u7f6e--------------------------------------\r\noutput.logstash:\r\n# The Logstash hosts\r\nhosts: [\"10.0.15.10:5443\"]\r\nbulk_max_size: 1024\r\nssl.certificate_authorities: [\"\/etc\/pki\/tls\/certs\/logstash-forwarder.crt\"]\r\ntemplate.name: \"filebeat\"\r\ntemplate.path: \"filebeat.template.json\"\r\ntemplate.overwrite: false\r\n--------------------------------------------------------------------------------------\r\n<\/pre>\n

PS:Filebeat \u9ed8\u8ba4\u4f7f\u7528 Elasticsearch \u4f5c\u4e3a\u8f93\u51fa\u76ee\u6807\u3002 \u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u5176\u66f4\u6539\u4e3a Logshtash\u3002<\/p><\/blockquote>\n

\u5c06 Filebeat \u8bbe\u5b9a\u4e3a\u5f00\u673a\u542f\u52a8\u5e76\u542f\u52a8\u3002<\/p>\n

sudo systemctl enable filebeat\r\nsudo systemctl start filebeat\r\n<\/pre>\n
\u6b65\u9aa4 7 - \u5728 Ubuntu \u5ba2\u6237\u7aef\u4e0a\u5b89\u88c5\u5e76\u914d\u7f6e Filebeat<\/strong><\/div>\n

\u4ece\u670d\u52a1\u7aef\u62f7\u8d1d\u8bc1\u4e66\u6587\u4ef6<\/p>\n

ssh root@ubuntu-clientIP\r\nscp root@elk-serverIP:~\/logstash-forwarder.crt .\r\n.......\r\nsudo mkdir -p \/etc\/pki\/tls\/certs\/\r\nmv ~\/logstash-forwarder.crt \/etc\/pki\/tls\/certs\/\r\n<\/pre>\n

\u5728\u670d\u52a1\u5668\u4e0a\u5bfc\u5165 elastic \u5bc6\u94a5\u3002<\/p>\n

\r\nwget -qO - https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch | sudo apt-key add -\r\n <\/pre>\n

\u4e0b\u8f7d Filebeat .deb \u5305\u5e76\u4e14\u4f7f\u7528 dpkg \u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n

\r\nwget https:\/\/artifacts.elastic.co\/downloads\/beats\/filebeat\/filebeat-5.1.1-amd64.deb\r\ndpkg -i filebeat-5.1.1-amd64.deb\r\n<\/pre>\n

\u8f6c\u5230\u914d\u7f6e\u76ee\u5f55\u5e76\u7f16\u8f91 filebeat.yml \u6587\u4ef6\u3002<\/p>\n

cd \/etc\/filebeat\/\r\nvim filebeat.yml\r\n      \\\\ \u5728\u7b2c 21 \u884c\u7684\u8def\u5f84\u90e8\u5206\uff0c\u6dfb\u52a0\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\u3002 \u6211\u4eec\u5c06\u521b\u5efa\u4e24\u4e2a\u6587\u4ef6\uff0c\u8bb0\u5f55 ssh \u6d3b\u52a8\u7684 \/var\/log\/secure \u6587\u4ef6 \uff0c\u4ee5\u53ca\u670d\u52a1\u5668\u65e5\u5fd7 \/var\/log\/messages :\r\npaths:\r\n- \/var\/log\/secure\r\n- \/var\/log\/messages\r\n                                \\\\\u5728\u7b2c 26 \u884c\u6dfb\u52a0\u4e00\u4e2a\u65b0\u914d\u7f6e\u6765\u5b9a\u4e49 syslog \u7c7b\u578b\u7684\u6587\u4ef6:\r\ndocument-type: syslog\r\n\r\n\r\n                                     \\\\\u5728 83 \u884c\u548c 85 \u884c\u6dfb\u52a0\u6ce8\u91ca\u6765\u7981\u7528 Elasticsearch \u8f93\u51fa,\u66f4\u6539\u4e3a Logshtash:\r\n-------------------------------------------------------------------------------------\r\n#-------------------------- Elasticsearch output ------------------------------\r\n#output.elasticsearch:\r\n# Array of hosts to connect to.\r\n# hosts: [\"localhost:9200\"]\r\n--------------------------------------------------------------------------------------\r\n\r\n------------------\u73b0\u5728\u6dfb\u52a0\u65b0\u7684 logstash \u8f93\u51fa\u914d\u7f6e--------------------------------------\r\noutput.logstash:\r\n# The Logstash hosts\r\nhosts: [\"10.0.15.10:5443\"]\r\nbulk_max_size: 1024\r\nssl.certificate_authorities: [\"\/etc\/pki\/tls\/certs\/logstash-forwarder.crt\"]\r\ntemplate.name: \"filebeat\"\r\ntemplate.path: \"filebeat.template.json\"\r\ntemplate.overwrite: false\r\n--------------------------------------------------------------------------------------\r\n<\/pre>\n

PS:Filebeat \u9ed8\u8ba4\u4f7f\u7528 Elasticsearch \u4f5c\u4e3a\u8f93\u51fa\u76ee\u6807\u3002 \u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u5176\u66f4\u6539\u4e3a Logshtash\u3002<\/p><\/blockquote>\n

\u5c06 Filebeat \u8bbe\u5b9a\u4e3a\u5f00\u673a\u542f\u52a8\u5e76\u542f\u52a8\u3002<\/p>\n

sudo systemctl enable filebeat\r\nsudo systemctl start filebeat\r\n<\/pre>\n

\u68c0\u67e5\u670d\u52a1\u72b6\u6001\uff1a<\/p>\n

systemctl status filebeat\r\n\r\n\"\"\r\n<\/pre>\n
\u6b65\u9aa4 8 - \u6d4b\u8bd5<\/strong><\/div>\n

\u6253\u5f00\u60a8\u7684\u7f51\u7edc\u6d4f\u89c8\u5668\uff0c\u5e76\u8bbf\u95ee\u60a8\u5728 Nginx \u4e2d\u914d\u7f6e\u7684 elastic stack \u57df\u540d\uff0c\u6211\u7684\u662f\u201celk-stack.co\u201d\u3002 \u4f7f\u7528\u7ba1\u7406\u5458\u5bc6\u7801\u767b\u5f55\uff0c\u7136\u540e\u6309 Enter \u952e\u767b\u5f55 Kibana \u4eea\u8868\u76d8\u3002<\/p>\n

\"\"<\/p>\n

\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u9ed8\u8ba4\u7d22\u5f15 filebeat-*\uff0c\u7136\u540e\u70b9\u51fb\u201c\u521b\u5efa\u201d\u6309\u94ae\u3002
\n\"\"<\/p>\n

\u9ed8\u8ba4\u7d22\u5f15\u5df2\u521b\u5efa\u3002 \u5982\u679c elastic stack \u4e0a\u6709\u591a\u4e2a beat\uff0c\u60a8\u53ef\u4ee5\u5728\u201c\u661f\u5f62\u201d\u6309\u94ae\u4e0a\u70b9\u51fb\u4e00\u4e0b\u5373\u53ef\u914d\u7f6e\u9ed8\u8ba4 beat\u3002<\/p>\n

\"\"<\/p>\n

\u8f6c\u5230 \u201c\u53d1\u73b0\u201d \u83dc\u5355\uff0c\u60a8\u5c31\u53ef\u4ee5\u770b\u5230 elk-client1 \u548c elk-client2 \u670d\u52a1\u5668\u4e0a\u7684\u6240\u6709\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n

\"\"<\/p>\n

\u6765\u81ea elk-client1 \u670d\u52a1\u5668\u65e5\u5fd7\u4e2d\u7684\u65e0\u6548 ssh \u767b\u5f55\u7684 JSON \u8f93\u51fa\u793a\u4f8b\u3002
\n\"\"<\/p>\n

\u4f7f\u7528\u5176\u4ed6\u7684\u9009\u9879\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 Kibana \u4eea\u8868\u76d8\u505a\u66f4\u591a\u7684\u4e8b\u60c5\u3002<\/p>\n

Elastic Stack \u5df2\u5b89\u88c5\u5728 CentOS 7 \u670d\u52a1\u5668\u4e0a\u3002 Filebeat \u5df2\u5b89\u88c5\u5728 CentOS 7 \u548c Ubuntu \u5ba2\u6237\u7aef\u4e0a\u3002<\/p>\n


\n

via: https:\/\/www.howtoforge.com\/tutorial\/how-to-install-elastic-stack-on-centos-7\/<\/a><\/p>\n

\u4f5c\u8005\uff1aMuhammad Arul<\/a> \u8bd1\u8005\uff1aFlowsnow<\/a> \u6821\u5bf9\uff1awxy<\/a><\/p>\n

\u672c\u6587\u7531 LCTT<\/a> \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd<\/a> \u8363\u8a89\u63a8\u51fa<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-8460-1.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttp:\/\/lrxjmw.cn\/elastic-stack-conf-install.html<\/a>\u7f16\u8f91\uff1a\u9676\u6b66\u6770\uff0c\u5ba1\u6838\u5458\uff1a\u51af\u632f\u534e<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb Elasticsearch\u662f\u57fa\u4e8e Lucene \u7531 Java \u5f00\u53d1\u7684\u5f00\u6e90\u641c\u7d22\u5f15\u64ce\uff0c\u662f\u7528\u4e8e\u7ba1\u7406\u4e8b\u4ef6\u548c\u65e5\u5fd7\u7684 […]<\/p>\n","protected":false},"author":63,"featured_media":63733,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-63676","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/63676","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=63676"}],"version-history":[{"count":19,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/63676\/revisions"}],"predecessor-version":[{"id":63765,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/63676\/revisions\/63765"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/63733"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=63676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=63676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=63676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}