前言:
kibana是比较好安装的,但https+密码就比较麻烦一些了,下面将就如何安装一个可在生产使用的kibana做一个简单的讲述
一,
kibana版本和下载地址
这里我想还是强调一下,kibana的版本需要和elasticsearch的版本一致,小版本都不能差,否则,kibana将不能正确连接到elasticsearch
本例我使用的是elasticsearch-6.3.2版本,因此,下载的kibana版本也是6.3.2
官方下载地址:
两个版本二进制和rpm基本没有什么区别,想折腾点就二进制了,不想太麻烦rpm即可,看自己的需求啦。
不过要吐槽一下,官网下载比较慢,即使科学上网仍然很慢,因此,是需要一点耐心了
下载完毕后,没什么好说的,扔到服务器上就可以了
二,
elasticsearch的证书
kibana是安装在192.168.123.15上面的(kibana是node项目,可以安装在任意的服务器上,不需要配置node环境)
elasticsearch|大数据|elasticsearch的api部分实战操作以及用户和密码的管理-CSDN博客?这个是elasticsearch集群的https开启,部署的时候没有添加192.168.123.15,因此,重新生成证书:
[root@node4 ~]# cat instances.yml
instances:
- name: "node-1"
dns: ['192.168.123.11']
- name: "node-2"
dns: ['192.168.123.12']
- name: "node-3"
dns: ['192.168.123.13']
- name: 'node-4'
dns: ['192.168.123.14']
- name: 'node-5'
dns: ['192.168.123.15']
执行以下命令生成证书包:
###注:生成的证书格式是pem的,可以直接使用,无需任何转换(哪个服务器都可以,随便找个服务器就可以了)
/data/es/bin/x-pack/certutil cert ca --pem --in instances.yml --out /root/certs.zip
解压上面在root根目录下生成的证书包
在15服务器上,证书放置在此目录下/opt/kibana/(kibana整个也是放置在opt目录下的,二进制方式部署):
[root@centos5 kibana]# ls -al ca.crt node-5.crt node-5.key
-rw-r--r-- 1 root root 1200 Dec 15 23:07 ca.crt
-rw-r--r-- 1 root root 1180 Dec 15 23:07 node-5.crt
-rw-r--r-- 1 root root 1679 Dec 15 23:07 node-5.key
证书重新分发到elasticsearch集群,然后重启elasticsearch集群??
kibana的配置文件:
####注意,密码必须双引号包裹,否则kibana识别不了,会报错,其次是elasticsearch.url?的值是elasticsearch集群的任意一个节点URL就可以了,不需要全部节点都列出
####elasticsearch.ssl.verificationMode: certificate?和elasticsearch的设置一致
[root@centos5 kibana]# cat config/kibana.yml
# Kibana is served by a back end server. This setting specifies the port to use.
server.port: 15666
# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
server.host: 192.168.123.15
# Enables you to specify a path to mount Kibana at if you are running behind a proxy.
# Use the `server.rewriteBasePath` setting to tell Kibana if it should remove the basePath
# from requests it receives, and to prevent a deprecation warning at startup.
# This setting cannot end in a slash.
#server.basePath: ""
# Specifies whether Kibana should rewrite requests that are prefixed with
# `server.basePath` or require that they are rewritten by your reverse proxy.
# This setting was effectively always `false` before Kibana 6.3 and will
# default to `true` starting in Kibana 7.0.
#server.rewriteBasePath: false
# The maximum payload size in bytes for incoming server requests.
#server.maxPayloadBytes: 1048576
# The Kibana server's name. This is used for display purposes.
server.name: mykibana
# The URL of the Elasticsearch instance to use for all your queries.
elasticsearch.url: https://192.168.123.11:19200
# When this setting's value is true Kibana uses the hostname specified in the server.host
# setting. When the value of this setting is false, Kibana uses the hostname of the host
# that connects to this Kibana instance.
#elasticsearch.preserveHost: true
# Kibana uses an index in Elasticsearch to store saved searches, visualizations and
# dashboards. Kibana creates a new index if the index doesn't already exist.
#kibana.index: ".kibana"
# The default application to load.
#kibana.defaultAppId: "home"
# If your Elasticsearch is protected with basic authentication, these settings provide
# the username and password that the Kibana server uses to perform maintenance on the Kibana
# index at startup. Your Kibana users still need to authenticate with Elasticsearch, which
# is proxied through the Kibana server.
elasticsearch.username: elastic
elasticsearch.password: "123456"
# Enables SSL and paths to the PEM-format SSL certificate and SSL key files, respectively.
# These settings enable SSL for outgoing requests from the Kibana server to the browser.
server.ssl.enabled: true
server.ssl.certificate: /opt/kibana/node-5.crt
server.ssl.key: /opt/kibana/node-5.key
# Optional settings that provide the paths to the PEM-format SSL certificate and key files.
# These files validate that your Elasticsearch backend uses the same key files.
#elasticsearch.ssl.certificate: /path/to/your/client.crt
#elasticsearch.ssl.key: /path/to/your/client.key
# Optional setting that enables you to specify a path to the PEM file for the certificate
# authority for your Elasticsearch instance.
elasticsearch.ssl.certificateAuthorities: [ "/opt/kibana/ca.crt" ]
# To disregard the validity of SSL certificates, change this setting's value to 'none'.
elasticsearch.ssl.verificationMode: certificate
# Time in milliseconds to wait for Elasticsearch to respond to pings. Defaults to the value of
# the elasticsearch.requestTimeout setting.
#elasticsearch.pingTimeout: 1500
# Time in milliseconds to wait for responses from the back end or Elasticsearch. This value
# must be a positive integer.
#elasticsearch.requestTimeout: 30000
# List of Kibana client-side headers to send to Elasticsearch. To send *no* client-side
# headers, set this value to [] (an empty list).
#elasticsearch.requestHeadersWhitelist: [ authorization ]
# Header names and values that are sent to Elasticsearch. Any custom headers cannot be overwritten
# by client-side headers, regardless of the elasticsearch.requestHeadersWhitelist configuration.
#elasticsearch.customHeaders: {}
# Time in milliseconds for Elasticsearch to wait for responses from shards. Set to 0 to disable.
#elasticsearch.shardTimeout: 30000
# Time in milliseconds to wait for Elasticsearch at Kibana startup before retrying.
#elasticsearch.startupTimeout: 5000
# Logs queries sent to Elasticsearch. Requires logging.verbose set to true.
#elasticsearch.logQueries: false
# Specifies the path where Kibana creates the process ID file.
#pid.file: /var/run/kibana.pid
# Enables you specify a file where Kibana stores log output.
logging.dest: /var/log/kibana/kibana.log
# Set the value of this setting to true to suppress all logging output.
#logging.silent: false
# Set the value of this setting to true to suppress all logging output other than error messages.
#logging.quiet: false
# Set the value of this setting to true to log all events, including system usage information
# and all requests.
#logging.verbose: false
# Set the interval in milliseconds to sample system and process performance
# metrics. Minimum is 100ms. Defaults to 5000.
#ops.interval: 5000
# The default locale. This locale can be used in certain circumstances to substitute any missing
# translations.
i18n.defaultLocale: "zh-CN"
根据配置文件,创建目录(kibana.log文件会自动生成):
mkdir /var/log/kibana
/opt/kibana/bin/kibana
此时是前台启动,直接看日志:
###提示kibana的版本是6.3.2,但elasticsearch的版本是6.2.4版本,
[root@centos5 kibana]# tail -n 10 /var/log/kibana/kibana.log
{"type":"log","@timestamp":"2023-12-15T23:48:48Z","tags":["status","plugin:searchprofiler@6.3.2","info"],"pid":1572,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"This version of Kibana requires Elasticsearch v6.3.2 on all nodes. I found the following incompatible nodes in your cluster: v6.2.4 @ 192.168.123.14:19200 (192.168.123.14), v6.2.4 @ 192.168.123.13:19200 (192.168.123.13), v6.2.4 @ 192.168.123.12:19200 (192.168.123.12), v6.2.4 @ 192.168.123.11:19200 (192.168.123.11)"}
{"type":"log","@timestamp":"2023-12-15T23:48:48Z","tags":["status","plugin:ml@6.3.2","info"],"pid":1572,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"This version of Kibana requires Elasticsearch v6.3.2 on all nodes. I found the following incompatible nodes in your cluster: v6.2.4 @ 192.168.123.14:19200 (192.168.123.14), v6.2.4 @ 192.168.123.13:19200 (192.168.123.13), v6.2.4 @ 192.168.123.12:19200 (192.168.123.12), v6.2.4 @ 192.168.123.11:19200 (192.168.123.11)"}
{"type":"log","@timestamp":"2023-12-15T23:48:48Z","tags":["status","plugin:tilemap@6.3.2","info"],"pid":1572,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"This version of Kibana requires Elasticsearch v6.3.2 on all nodes. I found the following incompatible nodes in your cluster: v6.2.4 @ 192.168.123.14:19200 (192.168.123.14), v6.2.4 @ 192.168.123.13:19200 (192.168.123.13), v6.2.4 @ 192.168.123.12:19200 (192.168.123.12), v6.2.4 @ 192.168.123.11:19200 (192.168.123.11)"}
{"type":"log","@timestamp":"2023-12-15T23:48:48Z","tags":["status","plugin:watcher@6.3.2","info"],"pid":1572,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"This version of Kibana requires Elasticsearch v6.3.2 on all nodes. I found the following incompatible nodes in your cluster: v6.2.4 @ 192.168.123.14:19200 (192.168.123.14), v6.2.4 @ 192.168.123.13:19200 (192.168.123.13), v6.2.4 @ 192.168.123.12:19200 (192.168.123.12), v6.2.4 @ 192.168.123.11:19200 (192.168.123.11)"}
{"type":"log","@timestamp":"2023-12-15T23:48:48Z","tags":["status","plugin:index_management@6.3.2","info"],"pid":1572,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"This version of Kibana requires Elasticsearch v6.3.2 on all nodes. I found the following incompatible nodes in your cluster: v6.2.4 @ 192.168.123.14:19200 (192.168.123.14), v6.2.4 @ 192.168.123.13:19200 (192.168.123.13), v6.2.4 @ 192.168.123.12:19200 (192.168.123.12), v6.2.4 @ 192.168.123.11:19200 (192.168.123.11)"}
{"type":"log","@timestamp":"2023-12-15T23:48:48Z","tags":["status","plugin:graph@6.3.2","info"],"pid":1572,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"This version of Kibana requires Elasticsearch v6.3.2 on all nodes. I found the following incompatible nodes in your cluster: v6.2.4 @ 192.168.123.14:19200 (192.168.123.14), v6.2.4 @ 192.168.123.13:19200 (192.168.123.13), v6.2.4 @ 192.168.123.12:19200 (192.168.123.12), v6.2.4 @ 192.168.123.11:19200 (192.168.123.11)"}
{"type":"log","@timestamp":"2023-12-15T23:48:48Z","tags":["status","plugin:security@6.3.2","info"],"pid":1572,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"This version of Kibana requires Elasticsearch v6.3.2 on all nodes. I found the following incompatible nodes in your cluster: v6.2.4 @ 192.168.123.14:19200 (192.168.123.14), v6.2.4 @ 192.168.123.13:19200 (192.168.123.13), v6.2.4 @ 192.168.123.12:19200 (192.168.123.12), v6.2.4 @ 192.168.123.11:19200 (192.168.123.11)"}
{"type":"log","@timestamp":"2023-12-15T23:48:48Z","tags":["status","plugin:grokdebugger@6.3.2","info"],"pid":1572,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"This version of Kibana requires Elasticsearch v6.3.2 on all nodes. I found the following incompatible nodes in your cluster: v6.2.4 @ 192.168.123.14:19200 (192.168.123.14), v6.2.4 @ 192.168.123.13:19200 (192.168.123.13), v6.2.4 @ 192.168.123.12:19200 (192.168.123.12), v6.2.4 @ 192.168.123.11:19200 (192.168.123.11)"}
{"type":"log","@timestamp":"2023-12-15T23:48:48Z","tags":["status","plugin:logstash@6.3.2","info"],"pid":1572,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"This version of Kibana requires Elasticsearch v6.3.2 on all nodes. I found the following incompatible nodes in your cluster: v6.2.4 @ 192.168.123.14:19200 (192.168.123.14), v6.2.4 @ 192.168.123.13:19200 (192.168.123.13), v6.2.4 @ 192.168.123.12:19200 (192.168.123.12), v6.2.4 @ 192.168.123.11:19200 (192.168.123.11)"}
{"type":"log","@timestamp":"2023-12-15T23:48:48Z","tags":["status","plugin:reporting@6.3.2","info"],"pid":1572,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"This version of Kibana requires Elasticsearch v6.3.2 on all nodes. I found the following incompatible nodes in your cluster: v6.2.4 @ 192.168.123.14:19200 (192.168.123.14), v6.2.4 @ 192.168.123.13:19200 (192.168.123.13), v6.2.4 @ 192.168.123.12:19200 (192.168.123.12), v6.2.4 @ 192.168.123.11:19200 (192.168.123.11)"}
kibana的启动脚本:
cat >/etc/systemd/system/kibana.service <<EOF
[Unit]
Description=Kibana
[Service]
Type=simple
User=kibana
Group=kibana
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
# Prefixing the path with '-' makes it try to load, but if the file doesn't
# exist, it continues onward.
EnvironmentFile=-/etc/default/kibana
EnvironmentFile=-/etc/sysconfig/kibana
ExecStart=/opt/kibana/bin/kibana "-c /opt/kibana/config/kibana.yml"
Restart=always
WorkingDirectory=/
[Install]
WantedBy=multi-user.target
EOF
?###按实际的kibana存放路径和kibana.yml?文件路径填写,这里出于安全考虑使用的是kibana这个普通用户,因此,需要创建该普通用户,并将kibana和kibana日志给予普通用户kibana的权限
[root@centos5 ~]# useradd kibana
[root@centos5 ~]# chown -Rf kibana. /opt/kibana/
[root@centos5 ~]# chown -Rf kibana. /var/log/kibana/
[root@centos5 ~]# systemctl enable kibana
Created symlink from /etc/systemd/system/multi-user.target.wants/kibana.service to /etc/systemd/system/kibana.service.
[root@centos5 ~]# systemctl restart kibana
[root@centos5 ~]# systemctl status kibana
● kibana.service - Kibana
Loaded: loaded (/etc/systemd/system/kibana.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2023-12-16 12:08:47 CST; 5s ago
Main PID: 2191 (node)
CGroup: /system.slice/kibana.service
└─2191 /opt/kibana/bin/../node/bin/node --no-warnings /opt/kibana/bin/../src/cli -c /opt/kibana/config/kibana.yml
Dec 16 12:08:47 centos5 systemd[1]: Started Kibana.
浏览器输入:https://192.168.123.15:15666?
登录界面输入账号elastic,密码123456
报错,kibana版本和elasticsearch版本不匹配
?
解决方案为升级或者迁移elasticsearch集群到6.3.2版本,这里就展开说了,篇幅太长了。?