安装Kibana
https://www.elastic.co/guide/en/kibana/current/index.html
创建kibana.repo
$ sudo vim/etc/yum.repos.d/kibana.repo
[kibana-4.4]
name=Kibana repository for 4.4.x packages
baseurl=http://packages.elastic.co/kibana/4.4/centos
gpgcheck=1
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1
使用yum install安装kibana
$ sudo yum -y install kibana
注:
1、Kibana默认端口为5601
2、kibana默认安装在/opt/kibana目录下
3、Kibana配置文件路径为/opt/kibana/config/kibana.yml
$ rpm -qc kibana
/opt/kibana/config/kibana.yml
修改kibana配置
$ sudo vim /opt/kibana/config/kibana.yml
server.host: "192.168.0.228"
elasticsearch.url: "http://192.168.0.228:9200"
启动kibana并添加为开机自启动服务
$ sudo systemctl start kibana
$ sudo chkconfig kibana on
安装Nginx(此部分内容不是必须)
由于elasticsearch、kibana自身均没有提供访问权限安全问题,这里使用nginx代理来验证用户身份。
$ sudo yum -y install epel-release
$ sudo yum -y install nginx httpd-tools
创建用户并设定密码
$ sudo htpasswd -c /etc/nginx/htpasswd.users kibanaadmin #创建kibanaadmin用户
注:
这里创建的用户为kibanaadmin/kibanaadmin(用户密码均为kibanaadmin)
修改/etc/nginx/nginx.conf
$ sudo vim /etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent""$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
}
创建/etc/nginx/conf.d/kibana.conf文件
sudo vim /etc/nginx/conf.d/kibana.conf
server {
listen 80;
server_name 192.168.0.228;
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/htpasswd.users;
location / {
proxy_pass http://192.168.0.228:5601;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
注:
1、以上配置使用http basic认证用户身份。
2、使用nginx反向代理到kibana所在服务器(http://192.168.0.228:5601)
为了使上述配置生效并能成功代理,需做如下操作
$ sudo setsebool -P httpd_can_network_connect 1
至此,访问nginx时则会要求输入用户名密码(kibanaadmin/kibanaadmin)。输入正确后请求会请求代理到kibana
启动nginx并添加到开启自启动服务
$ sudo systemctl start nginx
$ sudo systemctl enable nginx