今天一早DB就过来说,一直在工作的rsync服务没有将中转的数据文件定时上传至服务器上,叫我看下原因。

经检查,原来是做了crontab的rsync无法工作了,找出了故障,紧接着便是解决。

1. 先来确定是否是网络的原因,首先是telnet

[elpayment@epstranslate01 ~]$ telnet 10.123.1.66 873

Trying 10.123.1.66...

Connected to 10.123.1.66.

Escape character is '^]'.

Connection closed by foreign host.

telnet出现了闪退的问题


其实到了这里我就该想到服务被关掉了才对,唉。。。

2.检查rsync服务器的iptables以及selinux

[root@epsapp1 ssh]# iptables -L

Chain INPUT (policy DROP)

target     prot opt source               destination

ACCEPT     all  --  anywhere             anywhere

ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED

ACCEPT     icmp --  anywhere             anywhere            icmp destination-unreachable

ACCEPT     icmp --  anywhere             anywhere            icmp time-exceeded

ACCEPT     icmp --  anywhere             anywhere            icmp echo-reply

ACCEPT     icmp --  anywhere             anywhere            icmp echo-request

ACCEPT     tcp  --  10.123.0.0/16        anywhere            tcp dpt:ssh

ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:webcache

ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:rsync

ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:pcsync-https

REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

Chain FORWARD (policy DROP)

target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination

[root@epsapp1 ssh]# getenforce

Disabled

iptables以及selinux均正常

3. rsync检测

[elpayment@epstranslate01 ~]$ rsync -avz /translog/elcotable/DBM-721_elcas_order_20170304.del [email protected]:/home/elpayment

ssh: connect to host 10.123.1.66 port 22: Connection timed out

rsync: connection unexpectedly closed (0 bytes received so far) [sender]

rsync error: unexplained error (code 255) at io.c(600) [sender=3.0.6]

仍出现错误

4.检查rsync相关的配置以及检查rsync的日志

[root@epsapp1 ssh]# tail -100f /var/log/rsyncd.log

2017/03/03 18:00:00 [8942] connect from UNKNOWN (192.168.1.8)

2017/03/03 18:00:00 [8942] rsync to guiyangKF/ from loguard@unknown (192.168.1.8)

2017/03/03 18:00:00 [8942] receiving file list

2017/03/03 18:00:00 [8942] sent 76 bytes  received 134 bytes  total size 0

2017/03/03 18:35:30 [11286] rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(542) [receiver=3.0.6]

2017/03/06 11:03:05 [18972] rsyncd version 3.0.6 starting, listening on port 873

2017/03/06 11:11:57 [19043] rsync: failed to create pid file /var/run/rsyncd.pid: File exists (17)

2017/03/06 11:11:57 [19043] rsync error: error in file IO (code 11) at clientserver.c(1015) [receiver=3.0.6]

2017/03/06 11:12:08 [19046] rsyncd version 3.0.6 starting, listening on port 873

[root@epsapp1 ssh]# tail -100f /var/log/messages

Mar  6 11:09:45 epsapp1 rsyncd[19022]: rsync: unable to open configuration file "/etc/rsyncd.conf": No such file or directory (2)

Mar  6 11:09:45 epsapp1 rsyncd[19022]: rsync error: syntax or usage error (code 1) at clientserver.c(953) [receiver=3.0.6]

Mar  6 11:09:45 epsapp1 xinetd[2854]: EXIT: rsync status=1 pid=19022 duration=0(sec)

5.结论是:rsync没有正常启动

[root@epsapp1 ssh]# ps -ef|grep rsync

root     19116     1  0 11:15 ?        00:00:00 rsync --daemon --config=/etc/rsyncd.conf

root     19224 18129  0 11:42 pts/1    00:00:00 grep rsync

启动后,rsync传输正常

[elpayment@epstranslate01 ~]$ bash 1-66rsync.sh

sending incremental file list

DBM-721_elcas_order_20170306.del

sent 190816 bytes  received 27 bytes  127228.67 bytes/sec

total size is 986828  speedup is 5.17

sending incremental file list

sent 71 bytes  received 8 bytes  158.00 bytes/sec

total size is 30448786  speedup is 385427.67