1.准备(集群所有节点)
IP | Hostname | Elasticsearch | Kibana | Logstash |
---|
192.168.120.104 | yellow.elk | ES(master or data) | kibana | logstash | 192.168.120.105 | blue.elk | ES(master or data) | None | logstash | 192.168.120.106 | green.elk | ES(master or data) | None | logstash |
服务 | 版本 |
---|
Elasticsearch | 7.15.2 | Kibana | 7.15.2 | Logstash | 7.15.2 |
[root@yellow ~]
CentOS Linux release 7.8.2003 (Core)
[root@yellow ~]
3.10.0-1127.el7.x86_64
[root@yellow ~]
systemctl stop firewalld
systemctl disable firewalld
systemctl stop NetworkManager
systemctl disable NetworkManager
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
grep SELINUX=disabled /etc/selinux/config
setenforce 0
wget http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
yum install epel-release-latest-7.noarch.rpm -y
vim /etc/security/limits.conf
* soft nofile 655360
* hard nofile 655360
* soft nproc 32000
* hard nproc 32000
* hard memlock unlimited
* soft memlock unlimited
vim /etc/systemd/system.conf
DefaultLimitNOFILE=65536
DefaultLimitNPROC=32000
DefaultLimitMEMLOCK=infinity
vim /etc/sysctl.conf
vm.max_map_count=655360
sysctl -p
yum update -y && reboot
1.1 安装JDK(集群所有节点)
rpm -qa | grep -i java | xargs -n1 sudo rpm -e --nodeps
tar -zxvf jdk-11.0.13_linux-x64_bin.tar.gz && mv jdk-11.0.13 /usr/local/jdk11
vim /etc/profile
export JAVA_HOME=/usr/local/jdk11
export JRE_HOME=$JAVA_HOME
export ES_JAVA_HOME=$JAVA_HOME
export CLASSPATH=.:$JAVA_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
java --version
echo $JAVA_HOME
echo $ES_JAVA_HOME
ln -s /usr/local/jdk11/bin/java /usr/local/bin/java
2.Elasticsearch搭建
2.1 ES下载
一般下载最新版本半年前的版本:https://www.elastic.co/cn/downloads/past-releases#elasticsearch 本次下载的版本:7.15.2 RPM包
2.2 安装(集群所有节点)
yum localinstall elasticsearch-7.15.2-x86_64.rpm -y
[root@yellow ~]
elasticsearch-7.15.2-1.x86_64
[root@yellow ~]
[root@yellow ~]
/etc/elasticsearch/elasticsearch.yml
/etc/elasticsearch/jvm.options
/etc/elasticsearch/log4j2.properties
/etc/elasticsearch/role_mapping.yml
/etc/elasticsearch/roles.yml
/etc/elasticsearch/users
/etc/elasticsearch/users_roles
/etc/init.d/elasticsearch
/etc/sysconfig/elasticsearch
/usr/lib/sysctl.d/elasticsearch.conf
/usr/lib/systemd/system/elasticsearch.service
2.3 修改配置文件(集群所有节点)
vim /etc/elasticsearch/elasticsearch.yml
cluster.name: myes
node.name: yellow.elk
node.master: true
node.data: true
node.max_local_storage_nodes: 3
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
bootstrap.memory_lock: true
network.host: 192.168.120.104
http.port: 9200
transport.tcp.port: 9300
discovery.seed_hosts: ["yellow.elk:9300", "blue.elk:9300", "green.elk:9300"]
cluster.initial_master_nodes: ["yellow.elk", "blue.elk", "green.elk"]
discovery.zen.fd.ping_interval: 30s
discovery.zen.fd.ping_timeout: 120s
discovery.zen.fd.ping_retries: 6
discovery.zen.minimum_master_nodes: 2
gateway.recover_after_nodes: 2
gateway.expected_nodes: 3
gateway.recover_after_time: 1m
node.ingest: true
http.cors.enabled: true
http.cors.allow-origin: true
chown -R elasticsearch:elasticsearch /var/lib/elasticsearch
2.4 启动服务(集群所有节点)
systemctl start elasticsearch
systemctl enable elasticsearch
http://192.168.120.104:9200/
http://192.168.120.105:9200/
http://192.168.120.106:9200/
http://192.168.120.104:9200/_cat/health?v
3.Cerebro搭建
下载最新版本:[https://github.com/lmenezes/cerebro/releases](https://github.com/lmenezes/cerebro/releases)
yum install cerebro-0.9.4-1.noarch.rpm -y
systemctl start cerebro
systemctl enable cerebro
http://192.168.120.104:9000/
http://192.168.120.104:9200/
4.Kibana搭建
https://www.elastic.co/cn/downloads/kibana
yum install kibana-7.15.2-x86_64.rpm -y
vim /etc/kibana/kibana.yml
server.publicBaseUrl: "http://192.168.120.104:5601"
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://192.168.120.104:9200"]
kibana.index: ".kibana"
i18n.locale: "zh-CN"
systemctl start kibana
systemctl enable kibana
http://192.168.120.104:5601/
5.Logstash搭建
yum install ntpdate -y && ntpdate time1.aliyun.com && timedatectl set-timezone Asia/Shanghai
https://blog.csdn.net/Happy_Sunshine_Boy/article/details/89917443
https://www.elastic.co/cn/downloads/past-releases
yum install logstash-7.15.2-x86_64.rpm -y
cd /etc/logstash
cp logstash-sample.conf syslog.conf
vim syslog.conf
input {
syslog {
type => "system-syslog"
port => 10514
}
}
output {
elasticsearch {
hosts => ["http://192.168.120.104:9200"]
index => "system-syslog-%{+YYYY.MM.dd}"
}
}
/usr/share/logstash/bin/logstash --path.settings /etc/logstash -f /etc/logstash/syslog.conf --config.test_and_exit
vim logstash.yml
http.host: 192.168.120.104
systemctl start logstash
systemctl enable logstash
|