分布式下载系统上的Autossh绑定错误

时间:2018-11-29 09:11:10

标签: autossh

我已经建立了一个分布式系统,其中有多个运行在数字海洋小滴上的spring boot下载程序,这些小滴通过autossh隧道连接到数据库,如下所述,以连接到mysql数据库。

autossh -M 20000 -f root@xx.xx.xx.xx -L 3308:127.0.0.1:3306 -f -C -q -N

我在auth.log中收到以下消息,其中包含一些错误,包括错误:绑定:地址已在使用中和错误:channel_setup_fwd_listener_tcpip:无法收听端口:20000

Nov 29 08:38:40 SERVER sshd[17748]: Accepted publickey for root from xxx.xxx.xxx.xxx port 41078 ssh2: RSA ---------------------------------
Nov 29 08:38:40 SERVER sshd[17748]: pam_unix(sshd:session): session opened for user root by (uid=0)
Nov 29 08:38:40 SERVER systemd-logind[1339]: New session 2529 of user root.
Nov 29 08:38:40 SERVER sshd[17209]: Received disconnect from xxx.xxx.xxx.88 port 47188:11: disconnected by user
Nov 29 08:38:40 SERVER sshd[17209]: Disconnected from xxx.xxx.xxx.88 port 47188
Nov 29 08:38:40 SERVER sshd[17209]: pam_unix(sshd:session): session closed for user root
Nov 29 08:38:40 SERVER sshd[17713]: error: bind: Address already in use
Nov 29 08:38:40 SERVER sshd[17713]: error: channel_setup_fwd_listener_tcpip: cannot listen to port: 20000
Nov 29 08:38:40 SERVER systemd-logind[1339]: Removed session 2511.
Nov 29 08:38:40 SERVER sshd[17770]: Accepted publickey for root from xxx.xxx.xxx.88 port 47212 ssh2: RSA ---------------------------------
Nov 29 08:38:40 SERVER sshd[17770]: pam_unix(sshd:session): session opened for user root by (uid=0)
Nov 29 08:38:40 SERVER systemd-logind[1339]: New session 2530 of user root.
Nov 29 08:38:40 SERVER sshd[17748]: error: bind: Address already in use
Nov 29 08:38:40 SERVER sshd[17748]: error: channel_setup_fwd_listener_tcpip: cannot listen to port: 20000
Nov 29 08:38:40 SERVER sshd[17770]: error: bind: Address already in use
Nov 29 08:38:40 SERVER sshd[17770]: error: channel_setup_fwd_listener_tcpip: cannot listen to port: 20000
Nov 29 08:38:41 SERVER sshd[17270]: Received disconnect from xxx.xxx.xxx.101 port 3xxx16:11: disconnected by user
Nov 29 08:38:41 SERVER sshd[17270]: Disconnected from xxx.xxx.xxx.101 port 310816
Nov 29 08:38:41 SERVER sshd[17270]: pam_unix(sshd:session): session closed for user root
Nov 29 08:38:41 SERVER systemd-logind[1339]: Removed session 2512.
Nov 29 08:38:42 SERVER sshd[17824]: Accepted publickey for root from xxx.xxx.xxx.xxx port 3xxx56 ssh2: RSA ---------------------------------
Nov 29 08:38:42 SERVER sshd[17824]: pam_unix(sshd:session): session opened for user root by (uid=0)
Nov 29 08:38:42 SERVER systemd-logind[1339]: New session 2531 of user root.
Nov 29 08:38:42 SERVER sshd[17824]: error: bind: Address already in use
Nov 29 08:38:42 SERVER sshd[17824]: error: channel_setup_fwd_listener_tcpip: cannot listen to port: 20000
Nov 29 08:38:45 SERVER sshd[17306]: Received disconnect from xxx.xxx.xxx.xxx port 38672:11: disconnected by user
Nov 29 08:38:45 SERVER sshd[17306]: Disconnected from xxx.xxx.xxx.108 port 38672
Nov 29 08:38:45 SERVER sshd[17306]: pam_unix(sshd:session): session closed for user root
Nov 29 08:38:45 SERVER systemd-logind[1339]: Removed session 2513.
Nov 29 08:38:46 SERVER sshd[17860]: Accepted publickey for root from xxx.xxx.xxx.108 port 3xxx02 ssh2: RSA ---------------------------------
Nov 29 08:38:46 SERVER sshd[17860]: pam_unix(sshd:session): session opened for user root by (uid=0)
Nov 29 08:38:46 SERVER systemd-logind[1339]: New session 2532 of user root.
Nov 29 08:38:46 SERVER sshd[17860]: error: bind: Address already in use
Nov 29 08:38:46 SERVER sshd[17860]: error: channel_setup_fwd_listener_tcpip: cannot listen to port: 20000
Nov 29 08:40:01 SERVER CRON[17896]: pam_unix(cron:session): session opened for user root by (uid=0)
Nov 29 08:40:01 SERVER CRON[17896]: pam_unix(cron:session): session closed for user root
Nov 29 08:40:57 SERVER sshd[17347]: Received disconnect from xxx.xxx.42.10 port 37970:11: disconnected by user
Nov 29 08:40:57 SERVER sshd[17347]: Disconnected from xxx.xxx.42.10 port 37970
Nov 29 08:40:57 SERVER sshd[17347]: pam_unix(sshd:session): session closed for user root
Nov 29 08:40:57 SERVER systemd-logind[1339]: Removed session 2515.
Nov 29 08:40:57 SERVER sshd[17900]: Accepted publickey for root from xxx.xxx.xxx.xxx port 38022 ssh2: RSA ---------------------------------
Nov 29 08:40:57 SERVER sshd[17900]: pam_unix(sshd:session): session opened for user root by (uid=0)
Nov 29 08:40:57 SERVER systemd-logind[1339]: New session 2534 of user root.
Nov 29 08:42:01 SERVER CRON[17935]: pam_unix(cron:session): session opened for user root 

请让我知道您对于为什么会出现此问题的想法。

问候 继续

1 个答案:

答案 0 :(得分:0)

我在autossh documentation中发现了

  

-M端口[:echo_port]

     

指定要使用的基本监视端口。没有回音端口,这   端口及其正上方的端口(端口+1)应该是   没有其他使用。 autossh将在基础上发送测试数据   监视端口,然后将其接收回上面的端口。例如,   如果指定“ -M 20000”,则autossh将设置转发,以便可以   在端口20000上发送数据,然后在20001上接收数据。

因此,我不得不添加代码,以针对每个启动的下载器将-M增加2。