安装

  1. cd /soft/bak
  2. wget https://artifacts.elastic.co/downloads/kibana/kibana-7.11.1-linux-x86_64.tar.gz
  3. tar zxvf kibana-7.11.1-linux-x86_64.tar.gz
  4. mv kibana-7.11.1-linux-x86_64 /soft/kibana
  5. vi /soft/kibana/config/kibana.yml
  1. server.port: 5601 #kibana端口
  2. server.host: "0.0.0.0" #绑定的主机IP地址
  3. elasticsearch.hosts: ["http://localhost:9200"] #elasticsearch的主机IP
  4. kibana.index: ".kibana" #开启此选项
  5. #elasticsearch.username: "kibana" #elasticsearch账号密码
  6. #elasticsearch.password: "pass"
  7. i18n.locale: "zh-CN" #kibana默认文字是英文,变更成中文

启动

如果使用root用户启动服务,后面必须加—allow-root选项。

/soft/kibana/bin/kibana --allow-root
nohup /soft/kibana/bin/kibana --allow-root & # 后台启动

通过浏览器访问地址:http://192.168.123.236:5601

通过访问kibana浏览器,我们可以直接在需要收集日志的主机上安装Beats软件,不需要在ELK主机上安装Logstash软件包。

使用systemd运行Kibana

要配置Kibana在系统启动时自动启动,请运行以下命令:

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable kibana.service

Kibana的启动和停止如下所示:

sudo systemctl start kibana.service
sudo systemctl stop kibana.service

这些命令没有提供关于Kibana是否成功启动的反馈,相反,这些信息将被写入位于/var/log/kibana/的日志文件中。

安装 Filebeat

curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.11.1-x86_64.rpm
sudo rpm -vi filebeat-7.11.1-x86_64.rpm
修改 vi /etc/filebeat/filebeat.yml 以设置连接信息:
output.elasticsearch:
  hosts: ["0.0.0.0:9200"]
  username: "elastic"
  password: "<password>"
setup.kibana:
  host: "0.0.0.0:5601"

vi /soft/elasticsearch/config/elasticsearch.yml

xpack.security.enabled: true

日志数据采集模块

filebeat setup
// nginx
filebeat modules enable nginx
在 vi /etc/filebeat/modules.d/nginx.yml 文件中修改设置nginx日志位置 路径需要加””
vi /etc/filebeat/filebeat.yml

reload.enabled: true
filebeat -e
service filebeat restart

// logstash
filebeat modules enable logstash
vi /etc/filebeat/modules.d/logstash.yml 文件中修改设置。

// redis
filebeat modules enable redis
在 vi /etc/filebeat/modules.d/redis.yml 文件中修改设置 路径需要加””

var.paths: ["/soft/redis/redis.log"]
var.hosts: ["localhost:6379"]
enabled: false
var.password: "xxxxxxxx"

filebeat -e
service filebeat start

软件指标数据采集模块

cd /soft/bak
curl -L -O https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-7.11.1-x86_64.rpm
rpm -vi metricbeat-7.11.1-x86_64.rpm
metricbeat modules enable mysql
vi /etc/metricbeat/modules.d/mysql.yml //配置mysql
metricbeat setup
metricbeat -e

启动 Filebeat

setup 命令加载 Kibana 仪表板。如果仪表板已设置,请省略此命令。

确认已从 Filebeat nginx 模块成功收到数据

安装应用程序性能监测 (APM)

cd /soft/bak
wget https://artifacts.elastic.co/downloads/apm-server/apm-server-7.11.1-x86_64.rpm
rpm -iv apm-server-7.11.1-x86_64.rpm
vi /etc/apm-server/apm-server.yml //修改ES相关配置 0.0.0.0
service apm-server start

报错

第一次连接kibana如果显示连接超时 进入 192.168.123.236:9200 把.kibana相关的内容删除再运行