zl程序教程

您现在的位置是:首页 >  工具

当前栏目

如何在腾讯云CVM中使用docker搭建一个Kibana

Docker腾讯 使用 如何 一个 搭建 CVM Kibana
2023-06-13 09:18:32 时间

背景信息

由于腾讯云的Elastic Service免费提供的Kibana是搭建在1核1G的服务器上的,性能较差。本文叙述了如何在腾讯云CVM中使用docker搭建一个Kibana。该Kibana可以连接到腾讯云提供的Elastic Service。

kibana 7.x.x及以上新版本:

docker run --name kibana -e ELASTICSEARCH_HOSTS='["http://腾讯云ES的内网IP地址:9200"]' -e ELASTICSEARCH_USERNAME=elastic -e ELASTICSEARCH_PASSWORD=****** -e I18N_LOCALE=zh-CN -p 5601:5601 -d kibana:7.14.2

kibana 6.x.x老版本:

docker run --name kibana -e ELASTICSEARCH_URL=
http://腾讯云ES的内网IP地址:9200 -e ELASTICSEARCH_USERNAME=elastic -e ELASTICSEARCH_PASSWORD=****** -p 5601:5601 -d kibana:6.x.x

kibana.yml文件

如果不使用环境变量的方式,也可以通过变更kibana.yml文件的方式。例如:

变更docker中/usr/share/kibana/config/kibana.yml 文件:

#
# ** THIS IS AN AUTO-GENERATED FILE **
#

# Default Kibana configuration for docker target
server.host: "0"
server.shutdownTimeout: "5s"
elasticsearch.hosts: [ "http://腾讯云ES的内网IP地址:9200" ]
elasticsearch.username: elastic
elasticsearch.password: ******
monitoring.ui.container.elasticsearch.enabled: true
i18n.locale: "zh-CN"

正式环境

需要配置volume

docker run -it --rm -v full_path_to/config:/usr/share/kibana/config -v full_path_to/data:/usr/share/kibana/data kibana:7.14.2 bin/kibana-keystore create
docker run -it --rm -v full_path_to/config:/usr/share/kibana/config -v full_path_to/data:/usr/share/kibana/data kibana:7.14.2 bin/kibana-keystore add test_keystore_setting

docker run --name kibana -e ELASTICSEARCH_HOSTS='["http://腾讯云ES的内网IP地址:9200"]' -e ELASTICSEARCH_USERNAME=elastic -e ELASTICSEARCH_PASSWORD=****** -e I18N_LOCALE=zh-CN -v full_path_to/config:/usr/share/kibana/config -v full_path_to/data:/usr/share/kibana/data -p 5601:5601 -d kibana:7.14.2

参考文档

https://www.elastic.co/guide/en/kibana/7.17/docker.html

https://www.elastic.co/guide/en/kibana/7.17/settings.html

特别注意:务必保证elastic service和kibana的版本一致。elastic的文档,大版本不一致时,可能有较大的差异。