一、背景
用户访问量大,导致kibana使用卡顿,严重时无法登录
二、解决方法
访问kibana前增加一个nginx负载均衡,新增一个kibana(原本一个)
1、安装nginx
(1)解压
tar -zxvf nginx-1.21.1.tar.gz -C ./
(2)安装
make && make install
2、修改nginx.conf配置(负载均衡策略选择ip_hash)
user dy users;
worker_processes 16;
error_log logs/error.log;
pid logs/nginx.pid;
events {
worker_connections 10240;
}
http {
include mime.types;
default_type application/octet-stream;
log_format test escape=json '$remote_addr - $remote_user [$time_local] "$request" "$request_body" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format main escape=json '$remote_addr - $remote_user - [$time_local] - "$request" - "$request_body" - '
'$status - $request_time - $upstream_response_time - $body_bytes_sent - $request_method - "$http_x_forwarded_for"';
log_format test2 '$query_string';
access_log logs/access.log main;
client_max_body_size 20m;
sendfile on;
keepalive_timeout 65;
vhost_traffic_status_zone;
vhost_traffic_status_filter_by_host on;
upstream kibana {
ip_hash;
server kibana_ip1:5601;
server kibana_ip2:5601;
}
server {
listen 5601;
listen [::]:5601;
location / {
proxy_pass http://kibana;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
proxy_read_timeout 180s;
proxy_connect_timeout 180s;
}
}
}
二、根据具体用户进行校验,分配到具体kibana
增加请求分流接口,根据用户名选择重定向得kibana
Kibana请求登录接口