vi /etc/sysctl.conf
vm.max_map_count=655360
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.all.rp_filter = 1
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max= 4194304
net.core.wmem_default= 262144
net.core.wmem_max= 1048576
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
sysctl -p
vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 65536
* hard nproc 131072
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
cat > /etc/yum.repos.d/elasticsearch.repo << EOF
[elasticsearch]
name=Elasticsearch repository for 8.x packages
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md
EOF
sudo yum install --enablerepo=elasticsearch elasticsearch
--------------------------- Security autoconfiguration information --------------------
Authentication and authorization are enabled.
TLS for the transport and HTTP layers is enabled and configured.
The generated password for the elastic built-in superuser is : 19BQQy63qtzL1I5wiSXs
If this node should join an existing cluster, you can reconfigure this with
'/usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token <token-here>'
after creating an enrollment token on your existing cluster.
You can complete the following actions at any time:
Reset the password of the elastic built-in superuser with
'/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic'.
Generate an enrollment token for Kibana instances with
'/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana'.
Generate an enrollment token for Elasticsearch nodes with
'/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node'.
export ELASTIC_PASSWORD="your_password"
-----------------------------------------------------------------------------------------
/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node
/usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token <enrollment-token>
network.host: 10.255.251.24
node.name: jtbakserver
xpack.security.enabled: false
xpack.security.enrollment.enabled: false
xpack.security.http.ssl:
enabled: false
keystore.path: certs/http.p12
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
cluster.initial_master_nodes: ["jtbakserver"]
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
echo "keystore_password" > /path/to/my_pwd_file.tmp
chmod 600 /path/to/my_pwd_file.tmp
sudo systemctl set-environment ES_KEYSTORE_PASSPHRASE_FILE=/path/to/my_pwd_file.tmp
sudo systemctl start elasticsearch.service
systemd journalctl --quiet ExecStart elasticsearch.service
sudo journalctl -f
sudo journalctl --unit elasticsearch
sudo journalctl --unit elasticsearch --since "2016-10-30 18:17:16"
curl -k http://10.255.251.24:9200/_cat/health?v
sudo yum install --enablerepo=elasticsearch kibana
wget https://artifacts.elastic.co/downloads/kibana/kibana-8.14.1-x86_64.rpm
wget https://artifacts.elastic.co/downloads/kibana/kibana-8.14.1-x86_64.rpm.sha512
shasum -a 512 -c kibana-8.14.1-x86_64.rpm.sha512
sudo rpm --install kibana-8.14.1-x86_64.rpm
server.host: "10.255.251.24"
elasticsearch.hosts: ["http://10.255.251.24:9200"]
i18n.locale: "zh-CN"
systemctl enable kibana.service
systemctl start kibana.service
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
cat > /etc/yum.repos.d/elasticsearch.repo << EOF
[elasticsearch]
name=Elasticsearch repository for 8.x packages
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md
EOF
sudo yum install logstash --enablerepo=elasticsearch
wget https://home.vimll.com:9999/download/elk/logstash-8.14.1-x86_64.rpm --no-check-certificate
yum install logstash-8.14.1-x86_64.rpm
wget https://artifacts.elastic.co/downloads/logstash/logstash-8.14.1-x86_64.rpm --no-check-certificate
yum install logstash-8.14.1-x86_64.rpm
logstash -e 'input { stdin {}} output { stdout {} }'
input {
beats {
port => 5044
}
}
output {
elasticsearch {
hosts => ["http://10.255.251.24:9200"]
index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
}
}
curl -k http://10.255.251.24:9200/_cat/indices?v
sudo yum install filebeat --enablerepo=elasticsearch
curl -k -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.6.16-x86_64.rpm
sudo rpm -vi filebeat-5.6.16-x86_64.rpm
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.14.2-linux-x86_64.tar.gz
tar xzvf filebeat-8.14.2-linux-x86_64.tar.gz
==========================================================================
[Unit]
Description=Filebeat sends log files to Logstash or directly to Elasticsearch.
Documentation=https://www.elastic.co/beats/filebeat
Wants=network-online.target
After=network-online.target
[Service]
UMask=0027
Environment="GODEBUG='madvdontneed=1'"
Environment="BEAT_LOG_OPTS="
Environment="BEAT_CONFIG_OPTS=-c /etc/filebeat/filebeat.yml"
Environment="BEAT_PATH_OPTS=--path.home /usr/local/src/filebeat-8.14.2-linux-x86_64 --path.config /etc/filebeat --path.data /usr/local/src/filebeat-8.14.2-linux-x86_64 --path.logs /usr/local/src/filebeat-8.14.2-linux-x86_64"
ExecStart=/usr/local/src/filebeat-8.14.2-linux-x86_64/filebeat --environment systemd $BEAT_LOG_OPTS $BEAT_CONFIG_OPTS $BEAT_PATH_OPTS
Restart=always
[Install]
WantedBy=multi-user.target
==============================================================================
vim /etc/filebeat/filebeat.yml
paths:
- /home/smartbike/smartbike/message-server-0.0.1-SNAPSHOT/logs/um_error.log
- /home/smartbike/smartbike/message-server-0.0.1-SNAPSHOT/logs/um_info.log
- /data/smartbike/backup/20231124/bike-jms-0.0.1-SNAPSHOT/logs/um_error.log
- /data/smartbike/backup/20231124/bike-jms-0.0.1-SNAPSHOT/logs/um_info.log
- /data/smartbike/backup/20231124/bike-access-0.0.1-SNAPSHOT/logs/um_error.log
- /data/smartbike/backup/20231124/bike-access-0.0.1-SNAPSHOT/logs/um_info.log
- /home/smartbike/smartbike/message-cluster-0.0.1-SNAPSHOT/logs/um_error.log
- /home/smartbike/smartbike/message-cluster-0.0.1-SNAPSHOT/logs/um_info.log
- /home/activemq/apache-activemq-5.10.1/data/activemq.log
name: 10.255.254.83
output.logstash:
hosts: ["10.255.251.24:5044"]
vim /etc/filebeat/filebeat.yml
paths:
- /home/smartbike/smartbike/message-server-0.0.1-SNAPSHOT/logs/um_error.log
- /home/smartbike/smartbike/message-server-0.0.1-SNAPSHOT/logs/um_info.log
- /home/smartbike/smartbike/bike-access-0.0.1-SNAPSHOT/logs/um_error.log
- /home/smartbike/smartbike/bike-access-0.0.1-SNAPSHOT/logs/um_info.log
- /home/smartbike/smartbike/bike-jms-0.0.1-SNAPSHOT/logs/um_error.log
- /home/smartbike/smartbike/bike-jms-0.0.1-SNAPSHOT/logs/um_info.log
name: 10.255.254.84
output.logstash:
hosts: ["10.255.251.24:5044"]
vim /etc/filebeat/filebeat.yml
paths:
- /home/smartbike/bike-ba-web-0.0.1-SNAPSHOT/logs/um_error.log
- /home/smartbike/bike-ba-web-0.0.1-SNAPSHOT/logs/um_info.log
- /home/smartbike/bike-access-0.0.1-SNAPSHOT/logs/um_error.log
- /home/smartbike/bike-access-0.0.1-SNAPSHOT/logs/um_info.log
- /home/smartbike/bike-jms-0.0.1-SNAPSHOT/logs/um_error.log
- /home/smartbike/bike-jms-0.0.1-SNAPSHOT/logs/um_info.log
- /home/smartbike/message-server-0.0.1-SNAPSHOT/logs/um_error.log
- /home/smartbike/message-server-0.0.1-SNAPSHOT/logs/um_info.log
name: 10.255.254.87
output.logstash:
hosts: ["10.255.251.24:5044"]
vim /etc/filebeat/filebeat.yml
paths:
- /home/smartbike/smartbike/message-server-0.0.1-SNAPSHOT/logs/um_error.log
- /home/smartbike/smartbike/message-server-0.0.1-SNAPSHOT/logs/um_info.log
- /home/smartbike/smartbike/bike-jms-0.0.1-SNAPSHOT/logs/um_error.log
- /home/smartbike/smartbike/bike-jms-0.0.1-SNAPSHOT/logs/um_info.log
- /home/smartbike/smartbike/bike-access-0.0.1-SNAPSHOT/logs/um_error.log
- /home/smartbike/smartbike/bike-access-0.0.1-SNAPSHOT/logs/um_info.log
name: 10.255.254.64
output.logstash:
hosts: ["10.255.251.24:5044"]
paths:
- /home/hzbike/bike-ba-web-0.0.1-SNAPSHOT/logs/um_error.log
- /home/hzbike/bike-ba-web-0.0.1-SNAPSHOT/logs/um_info.log
name: 10.255.250.79
output.logstash:
hosts: ["10.255.251.24:5044"]
vim /etc/filebeat/filebeat.yml
filebeat.inputs:
- type: log
enabled: true
paths:
- /home/H3C/20230905-new/bike-ba-web-0.0.1-SNAPSHOT/logs/um_error.log
- /home/H3C/20230905-new/bike-ba-web-0.0.1-SNAPSHOT/logs/um_info.log
- /home/H3C/20230905-new/bike-access-0.0.1-SNAPSHOT/logs/um_error.log
- /home/H3C/20230905-new/bike-access-0.0.1-SNAPSHOT/logs/um_info.log
- /home/H3C/20230905-new/bike-jms-0.0.1-SNAPSHOT/logs/um_error.log
- /home/H3C/20230905-new/bike-jms-0.0.1-SNAPSHOT/logs/um_info.log
- /home/H3C/20230905-new/message-server-0.0.1-SNAPSHOT/logs/um_error.log
- /home/H3C/20230905-new/message-server-0.0.1-SNAPSHOT/logs/um_info.log
name: 10.2.128.24
output.logstash:
hosts: ["10.255.251.24:5044"]
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
yum install docker-ce
systemctl enable --now docker
docker pull d.vimll.com:9888/root/plulic/jertel/elastalert2:latest
===========================================
rules_folder: /opt/elastalert/rules
run_every:
seconds: 30
buffer_time:
minutes: 15
es_host: 10.255.251.24
es_port: 9200
writeback_index: elastalert_status
alert_time_limit:
days: 2
=======================================
user: "xxxxxxxx@xxxxxx.com"
password: "xxxxxxxxx"
=======================================
name: "hz-log"
type: "frequency"
index: "filebeat-hz-log"
is_enabled: true
num_events: 50
timeframe:
minutes: 1
realert:
minutes: 10
silenced: false
timestamp_field: "@timestamp"
timestamp_type: "iso"
use_strftime_index: false
use_local_time: true
query_timezone: "Asia/Shanghai"
buffer_time:
minutes: 10
alert_subject: "ElastAlert: 杭州线下日志告警!!!"
alert_text_type: alert_text_only
alert_text: |
<< 杭州线下日志告警 >>
索引名称: {0}
时间: {1}
日志路径: {2}
10分钟错误日志数: {3}
规则匹配次数: {4}
日志信息: {5}
告警节点: {6}
日志ID: {7}
alert_text_args:
- "_index"
- "@timestamp"
- source
- num_hits
- num_matches
- message
- beat.name
- "_id"
filter:
- query:
query_string:
query: "\"Response Message Routing Error\" OR UMRouteInfoManager"
alert:
- "email"
email:
- "xxxx@xxxxxxxxxxxx.com"
smtp_auth_file: /opt/elastalert/email_auth.yaml
smtp_host: smtp.exmail.qq.com
smtp_port: 465
smtp_ssl: true
user: xxxxxxxx@xxxxxx.com
from_addr: xxxxxxxx@xxxxxx.com
email_reply_to: xxxxxxxx@xxxxxx.com
docker run -d --name elastalert -e TZ=Asia/Shanghai --restart=always -v /usr/local/src/elastalert2/elastalert.yaml:/opt/elastalert/config.yaml -v /usr/local/src/elastalert2/email_auth.yaml:/opt/elastalert/email_auth.yaml -v /usr/local/src/elastalert2/rules:/opt/elastalert/rules d.vimll.com:9888/root/plulic/jertel/elastalert2:latest --verbose
docker exec -it elastalert bash
docker logs -f elastalert -n 100