sudo apt install openjdk-8-jre-headless
java -version
#关闭防火墙
sudo ufw disable
#查看防火墙状况
sudo ufw status
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get install apt-transport-https
#这里是选择安装的版本,如果改成6.x就会安装最新的6.x的版本
echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
sudo apt-get update
sudo apt-get install logstash
sudo chmod 777 /usr/share/logstash/data
/usr/share/logstash/bin/logstash -e 'input{stdin{}}output{stdout{codec=>rubydebug}}'
sudo apt-get install elasticsearch
sudo vim /etc/elasticsearch/elasticsearch.yml
sudo -i service elasticsearch start
curl -X GET http://localhost:9200/
service elasticsearch status
sudo apt-get install kibana
sudo vim /usr/share/kibana/config/kibana.yml
sudo vim /etc/kibana/kibana.yml
使用默认配置就可以了,需要使用高级功能参考:官方详细配置方法
#如果连接不上,可以在elasticsearch.yml中添加配置:
sudo vim /etc/elasticsearch/elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
sudo -i service kibana start
service kibana status
#在浏览器中输入服务器ip,进程端口号为5601(默认)
https://localhost:5601
sudo apt-get update && sudo apt-get install filebeat
cd ~
curl -O https://gist.githubusercontent.com/thisismitch/3429023e8438cc25b86c/raw/d8c479e2a1adcea8b1fe86570e42abab0f10f364/filebeat-index-template.json
curl -XPUT 'http://localhost:9200/_template/filebeat?pretty' [email protected]
#注意将client_server_private_address替换为你客户端主机IP,将user替换为你的用户名
scp /etc/pki/tls/certs/logstash-forwarder.crt user@client_server_private_address:/tmp
sudo mkdir -p /etc/pki/tls/certs
sudo cp /tmp/logstash-forwarder.crt /etc/pki/tls/certs/
echo "deb https://packages.elastic.co/beats/apt stable main" | sudo tee -a /etc/apt/sources.list.d/beats.list
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get update
sudo apt-get install filebeat
vim /etc/filebeat/filebeat.yml
#注意!yml文件具有严格的缩进,请务必保持一致
filebeat:
prospectors:
-
paths:
- /var/log/auth.log
- /var/log/syslog
# - /var/log/*.log
input_type: log
document_type: syslog
registry_file: /var/lib/filebeat/registry
output:
logstash:
hosts: ["elk_server_private_ip:5044"]
bulk_max_size: 1024
tls:
certificate_authorities: ["/etc/pki/tls/certs/logstash-forwarder.crt"]
shipper:
logging:
files:
rotateeverybytes: 10485760 # = 10MB
sudo systemctl restart filebeat
sudo systemctl enable filebeat
在ELK服务器上,通过使用以下命令查询Filebeat索引,验证Elasticsearch是否确实正在接收数据:
curl -XGET 'http://localhost:9200/filebeat-*/_search?pretty'
如果您的输出显示总命中数为0,则Elasticsearch不会在您搜索的索引下加载任何日志,您应该检查设置是否有错误。如果收到预期输出,请继续执行下一步。
https://www.jianshu.com/p/43e3a2f437fd?tdsourcetag=s_pctim_aiomsg
https://www.howtoing.com/how-to-install-elasticsearch-logstash-and-kibana-elk-stack-on-ubuntu-16-04?tdsourcetag=s_pctim_aiomsg
1.常见的配置错误及解决办法
2.ELK常见问题及解决办法
3.curl: (7) Failed connect to 192.168.109.131:9200; 拒绝连接
4.Elasticsearch官方视频教程
5.腾讯云社区ELK安装指南