一、下載源碼包
1 官網下載
下載帶有jdk的elasticsearch
https://elasticsearch.cn/download/
2 網盤下載
https://pan.baidu.com/share/init?surl=zmVDZLZ1KJyQUdQDgJwKPw
提取碼:mtvl
3 集群環境
1.1.1.6 jdk+elasticsearch主節點+kibana 1.1.1.7 jdk+elasticsearch數據節點+filebeat 1.1.1.8 jdk+elasticsearch數據節點+logstash 1.1.1.7的filebeat監控本機某個日志文件,輸出到1.1.1.8的logstash, 1.1.1.8的logstash連接到1.1.1.6的elasticsearch,生成elasticsearch索引 1.1.1.6的kibana web顯示內容

二、安裝前准備
1 創建普通用戶
es無法使用root啟動
useradd es
2 增加最大虛擬內存區,至少262144
vi /etc/sysctl.conf
末尾加入
vm.max_map_count=262144
3 為es用戶增加進程最大可同時打開的文件數
查看當前每個進程最大可同時打開的文件數 ulimit -Hn ulimit -Sn
在/etc/security/limits.conf加入 es soft nofile 65536 es hard nofile 65536
4 為es用戶增加進程的最大線程數
查看當前每個進程的最大線程數 ulimit -Hu ulimit -Su 在/etc/security/limits.conf加入 es soft nproc 4096 es hard nproc 4096
5 安裝jdk環境並設置環境變量
https://www.cnblogs.com/gudanaimei/p/12525325.html
6 把源碼包以es用戶上傳至/home/es下,切換至es用戶
如果以root用戶上傳,請改變源碼包的所有者和所屬組(chown es:es /home/es/* -R)
su es
三、部署elk和filebeat
1 部署elasticsearch集群(三台主機都要)
1.1 解壓(三台主機都要)
cd /home/es
tar -xzvf ./elasticsearch-7.8.0-linux-x86_64.tar.gz
1.2 修改配置文件
常用基本配置詳情請到
https://www.cnblogs.com/gudanaimei/p/13283019.html
A 1.1.1.6主機上
cd /home/es/elasticsearch-7.8.0/config
vi elasticsearch.yml #集群名字,識別集群的標識,同一個集群名字必須相同,自定義或者默認 cluster.name: my-elk #該節點名稱,自定義或者默認 node.name: node1 #節點是否為為master節點 node.master: true #節點是否為為數據節點 node.data: false #監聽地址 network.host: 0.0.0.0 #監聽端口 http.port: 9200 #數據存放路徑 path.data: /home/es/data/elk/elasticsearch/data #日志存放路徑 path.logs: /home/es/data/elk/elasticsearch/logs #集群列表 discovery.seed_hosts: ["1.1.1.6", "1.1.1.7","1.1.1.8"] #初始化主節點,可以有多個,以逗號(,)隔開 cluster.initial_master_nodes: ["1.1.1.6"]
B 1.1.1.7主機上
cd /home/es/elasticsearch-7.8.0/config
vi elasticsearch.yml cluster.name: my-elk node.name: node2 node.master: false node.data: true network.host: 0.0.0.0 http.port: 9200 path.data: /home/es/data/elk/elasticsearch/data path.logs: /home/es/data/elk/elasticsearch/logs discovery.seed_hosts: ["1.1.1.6", "1.1.1.7","1.1.1.8"] cluster.initial_master_nodes: ["1.1.1.6"]
C 1.1.1.8主機上
cd /home/es/elasticsearch-7.8.0/config vi elasticsearch.yml
cluster.name: my-elk node.name: node3 node.master: false node.data: true network.host: 0.0.0.0 http.port: 9200 path.data: /home/es/data/elk/elasticsearch/data path.logs: /home/es/data/elk/elasticsearch/logs discovery.seed_hosts: ["1.1.1.6", "1.1.1.7","1.1.1.8"] cluster.initial_master_nodes: ["1.1.1.6"]
1.3 啟動elasticsearch(三台主機都要)
cd /home/es/elasticsearch-7.8.0
nohup ./bin/elasticsearch &
1.4 elasticsearch集群狀態查看
也可以在瀏覽器中查看
#查看指定節點狀態 curl 1.1.1.6:9200 #查看集群健康狀態(ip為集群中任意一個主機ip) curl 1.1.1.6:9200/_cluster/health?pretty #查看集群詳細信息(ip為集群中任意一個主機ip) curl 1.1.1.6:9200/_cluster/state?pretty #查看集群索引列表 curl 1.1.1.6:9200/_cat/indices?v
2 主節點1.1.1.6安裝kibana
2.1 解壓
cd /home/es/
tar -xzvf kibana-7.8.0-linux-x86_64.tar.gz
2.2 修改配置文件
常用基本配置詳情請到
https://www.cnblogs.com/gudanaimei/p/13283022.html
cd kibana-7.8.0-linux-x86_64/config/ vi kibana.yml server.port: 5601 server.host: 0.0.0.0 server.name: "kibana-1" elasticsearch.hosts: ["http://1.1.1.6:9200","http://1.1.1.7:9200","http://1.1.1.8:9200"] elasticsearch.preserveHost: true kibana.index: ".kibana" kibana.defaultAppId: "home" elasticsearch.pingTimeout: 1500 elasticsearch.requestTimeout: 30000 elasticsearch.shardTimeout: 30000 elasticsearch.startupTimeout: 5000 elasticsearch.logQueries: false pid.file: /home/es/data/elk/kibana/kibana.pid logging.dest: /home/es/data/elk/kibana/logs/kibana.log logging.silent: false logging.quiet: false logging.verbose: false ops.interval: 5000 i18n.locale: "en"
2.3 啟動kibana
cd /home/es/kibana-7.8.0-linux-x86_64
nohup ./bin/kibana &
2.4 瀏覽器查看kibana
查看kibana的插件是否准備好 1.1.1.6:5601/status 訪問kibana 1.1.1.6:5601
3 1.1.1.7安裝filebeat
3.1 解壓
cd /home/es/
tar -xzvf filebeat-7.8.0-linux-x86_64.tar.gz
3.2 修改配置文件
/home/es/logs目錄下存放了一些日志文件,所屬用戶和所屬組必須是es
常用基本配置詳情請到
https://www.cnblogs.com/gudanaimei/p/13283028.html
filebeat.inputs: - type: log enabled: true paths: - /home/es/logs/secure.log fields: level: debug tags: ["secure.log"] - type: log enabled: true paths: - /home/es/logs/secure.log.1 fields: level: debug tags: ["secure.log.1"] - type: log enabled: true paths: - /home/es/logs/secure.log.2 tags: ["secure.log.2"] - type: log enabled: true paths: - /home/es/logs/server.log tags: ["server.log"] #輸出到1.1.1.8的logstash output.logstash: hosts: ["1.1.1.8:5044"]
3.3 啟動filebeat
cd /home/es/filebeat-7.8.0-linux-x86_64
nohup ./filebeat -e -c ./filebeat.yml &
4 1.1.1.8安裝logstash
4.1 解壓
cd /home/es
tar -xzvf logstash-7.8.0.tar.gz
4.2 修改配置文件
常用基本配置詳情請到
https://www.cnblogs.com/gudanaimei/p/13283025.html
cd logstash-7.8.0/config/
mv logstash-sample.conf logstash.conf
A 修改主配置文件logstash.yml
vi logstash.yml node.name: "logstash-1" path.data: /home/es/data/elk/logstash/data http.enabled: true http.host: 0.0.0.0 http.port: 9600-9700 log.level: info log.format: json path.logs: /home/es/data/elk/logstash/logs
B 修改輸出文件logstash.conf
input { beats { port => 5044 } } output { if "secure.log" in [tags] { elasticsearch { hosts => ["http://1.1.1.6:9200"] index => "secure_log" } } else if "secure.log.1" in [tags] { elasticsearch { hosts => ["http://1.1.1.6:9200"] index => "secure_log_1" } } else if "secure.log.2" in [tags] { elasticsearch { hosts => ["http://1.1.1.6:9200"] index => "secure_log_2" } } else if "server.log" in [tags] { elasticsearch { hosts => ["http://1.1.1.6:9200"] index => "serverlog" } } }
4.3 啟動logstash
cd /home/es/logstash-7.8.0
nohup bin/logstash -f config/logstash.conf &
4.4 查看logstash詳情
瀏覽器輸入
1.1.1.8:9600
或者curl 1.1.1.8:9600