新手建站,门户网站app有哪些,wordpress添加新的模板,余杭住房和城乡建设局网站一、简介
1.1、软件简介
ELK其实是Elasticsearch#xff0c;Logstash 和 Kibana三个产品的首字母缩写#xff0c;这三款都是开源产品。
1.1.1、Elasticsearch简介
Elasticsearch 是一个分布式、高扩展、高实时的搜索与数据分析引擎。它能很方便的使大量数据具有搜索、分析…一、简介
1.1、软件简介
ELK其实是ElasticsearchLogstash 和 Kibana三个产品的首字母缩写这三款都是开源产品。
1.1.1、Elasticsearch简介
Elasticsearch 是一个分布式、高扩展、高实时的搜索与数据分析引擎。它能很方便的使大量数据具有搜索、分析和探索的能力。充分利用Elasticsearch的水平伸缩性能使数据在生产环境变得更有价值。Elasticsearch 的实现原理主要分为以下几个步骤首先用户将数据提交到Elasticsearch 数据库中再通过分词控制器去将对应的语句分词将其权重和分词结果一并存入数据当用户搜索数据时候再根据权重将结果排名打分再将返回结果呈现给用户。
1.1.2、Logstash简介
Logstash是基于过滤器/管道模式的工具用于收集处理和生成日志或事件。它有助于集中和实时分析来自不同来源的日志和事件。
Logstash是用在JVM上运行的JRuby编程语言编写的因此您可以在不同的平台上运行Logstash。它几乎从每种类型的源中收集不同类型的数据例如日志数据包事件事务时间戳数据等。数据源可以是社交数据电子商务新闻文章CRM游戏数据Web趋势金融数据物联网移动设备等。
1.1.3、Kibana简介
Kibana是一个开源的分析与可视化平台设计出来用于和Elasticsearch一起使用的。你可以用kibana搜索、查看、交互存放在Elasticsearch索引里的数据使用各种不同的图表、表格、地图等kibana能够很轻易地展示高级数据分析与可视化。
Kibana让我们理解大量数据变得很容易。它简单、基于浏览器的接口使你能快速创建和分享实时展现Elasticsearch查询变化的动态仪表盘。安装Kibana非常快你可以在几分钟之内安装和开始探索你的Elasticsearch索引数据不需要写任何代码没有其他基础软件依赖。
1.1.4、Filebeat简介
Filebeat是一个轻量级的托运器用于转发和集中日志数据。Filebeat作为代理安装在您的服务器上监视您指定的日志文件或位置收集日志事件并将其转发到Elasticsearch或Logstash进行索引
1.2、架构简介
大概就是Filebeat收集应用服务器的日志转给Logstash收集、解析之后将数据发送给Elasticsearch然后Kibana将之展示出来。 至于为什么用了一个Filebeat了就是因为其比较轻量但收集日志又完全OK所以将Logstash分离出来Logstash安装插件的时候就比较简单了不需要每台都安装节省了资源提高了效率
二、环境准备
2.1、软件下载
去这个网站找啊
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.14.3-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.14.3-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/logstash/logstash-8.14.3-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/kibana/kibana-8.14.3-linux-x86_64.tar.gz2.2、java环境安装
下载安装jdk
wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm
yum -y install ./jdk-17_linux-x64_bin.rpm修改环境变量
vim /etc/profileexport JAVA_HOME/usr/java/jdk-17
export PATH$JAVA_HOME/bin:$PATH刷新环境变量使之生效
source /etc/profile查看Java环境
java -version三、Elasticsearch
安装配置参考官方链接
3.1、安装
cd /home/local
tar -xvzf elasticsearch-8.14.3-linux-x86_64.tar.gz3.2、修改配置文件
vim elasticsearch-8.14.3/config/elasticsearch.ymlcluster.name: elk-application
node.name: node-1
path.data: /home/local/elasticsearch-8.14.3/data
path.logs: /home/local/elasticsearch-8.14.3/logs
network.host: 10.10.30.34
http.port: 9200
cluster.initial_master_nodes: [node-1]
xpack.security.enabled: false
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:enabled: falsekeystore.path: certs/http.p12
xpack.security.transport.ssl:enabled: trueverification_mode: certificatekeystore.path: certs/transport.p12truststore.path: certs/transport.p12
/home/local]# cat elasticsearch-8.14.3/config/elasticsearch.yml |grep -v ^# | grep -v ^$3.3、修改jvm
vim elasticsearch-8.14.3/config/jvm.options-Xms4g
-Xmx4g
-XX:UseG1GC
-Djava.io.tmpdir${ES_TMPDIR}
20-:--add-modulesjdk.incubator.vector
-XX:HeapDumpOnOutOfMemoryError
-XX:ExitOnOutOfMemoryError
-XX:HeapDumpPathdata
-XX:ErrorFilelogs/hs_err_pid%p.log
-Xlog:gc*,gcagetrace,safepoint:filelogs/gc.log:utctime,level,pid,tags:filecount32,filesize64mcat elasticsearch-8.14.3/config/jvm.options |grep -v ^# | grep -v ^$3.4、修改环境参数
修改连接数和文件数 临时生效ulimit -n 65535 永久生效
vim /etc/security/limits.confelastic - nofile 65535
elastic - noproc 65535修改虚拟内存 临时生效sysctl -w vm.max_map_count262144 永久生效
vim /etc/sysctl.confvm.max_map_count2621443.5、启动
Elasticsearch不能使用root用户启动
3.5.1、命令启动
useradd elastic
passwd elastic
chown -R elastic:elastic /home/local/elasticsearch-8.14.3
su - elastic
/home/local/elasticsearch-8.14.3/bin/elasticsearch -d3.5.2、服务启动
vim /lib/systemd/system/elasticsearch.service[Unit]
Descriptionelasticsearch
Wantsnetwork-online.target
Afternetwork-online.target[Service]
Userelastic
ExecStart/home/local/elasticsearch-8.14.3/bin/elasticsearch -d
PrivateTmptrue
# 指定此进程可以打开的最大文件数
LimitNOFILE65535
# 指定此进程可以打开的最大进程数
LimitNPROC65535
# 最大虚拟内存
LimitASinfinity
# 最大文件大小
LimitFSIZEinfinity
# 超时设置 0-永不超时
TimeoutStopSec0
# SIGTERM是停止java进程的信号
KillSignalSIGTERM
# 信号只发送给给JVM
KillModeprocess
# java进程不会被杀掉
SendSIGKILLno
# 正常退出状态
SuccessExitStatus143
[Install]
WantedBymulti-user.target#加载服务
systemctl daemon-reload
#开机自启
systemctl enable elasticsearch
#启动服务
systemctl start elasticsearch
#关闭服务
systemctl stop elasticsearch
#重启服务
systemctl restart elasticsearch
#查看状态
systemctl status elasticsearch
#查看日志
journalctl -f -u elasticsearch3.6、验证
3.6.1、访问页面
curl -I http://10.10.30.34:9200/3.6.2、查看进程
ps -ef | grep elasticsearch3.6.3、服务状态
systemctl status elasticsearch四、Logstash
4.1、安装
tar -xzvf logstash-8.14.3-linux-x86_64.tar.gz4.2、配置
vim logstash-8.14.3/config/logstash-sample.confinput {beats {port 5044}
}
output {if mes3-log in [tags] {elasticsearch {hosts [http://10.10.30.34:9200]index [mes3-log]-%{YYYY.MM.dd}}}
}cat logstash-8.14.3/config/logstash-sample.conf | grep -v ^# | grep -v ^$4.3、启动
4.3.1、命令启动
chown -R elastic:elastic /home/local/logstash-8.14.3
su - elastic
nohup /home/local/logstash-8.14.3/bin/logstash -f /home/local/logstash-8.14.3/config/logstash-sample.conf 4.3.2、服务启动
vim /lib/systemd/system/logstash.service[Unit]
Descriptionlogstash
Wantsnetwork-online.target
Afternetwork-online.target[Service]
Userelastic
ExecStart/home/local/logstash-8.14.3/bin/logstash -f /home/local/logstash-8.14.3/config/logstash-sample.conf
# 设置为掉线自动重启进程强制杀掉后会自动重新启动
Restartalways[Install]
WantedBymulti-user.target#加载服务
systemctl daemon-reload
#开机自启
systemctl enable logstash
#启动服务
systemctl start logstash
#关闭服务
systemctl stop logstash
#重启服务
systemctl restart logstash
#查看状态
systemctl status logstash
#查看日志
journalctl -f -u logstash4.4、验证
进程查看
ps -ef | grep logstash服务状态
systemctl status logstash五、Kibana
5.1、安装
tar xvzf kibana-8.14.3-linux-x86_64.tar.gz5.2、配置
vim kibana-8.14.3/config/kibana.ymlserver.port: 5601
server.host: 10.10.30.34
server.name: myshell
elasticsearch.hosts: [http://10.10.30.34:9200]
cat kibana-8.14.3/config/kibana.yml | grep -v ^# | grep -v ^$5.3、启动
5.3.1、命令启动
chown -R elastic:elastic kibana-8.14.3
su - elastic
nohup /home/local/kibana-8.14.3/bin/kibana 5.3.2、服务启动
vim /lib/systemd/system/kibana.service[Unit]
Descriptionkibana
Wantsnetwork-online.target
Afternetwork-online.target[Service]
Userelastic
ExecStart/home/local/kibana-8.14.3/bin/kibana
# 设置为掉线自动重启进程强制杀掉后会自动重新启动
Restartalways[Install]
WantedBymulti-user.target#加载服务
systemctl daemon-reload
#开机自启
systemctl enable kibana
#启动服务
systemctl start kibana
#关闭服务
systemctl stop kibana
#重启服务
systemctl restart kibana
#查看状态
systemctl status kibana
#查看日志
journalctl -f -u kibana5.4、验证
5.4.1、网页验证
curl -I http://10.10.30.34:56015.4.2、进程查看
ps -ef | grep kibana5.4.3、服务状态
systemctl status kibana六、Filebeat
6.1、安装
tar xvzf filebeat-8.14.3-linux-x86_64.tar.gz6.2、配置
vim /home/local/filebeat-8.14.3-linux-x86_64/filebeat.ymlfilebeat.inputs:
- type: filestreamid: filestream-2-3enabled: truepaths:- /var/lib/docker/containers/67eafd4ef65765ea5c6cec77dccbb357764a984de9cc1c21c7131688d3cc3bf3/*.log- /var/log/*.logtags: [mes3-log]exclude_lines: [^$]multiline:type: patternpattern: ^[0-9]{4}-[0-9]{4}-[0-9]{2}negate: truematch: after
filebeat.config.modules:path: ${path.config}/modules.d/*.ymlreload.enabled: false
setup.template.settings:index.number_of_shards: 1
setup.kibana:
output.logstash:hosts: [10.10.30.34:5044]
processors:- add_host_metadata:when.not.contains.tags: forwarded- add_cloud_metadata: ~- add_docker_metadata: ~- add_kubernetes_metadata: ~
seccomp:default_action: allow syscalls:- action: allownames:- rseq
cat /home/local/filebeat-8.14.3-linux-x86_64/filebeat.yml | grep -v ^# | grep -v ^$ | grep -v #6.3、启动
直接使用命令启动
nohup /home/local/filebeat-8.14.3-linux-x86_64/filebeat -e -c /home/local/filebeat-8.14.3-linux-x86_64/filebeat.yml 整成服务
vim /lib/systemd/system/filebeat.service[Unit]
Descriptionfilebeat
Wantsnetwork-online.target
Afternetwork-online.target[Service]
Userroot
ExecStart/home/local/filebeat-8.14.3-linux-x86_64/filebeat -e -c /home/local/filebeat-8.14.3-linux-x86_64/filebeat.yml
# 设置为掉线自动重启进程强制杀掉后会自动重新启动
Restartalways[Install]
WantedBymulti-user.target#加载服务
systemctl daemon-reload
#开机自启
systemctl enable filebeat
#启动服务
systemctl start filebeat
#关闭服务
systemctl stop filebeat
#重启服务
systemctl restart filebeat
#查看状态
systemctl status filebeat
#查看日志
journalctl -f -u filebeat6.4、验证
查看进程
ps -ef | grep filebeat查看服务状态
systemctl status filebeat七、Kibana网页配
7.1、Index Management 7.2、Data Views 7.3、Discover