大连将30个中风险地区调整为低风...
大连将30个中风险地区调整为低风险地区 ...
(资料图)
主要记录下filebeat+logstash+elasticsearch+kibana抽取过滤存储展示应用日志文件的方式;版本基于8.8,并开启xpack安全认证。由于从7.X开始就自带JDK,故这里也不展示环境配置等步骤。
下载服务elasticsearch:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.8.1-linux-x86_64.tar.gzkibana:https://artifacts.elastic.co/downloads/kibana/kibana-8.8.1-linux-x86_64.tar.gzfilebeat:https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.8.1-linux-x86_64.tar.gzlogstash:https://artifacts.elastic.co/downloads/logstash/logstash-8.8.1-linux-x86_64.tar.gz
环境介绍IP | 系统 | 服务 | 软件版本 |
---|---|---|---|
172.16.0.1 | CentOS Linux release 7.6.1810 (Core) | logstash+elasticsearch+kibana | 8.8.1 |
172.16.0.2 | CentOS Linux release 7.6.1810 (Core) | logstash+elasticsearch+kibana | 8.8.1 |
172.16.0.3 | CentOS Linux release 7.6.1810 (Core) | logstash+elasticsearch+kibana | 8.8.1 |
useradd -d /home/elk -m elkecho "123@qwe"|passwd elk --stdin
安装es- 创建es数据目录和log目录;mkdir /data/elk/elasticsearch/{data,log}- 解压安装包tar -zxvf elasticsearch-8.8.1-linux-x86_64.tar.gz- 进入config目录,修改配置文件elasticsearch.yml;cd elasticsearch-8.8.1/config- 修改配置文件取消以下注释并配置;vim elasticsearch.ymlcluster.name: my-applicationnode.name: node-1path.data: /data/elk/elasticsearch/datapath.logs: /data/elk/elasticsearch/logsnetwork.host: 0.0.0.0http.port: 9200- 首次启动不要后台启动;pwd/home/elk/elasticsearch-8.8.1/configcd /home/elk/elasticsearch-8.8.1/bin./elasticsearch**前台日志输出最后内容<要记录下来>**:✅ Elasticsearch security features have been automatically configured!✅ Authentication is enabled and cluster connections are encrypted.ℹ️ Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`): 2j6qweqeRqnAnPGU61ℹ️ HTTP CA certificate SHA-256 fingerprint: 09189c0bb24353451b32f603d509272d591sad123815b1233d7aeℹ️ Configure Kibana to use this cluster:• Run Kibana and click the configuration link in the terminal when Kibana starts.• Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes): eyJ2ZXIiOiI4LjguMSIsImFkciI6WyIxMC4yNTMuMTc3LjkyOjkyMDAiXSwiZmdyIjoiMDkxODljMGJiMjc4NDE4YTIyNjE4YjBlN2M5OGIzMmY2MDNkNTA5MjcyZDU5MWZiNzkwMDQzODE1YjY3ZDdhZSIsImtleSI6Im02ckE5WWdCUEJtZ2J3czVUWU14OjRUYVliMi1SUWFHSlVlRWJaYk5NUVEifQ==ℹ️ Configure other nodes to join this cluster:• Copy the following enrollment token and start new Elasticsearch nodes with `bin/elasticsearch --enrollment-token ` (valid for the next 30 minutes): eyJ2ZXIiOiI4LjguMSIsImFkciI6WyIxMC4yNTMuMTc3LjkyOjkyMDAiXSwiZmdyIjoiMDkxODljMGJiMjc4NDE4YTIyNjE4YjBlN2M5OGIzMmY2MDNkNTA5MjcyZDU5MWZiNzkwMDQzODE1YjY3ZDdhZSIsImtleSI6Im1xckE5WWdCUEJtZ2J3czVUWU12Omt1aEdkVXAzUTA2LUpqOVNmMWkweEEifQ== If you"re running in Docker, copy the enrollment token and run: `docker run -e "ENROLLMENT_TOKEN=" docker.elastic.co/elasticsearch/elasticsearch:8.8.1`- 重新开启一个会话窗口,再次查看elasticsearch.yml配置,会发现多了xpack安全认证; ``` # Enable security features xpack.security.enabled: true xpack.security.enrollment.enabled: true xpack.monitoring.collection.enabled: true # Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents xpack.security.http.ssl: enabled: true keystore.path: certs/http.p12 # Enable encryption and mutual authentication between cluster nodes xpack.security.transport.ssl: enabled: true verification_mode: certificate keystore.path: certs/transport.p12 truststore.path: certs/transport.p12 # Create a new cluster with the current node only # Additional nodes can still join the cluster later cluster.initial_master_nodes: ["node-1"] ``` 同时/home/elk/elasticsearch-8.8.1/config目录下增加一个certs目录,里面有以下内容; ll certs/ 总用量 24 -rw-rw---- 1 elk elk 1915 6月 26 11:29 http_ca.crt -rw-rw---- 1 elk elk 9997 6月 26 11:29 http.p12 -rw-rw---- 1 elk elk 5822 6月 26 11:29 transport.p12 - 关闭elasticsearch服务,并后台启动;[elk@host-172-16-0-1 config]$ ps -ef|grep elasticsearch|grep -v grep|awk "{print $2}"|xargs kill[elk@host-172-16-0-1 config]$ cd ../bin/[elk@host-172-16-0-1 bin]$ ./elasticsearch -d - 初始化elasticsearch内置kibana用户密码;./elasticsearch-reset-password -u kibaina- 浏览器访问https://172.16.0.1:9200,输入elastic密码2j6qweqeRqnAnPGU61:
安装kibana- 解压安装包;tar -zxvf kibana-8.8.1-linux-x86_64.tar.gzcd kibana-8.8.1/config- 拷贝es目录下certs文件夹到config下;\cp -rf /home/elk/elasticsearch-8.8.1/config/certs ./- 修改kibana.yml,取消以下注释并配置;vim kibana.ymlserver.port: 5601server.host: "172.16.0.1"elasticsearch.hosts: ["https://172.16.0.1:9200"]elasticsearch.username: "kibana" # es内置用户;elasticsearch.password: "pkRqnAnPGU61123" # es初始化的的密码;elasticsearch.ssl.certificateAuthorities: [ "/home/elk/kibana-8.8.1/config/certs/http_ca.crt" ]i18n.locale: "zh-CN"- 启动kibanacd /home/elk/kibana-8.8.1/nohup ./bin/kibana &- 访问http://10.253.177.92:5601/login,输入elastic密码2j6qweqeRqnAnPGU61:
安装logstash- 解压安装包;tar -zxvf logstash-8.8.1-linux-x86_64.tar.gzcd logstash-8.8.1/config/- 拷贝es目录下certs文件夹到config下;\cp -rf /home/elk/elasticsearch-8.8.1/config/certs ./- 修改配置文件logstash.yml;vim logstash.ymlhttp.host: "0.0.0.0"xpack.monitoring.enabled: truexpack.monitoring.elasticsearch.username: elasticxpack.monitoring.elasticsearch.password: 2j6qweqeRqnAnPGU61xpack.monitoring.elasticsearch.hosts: ["https://172.16.0.1:9200"]xpack.monitoring.elasticsearch.ssl.certificate_authority: "/home/elk/logstash-8.8.1/config/certs/http_ca.crt"xpack.monitoring.elasticsearch.ssl.ca_trusted_fingerprint: 09189c0bb278418a22618b0e7c98b32f603d509272d591fb790043815b67d7ae - 修改logstash-sample.conf配置;vim logstash-sample.confinput { beats { port => 5041 }}output { elasticsearch { hosts => ["https://172.16.0.1:9200"] #index => "%{[fields][service_name]}-%{+YYYY.MM.dd}" ssl => true ssl_certificate_verification => false cacert => "/home/elk/logstash-8.8.1/config/certs/http_ca.crt" ca_trusted_fingerprint => "09189c0bb278418a22618b0e7c98b32f603d509272d591fb790043815b67d7ae" user => "elastic" password => "2j6qweqeRqnAnPGU61" } stdout {codec => rubydebug}}- 启动logstash;nohup ./bin/logstash -f /home/elk/logstash-8.8.1/config/logstash-sample.conf &
安装filebeat- 分别登录172.16.0.2/3两台应用服务器/data目录;mkdir filebeattar -zxvf filebeat-8.8.1-linux-x86_64.tar.gzcd filebeat-8.8.1-linux-x86_64- 修改filebeat.yml配置文件vim filebeat.ymlfilebeat.inputs: - type: log id: 1 enable: true paths: - /data/app/ap/logs/*.log # 要采集的日志文件或路径# output.elasticsearch: # 由于本文架构是filebeat的output是到logstash,故关闭默认output.elasticsearch;output.logstash: hosts: ["172.16.0.1:5041"] # 这里的端口要与logstash-sample.conf配置里的一致;- 配置完成,临时启动filebeat;nohup ./filebeat -e -c filebeat.yml > /dev/null 2>&1- 由于通过nohub方式启动filebeat,运行一段时间后filebeat自动退出;原因是filebeat默认会定期检测文件是否有新的内容,如果超过一定时间检测的文件没有新数据写入,那么filebeat会自动退出,解决办法就是将filebeat通过系统后台的方式长期运行; - 添加systemctl服务启动配置 vim /etc/systemd/system/filebeat.service [Unit] Description=Filebeat is a lightweight shipper for metrics. Documentation=https://www.elastic.co/products/beats/filebeat Wants=network-online.target After=network-online.target [Service] Environment="LOG_OPTS=-e" Environment="CONFIG_OPTS=-c /data/filebeat/filebeat-8.8.1-linux-x86_64/filebeat.yml" Environment="PATH_OPTS=-path.home /data/filebeat/filebeat-8.8.1-linux-x86_64/filebeat -path.config /data/filebeat/fileb eat-8.8.1-linux-x86_64 -path.data /data/filebeat/filebeat-8.8.1-linux-x86_64/data -path.logs /data/filebeat/filebeat-8. 8.1-linux-x86_64/logs" ExecStart=/data/filebeat/filebeat-8.8.1-linux-x86_64/filebeat $LOG_OPTS $CONFIG_OPTS $PATH_OPTS Restart=always [Install] WantedBy=multi-user.target - 授予可执行权限 chmod +x /etc/systemd/system/filebeat.service - 配置开机启动等 systemctl daemon-reload systemctl enable filebeat systemctl start filebeat
登录kibana查看 关键词:
6月15日,5月国民经济多项指标出炉。数据显示,5月份受疫情影响,消费业态承压明显,但同时,城镇调查失业率出现小幅下降,工业生产由降转
北京商报 2022-06-20中新经纬11月24日电 (张澍楠)虽说三百六十行,行行出状元,但行业之间的差距,仍然很大。究竟什么行业“最香”?被视为“高富帅”的金
2021-11-24新华社郑州11月23日电(记者冯大鹏)在“狗咬人”舆情发酵后,23日晚,河南安阳通报了对涉“狗咬人”事件责任单位和责任人的处理决定。
2021-11-2411月23日晚,朝阳区来广营地区清苑路第五社区华贸城7号院6号楼正式解除管控。 11月23日,华贸城7号院6号楼583户管控居民进行了第四
2021-11-2411月23日大连市新冠肺炎疫情防控总指挥部发布,大连市严格落实新冠肺炎疫情防控各项措施,至2021年11月23日24时,大连市庄河市城关街道
2021-11-24根据云南省普洱市哀牢山 "11·15 "联合指挥部通报,2021年11月23日21时50分,4名遇难人员遗体已移交其所在单位。 【编辑:叶攀】
2021-11-24中新网银川11月23日电 (李佩珊 姚舒玲)“在宁夏,每6个农村妇女中就有1个接受过创业担保贷款项目的资金支持。”11月23日,宁夏妇联党
2021-11-246月15日,5月国民经济多项指标出炉。数据显示,5月份受疫情影响,消费业态承压明显,但同时,城镇调查失业率出现小幅下降,工业生产由降转
北京商报 2022-06-20中新经纬11月24日电 (张澍楠)虽说三百六十行,行行出状元,但行业之间的差距,仍然很大。究竟什么行业“最香”?被视为“高富帅”的金
2021-11-24新华社郑州11月23日电(记者冯大鹏)在“狗咬人”舆情发酵后,23日晚,河南安阳通报了对涉“狗咬人”事件责任单位和责任人的处理决定。
2021-11-24根据云南省普洱市哀牢山 "11·15 "联合指挥部通报,2021年11月23日21时50分,4名遇难人员遗体已移交其所在单位。 【编辑:叶攀】
2021-11-24中新网银川11月23日电 (李佩珊 姚舒玲)“在宁夏,每6个农村妇女中就有1个接受过创业担保贷款项目的资金支持。”11月23日,宁夏妇联党
2021-11-24中新网拉萨11月23日电 (记者 冉文娟)第三届拉萨市旅游行业服务技能大赛决赛11月23日精彩举行。百余名选手经过层层选拔,经历初赛、网
2021-11-24中新网长春11月23日电 (郭佳 吴林锡)东北虎豹国家公园23日全面启动2021-2022年今冬明春清山清套·打击乱捕滥猎专项行动。该行动旨在
2021-11-24大连将30个中风险地区调整为低风险地区 ...
中新网成都11月22日电 (记者 刘忠俊)四...
(北京冬奥会)北京规划超270公里冬奥道路网...
中新网杭州11月22日电(郭其钰 张益聪)“...
中新网北京11月22日电 (记者 杜燕)今天...
山西长子“羊倌”养羊20余年 带动700余户养殖户发“羊财”
上海首个“两山”实践创新基地成功创建
广西医科大一附院向越南捐赠医疗防疫物资
黄埔海关破获案值5.5亿元走私进口二手挖掘机案
黄河内蒙古段今年首次出现流凌
Copyright 2015-2022 全球仓储网版权所有 备案号:豫ICP备20009784号-11 联系邮箱:85 18 07 48 3@qq.com