我使用dovecot+postfix+mysql配置了邮件服务器,它在服务器(Ubuntu Server)上运行良好。但是在上周,它停止正常工作。它无法发送电子邮件。当我尝试
通过查看
我尝试了
telnet localhost smtp
时,连接成功,但当我执行mail from:<steve@example.com>
并按Enter键时,它卡住了,没有任何反应。通过查看
/var/log/mail.log
文件,我发现问题可能(99%)出在 postfix 尝试连接到 MySQL 服务器时。如果您查看下面给出的日志文件,您会看到它说Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
。Nov 14 21:54:36 ns1 dovecot: dovecot: Killed with signal 15 (by pid=7731 uid=0 code=kill)
Nov 14 21:54:36 ns1 dovecot: Dovecot v1.2.9 starting up (core dumps disabled)
Nov 14 21:54:36 ns1 dovecot: auth-worker(default): mysql: Connected to localhost (mailserver)
Nov 14 21:54:44 ns1 postfix/postfix-script[7753]: refreshing the Postfix mail system
Nov 14 21:54:44 ns1 postfix/master[1670]: reload -- version 2.7.0, configuration /etc/postfix
Nov 14 21:54:52 ns1 postfix/trivial-rewrite[7759]: warning: connect to mysql server localhost: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Nov 14 21:54:52 ns1 postfix/trivial-rewrite[7759]: fatal: mysql:/etc/postfix/mysql-virtual-alias-maps.cf(0,lock|fold_fix): table lookup problem
Nov 14 21:54:53 ns1 postfix/master[1670]: warning: process /usr/lib/postfix/trivial-rewrite pid 7759 exit status 1
Nov 14 21:54:53 ns1 postfix/cleanup[7397]: warning: problem talking to service rewrite: Connection reset by peer
Nov 14 21:54:53 ns1 postfix/master[1670]: warning: /usr/lib/postfix/trivial-rewrite: bad command startup -- throttling
Nov 14 21:54:53 ns1 postfix/smtpd[7071]: warning: problem talking to service rewrite: Success
我尝试了
netstat -ln | grep mysql
,它返回:
unix 2 [ ACC ] STREAM LISTENING 5817 /var/run/mysqld/mysqld.sock
。
/etc/postfix/mysql-virtual-alias-maps.cf
文件的内容在这里:
user = stevejobs
password = apple
hosts = localhost
dbname = mailserver
query = SELECT destination FROM virtual_aliases WHERE source='%s'
这里我试图更改hosts = 127.0.0.1
,但它显示警告:连接到MySQL服务器127.0.0.1失败:无法连接到MySQL服务器'127.0.0.1'(110)
所以,我迷失了方向,不知道还需要在哪里进行更改以解决问题。非常感谢任何帮助。
谢谢。
编辑1
当我执行netstat -na时,我发现mysql既没有绑定到localhost也没有绑定到127.0.0.1。这也可能是问题吗?
bakhtiyor@ns1:~$ netstat -na | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN