xiaokai-wang / nginx-stream-upsync-module

For stream protocol. syncing upstreams from etcd or consul and so on, dynamically updating backend servers attribute, not need to reload nginx for tcp protocol, stream configure.
175 stars 48 forks source link

采用etcd, 然后按配置搞完出现如下错误,求解? #27

Closed 527593036 closed 6 years ago

527593036 commented 6 years ago

nginx error.log报错信息如下: 2018/01/21 19:16:55 [error] 31764#0: upsync_timeout: timed out reading upsync_server: 10.10.75.150:2379

求解决方案?

0、环境: nginx-1.12.2, etcd: 3.2.1

1、场景: k8s的master ssl 6433端口代理

2、配置配置文件如下: upstream k8s_master_apiserver { hash $remote_addr consistent;

server 10.10.75.150:6443 max_fails=3 fail_timeout=30s weight=2;

# server 10.10.75.151:6443 max_fails=3 fail_timeout=30s weight=2;
# server 10.10.75.153:6443 max_fails=3 fail_timeout=30s `weight=2;`
upsync 10.10.75.150:2379/v2/keys/upstreams/k8s_master_apiserver upsync_timeout=6m upsync_interval=500ms upsync_type=etcd strong_dependency=off;
upsync_dump_path /usr/local/nginx/conf/tcp_udp_vhosts/A-tcp-udp-upstream.conf;
# include /usr/local/nginx/conf/tcp_udp_vhosts/A-tcp-udp-upstream.conf;

}

server { listen 6443; access_log /usr/local/nginx/logs/k8s.master.6443-access.log proxy; error_log /usr/local/nginx/logs/k8s.master.6443-error.log; proxy_connect_timeout 30s; proxy_timeout 30s; proxy_pass k8s_master_apiserver; proxy_next_upstream on; }

3、配置测试,提示no servers错误: /usr/local/nginx/sbin/nginx -t nginx: [emerg] no servers are inside upstream in /usr/local/nginx-1.12.2/conf/tcp_udp_vhosts/k8s_master_proxy.conf:10 nginx: configuration file /usr/local/nginx-1.12.2/conf/nginx.conf test failed

4、upsync_dump_path对应的文件为空 total 8.0K drwx------ 2 root root 66 Jan 21 16:16 . drwx------ 4 root root 4.0K Jan 21 15:38 .. -rw-r--rw- 1 root root 0 Jan 21 16:05 A-tcp-udp-upstream.conf -rw------- 1 root root 868 Jan 21 16:16 k8s_master_proxy.conf

5、etcd集群的设置如下: curl -s http://10.10.75.150:2379/v2/keys/upstreams/k8s_master_apiserver | python -m json.tool { "action": "get", "node": { "createdIndex": 53, "dir": true, "key": "/upstreams/k8s_master_apiserver", "modifiedIndex": 53, "nodes": [ { "createdIndex": 53, "key": "/upstreams/k8s_master_apiserver/10.10.75.153:6443", "modifiedIndex": 53, "value": "{\"weight\":1, \"max_fails\":2, \"fail_timeout\":10}" }, { "createdIndex": 54, "key": "/upstreams/k8s_master_apiserver/10.10.75.150:6443", "modifiedIndex": 54, "value": "{\"weight\":1, \"max_fails\":2, \"fail_timeout\":10}" }, { "createdIndex": 55, "key": "/upstreams/k8s_master_apiserver/10.10.75.151:6443", "modifiedIndex": 55, "value": "{\"weight\":1, \"max_fails\":2, \"fail_timeout\":10}" } ] } }