Centos,ELK避坑版

奋斗吧
奋斗吧
擅长邻域:未填写

标签: Centos,ELK避坑版 博客 51CTO博客

2023-06-16 18:24:11 228浏览

Centos,ELK避坑版,1、root用户配置系统参数1.1root用户编辑vi/etc/sysctl.conf 添加vm.max_map_count=262144重新加载生效配置sysctl-p1.2输入:vi/etc/security/limits.conf末尾追加softnofile65536hardnofile65536softnproc4096hardnproc4096

1、root用户配置系统参数

1.1 root用户编辑 vi /etc/sysctl.conf 

添加 vm.max_map_count=262144

重新加载生效配置 sysctl -p

1.2 输入:vi /etc/security/limits.conf

末尾追加

  • soft nofile 65536
  • hard nofile 65536
  • soft nproc 4096
  • hard nproc 4096

2、创建elk普通用户,root用户授权

useradd elk

chown -R elk:elk /usr/local/elk

3、ELK安装(从官网上下载对应的版本,我这里是7.17.1)

下载ElasticSearch,Kibana,Logstash,Filebeat(统一一个版本)

3.1 ElasticSearch

3.1.1 上传到/usr/local/elk中

解压:tar -zxvf elasticsearch-7.17.1-linux-x86_64.tar.gz

改名: mv elasticsearch-7.17.1 elasticsearch 1.

配置config/elasticsearch.yml

ingest.geoip.downloader.enabled: false

xpack.security.enabled: true

xpack.security.authc.api_key.enabled: true

xpack.security.transport.ssl.enabled: true

cluster.name: es-cluster

node.name: node-1

path.data: /usr/local/elasticsearch/data(提前创建文件夹)

path.logs: /usr/local/elasticsearch/logs(提前创建文件夹)

bootstrap.memory_lock: false

network.host: 0.0.0.0

http.port: 9200

http.cors.enabled: true

http.cors.allow-origin: "*"

cluster.initial_master_nodes: ["node-1"]

切换elk用户,

转到bin文件夹下运行elasticsearch

运行查看是否有报错: ./elasticsearch ,

查看控制台日志,无异常,在浏览器里查看是否正常运行 http://ip:9200 ,

后台运行: ./elasticsearch -d

3.1.2 设置密码(确保elasticsearch在运行中)

运行(可以root用户进行设置) ./bin/elasticsearch-setup-passwords interactive

将密码全部都设置成123456。

3.1.3 在浏览器中打开http://****:9200   要求输入用户名和密码,输入elastic / 123456

就可看到elasticsearch的版本信息


3.2 Kibana

Centos,ELK避坑版_centos

3.3 Logstash

Centos,ELK避坑版_centos_02

3.3.1 配置Lostash.conf

input:

Centos,ELK避坑版_centos_03

filter:

filter { if [type] == "syslog" { grok { match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" } add_field => [ "received_at", "%{@timestamp}" ] add_field => [ "received_from", "%{host}" ] } date { match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ] } } }

Centos,ELK避坑版_elk_04

output:

Centos,ELK避坑版_centos_05

配置完成,验证配置文件,并运行Logstash

Centos,ELK避坑版_elk_06

3.4 Filebeat

Centos,ELK避坑版_elk_07


好博客就要一起分享哦!分享海报

此处可发布评论

评论(0展开评论

暂无评论,快来写一下吧

展开评论

您可能感兴趣的博客

客服QQ 1913284695