点击测试连接一段时间后直接跳转到登录页面
原因是IP地址不对,连接超时,直接跳转到登录页面是因为nginx设置的超时时间小于连接超时时间,会话失效直接条状到登录页面
通过打印日志可以看出连接时间为128秒,将nginx超时时间(proxy_read_timeout)调大,则正常显示数据源建立失败错
[dolphinscheduler@host1 logs]$ grep ping dolphinscheduler-api.log
[INFO] 2021-12-27 17:04:27.066 org.apache.dolphinscheduler.api.utils.DataSourceUtils:[53] - ping time:128 s
[dolphinscheduler@host1 logs]$ sudo vi /usr/local/nginx/conf/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server {
listen 10000;
server_name localhost;
location / {
root /home/dolphinscheduler/app/dolphinscheduler/ui;
index index.html index.htm;
}
location /dolphinscheduler/ui {
root /home/dolphinscheduler/app;
index index.html index.htm;
}
location /dolphinscheduler {
proxy_pass http://192.168.56.10:12345; # 接口地址(自行修改)
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header x_real_ipP $remote_addr;
proxy_set_header remote_addr $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_connect_timeout 4s;
proxy_read_timeout 200s;
proxy_send_timeout 12s;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
client_max_body_size 1000m;
}
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
sudo /usr/local/nginx/sbin/nginx -s stop
[dolphinscheduler@host1 logs]$ sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
再次测试(测试、编辑、创建均可测试)
心累历程:
nginx默认设置的是30秒,后来改成60秒,100秒,均会跳转到登录页,于是放弃nginx配置,准备在jdbc连接之前先通过Java执行Linux命令,看能否ping通,结果就因为看日志,时长128秒,才恍然大悟,之前配置设置的时间还是小了…
但是弯路也没白走,虽然设置超时时间可以解决,但是等待的时间太长,等了两分钟才提示建立连接失败,因此也可以优化,比如超过20秒就判定为网络不通。经过本地测试,正常情况下,一次连接也就10秒左右,生产上肯定更快。点我走弯路