ELK 集群 安装 部署
- 史上最靠谱 集群部署 ( 7.1 , 7.2 , 7.3 , 7.4 , 7.5 , 7.6 , 7.7 , 7.8 等版本 )
一、ELK软件包下载
登录用户使用 root 账户下载软件、解压软件、拷贝软件 ,如果需要更换版本,可修改连接中的版本号
- elasticsearch
- https://www.elastic.co/downloads/past-releases#elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.5.0-linux-x86_64.tar.gz
- kibana
- https://www.elastic.co/downloads/past-releases#kibana
wget https://artifacts.elastic.co/downloads/kibana/kibana-7.5.0-linux-x86_64.tar.gz
- logstash
- https://www.elastic.co/downloads/past-releases#logstash
wget https://artifacts.elastic.co/downloads/logstash/logstash-7.5.0.zip
- filebate
- https://www.elastic.co/downloads/past-releases#filebeat
https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.5.0-linux-x86_64.tar.gz
```
二、服务器安装地址
- 安装 elasticsearch
- 10.8.12.80, 10.8.12.82, 10.8.12.83
- 安装 kbana
- 安装 logstash
- 安装 filebate (收集业务日志)
注意:elasticsearch, 启动命令切请换到elasticsearch账户下执行 kbana,logstash 启动命令切请换到 root 账户下执行
三、安装 elasticsearch
- 创建目录及安装软件(10.8.12.80, 10.8.12.82, 10.8.12.83)
创建ES启动用户
useradd elasticsearch
创建安装目录
mkdir -p /usr/local/elk/elasticsearch
解压软件报
tar -zxvf /usr/local/elk/elasticsearch/elasticsearch-7.5.0-linux-x86_64.tar.gz
拷贝软件报到
cp -r elasticsearch-7.5.0-linux-x86_64 /usr/local/elk/
重命名文件包
mv /usr/local/elk/elasticsearch-7.5.0-linux-x86_64 /usr/local/elk/elasticsearch
echo "vm.swappiness=0" >> /etc/sysctl.conf
echo "vm.max_map_count=655350" >> /etc/sysctl.conf
sysctl -p
vi /etc/security/limits.conf
* soft nproc 65536
* hard nproc 65536
* soft nofile 65536
* hard nofile 65536
chown -R elasticsearch:elasticsearch /usr/local/elk
cluster.name: cluster-7.5.0
node.name: node-1
node.master: true
node.data: true
path.data: /usr/local/elk/elasticsearch/data
path.logs: /usr/local/elk/elasticsearch/logs
http.port: 9200
network.host: 10.8.12.80
discovery.seed_hosts: ["10.8.12.80", "10.8.12.82","10.8.12.83"]
cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
cluster.name: cluster-7.5.0
node.name: node-2
node.master: true
node.data: true
path.data: /usr/local/elk/elasticsearch/data
path.logs: /usr/local/elk/elasticsearch/logs
http.port: 9200
network.host: 10.8.12.82
discovery.seed_hosts: ["10.8.12.80", "10.8.12.82","10.8.12.83"]
cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
cluster.name: cluster-7.5.0
node.name: node-3
node.master: true
node.data: true
path.data: /usr/local/elk/elasticsearch/data
path.logs: /usr/local/elk/elasticsearch/logs
http.port: 9200
network.host: 10.8.12.83
discovery.seed_hosts: ["10.8.12.80", "10.8.12.82","10.8.12.83"]
cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
启动命令
切换用户执行
su elasticsearch
sh /usl/local/elk/elasticsearch/bin/elasticsearch -d
验证是否成功
http://10.8.12.80:9200
四、安装 kibana
*软件解压及软件配置
解压
tar -zxvf /usr/local/elk/kibana-7.5.0-linux-x86_64.tar.gz
修改包名
mv /usr/local/elk/kibana-7.5.0-linux-x86_64 kibana
修改配置
vim /usr/local/elk/kibana/config/kibana.yml
i18n.locale: "zh-CN"
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://10.8.12.80:9200"]
启动命令
在root账户下执行命令
sh /usr/local/elk/kibana --allow-root >/tmp/kibana.log 2>&1 &
五、安装 logstash
解压
unzip /usr/local/elk/logstash-7.5.0.zip
修改包名
mv /usr/local/elk/logstash-7.5.0 /usr/local/elk/logstash
mkdie /usr/local/elk/logstash/data
mkdie /usr/local/elk/logstash/logs
vi /usr/local/elk/logstash/config/logstash.conf
output {
if [fieldtype] == "oa"{
elasticsearch {
hosts => ["http://10.8.12.80:9200"]
index => "oa-%{+YYYY.MM.dd}"
}
} else if [fieldtype] == "crm" {
elasticsearch {
hosts => ["http://10.8.12.80:9200"]
index => "crm-%{+YYYY.MM.dd}"
}
} else if [fieldtype] == "wms" {
elasticsearch {
hosts => ["http://10.8.12.80:9200"]
index => "wms-%{+YYYY.MM.dd}"
}
} else {
elasticsearch {
hosts => ["http://10.8.12.80:9200"]
index => "oa-%{+YYYY.MM.dd}"
}
}
}
vi /usr/local/elk/logstash/config/logstash.yml
path.data: /usr/local/elk/logstash/data
path.logs: /usr/local/elk/logstash/logs
启动命令
在root账户下执行命令
bin/logstash -f config/logstash.conf &
六、安装 filebeat
mkdir -p /usr/local/elk/filebeat
cd /usr/local/elk/filebeat
解压
tar -zxvf /usr/local/elk/kibana-7.5.0-linux-x86_64.tar.gz
修改包名
mv /usr/local/elk/kibana-7.5.0-linux-x86_64 kibana
vi /usr/local/elk/filebeat/filebeat.yml
- type: log
enabled: true
paths:
- /opt/oa/logs/err.log
- /opt/oa/logs/out.log
fields:
fieldtype: oa
fields_under_root: true
- type: log
enabled: true
paths:
- /opt/crm/logs/err.log
- /opt/crm/logs/out.log
fields:
fieldtype: crm
fields_under_root: true
- type: log
enabled: true
paths:
- /opt/wms/logs/err.log
- /opt/wms/logs/out.log
fields:
fieldtype: wms
fields_under_root: true
output.logstash:
hosts: [“10.8.12.80:5044”]
在root账户下执行命令
./filebeat -e -c filebeat.yml -d "Publish" &
七 kibana 使用
- 访问地址:http://10.8.12.80:5601
可以开始使用了
|