| Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-02-2012, 09:14 PM
|
#1
|
|
Member
Registered: Aug 2002
Location: Alexandria
Distribution: ubuntu 12.04.2
Posts: 217
Rep:
|
postfix not working with mysql socket but with localhost
After looking through the various threads that are similar to this, it seems that this one is unique.
I've configured postfix to use mysql as it's source of aliases. Needless to say, everything works when I use localhost as the hosts:
Code:
hosts = 127.0.0.1
user = postfix_user
password = somepassword
dbname = postfix_db
query = SELECT goto FROM alias WHERE address='%s' AND active=1
However, when I change hosts to be:
Code:
hosts = unix:/var/run/mysqld/mysqld.sock
everything stops working:
Code:
May 2 21:23:47 helo postfix/trivial-rewrite[11776]: warning: connect to mysql server unix:/var/run/mysqld/mysqld.sock: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
May 2 21:23:47 helo postfix/trivial-rewrite[11776]: fatal: mysql:/etc/postfix/virtual/domains.cf(0,lock|fold_fix): table lookup problem
May 2 21:23:48 helo postfix/master[9880]: warning: process /usr/lib/postfix/trivial-rewrite pid 11776 exit status 1
The socket is set to 777 and I am able to successfully use mysql via:
Code:
mysql -u postfix_user -p --socket=/var/run/mysqld/mysqld.sock
What's going on that postfix can't use the socket by the mysql client can?
|
|
|
|
05-03-2012, 12:28 PM
|
#2
|
|
Senior Member
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,046
|
A couple of things to check:
1 - in your domains.cf file, if you have any spaces at the end of the line following the text, delete them. This will cause a failure.
2 - Is either SELinux or Apparmor preventing access to the pid file? (Check your logs)
3 - when you restart or reload Postfix, do you get any warning or error messages in your mail log or syslog that could point to a problem?
|
|
|
|
05-03-2012, 04:24 PM
|
#3
|
|
Member
Registered: Aug 2002
Location: Alexandria
Distribution: ubuntu 12.04.2
Posts: 217
Original Poster
Rep:
|
Quote:
Originally Posted by Noway2
A couple of things to check:
1 - in your domains.cf file, if you have any spaces at the end of the line following the text, delete them. This will cause a failure.
2 - Is either SELinux or Apparmor preventing access to the pid file? (Check your logs)
3 - when you restart or reload Postfix, do you get any warning or error messages in your mail log or syslog that could point to a problem?
|
Answer to 1:
domains.cf is also a mysql table. I have virtualized both files; however, they both work with 127.0.0.1 but not with the socket.
2:
I thought I removed all instances of SELinux. I've never heard of apparmor. I did a dpkg -get-selections for both and did not find them installed.
3:
No, nothing that indicates the files failed to load. I only get the messages when an e-mail comes in.
Interestingly, I left aliases to use the MYSQL the socket and the domain to still use 127.0.0.1. Aliases work but domains do not.
Is this a limitation on postfix that it can't use sockets when retrieving domain names?
Last edited by sohmc; 05-03-2012 at 04:26 PM.
Reason: grammar errors.
|
|
|
|
05-04-2012, 04:27 AM
|
#4
|
|
Senior Member
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,046
|
You should be able to use MySQL for all of the lookups, alias, domain, etc. Looking through the postfix manuals, I found this interesting statement that I think may be related to the problem ( link here. Pay particular attention to the note at the bottom)
Quote:
hosts The hosts that Postfix will try to connect to and
query from. Specify unix: for UNIX domain sockets,
inet: for TCP connections (default). Example:
hosts = host1.some.domain host2.some.domain : port
hosts = unix:/file/name
The hosts are tried in random order, with all con-
nections over UNIX domain sockets being tried
before those over TCP. The connections are auto-
matically closed after being idle for about 1
minute, and are re-opened as necessary. Postfix
versions 2.0 and earlier do not randomize the host
order.
NOTE: if you specify localhost as a hostname even
if you prefix it with inet:, MySQL will connect to
the default UNIX domain socket. In order to
instruct MySQL to connect to localhost over TCP you
have to specify
hosts = 127.0.0.1
|
A few more things to check:
1 - check the bind address on which mysql is running and make sure that this hasn't been blocked in a firewall somewhere. This may be why localhost is working, but othe connections are not. The fact that you can connect to mysql via the socket, but postfix can't suggests this probably isn't the problem, but it is worth double checking.
2 - Check your configuration file again. Look very carefully for any form of sytax error, such as a ' versus `, especially if you copied from any how to document.
3 - If you haven't be sure to check your mySQL logs. There may be information as to the problem in there.
This seems to be a semi common problem, but has a few different causes. You might try to Google on the error message "fatal: mysql:/etc/postfix/virtual/domains.cf(0,lock|fold_fix):". Here are a few hits from that with different causes:
1) http://www.howtoforge.com/forums/arc...p/t-53917.html
2) http://www.howtoforge.com/forums/arc...p/t-45905.html
3) http://askubuntu.com/questions/79226...ld-mysqld-sock
4) http://askubuntu.com/questions/69380...it/69450#69450
|
|
|
|
05-07-2012, 05:34 PM
|
#5
|
|
Member
Registered: Aug 2002
Location: Alexandria
Distribution: ubuntu 12.04.2
Posts: 217
Original Poster
Rep:
|
Quote:
Originally Posted by Noway2
A few more things to check:
1 - check the bind address on which mysql is running and make sure that this hasn't been blocked in a firewall somewhere. This may be why localhost is working, but othe connections are not. The fact that you can connect to mysql via the socket, but postfix can't suggests this probably isn't the problem, but it is worth double checking.
2 - Check your configuration file again. Look very carefully for any form of sytax error, such as a ' versus `, especially if you copied from any how to document.
3 - If you haven't be sure to check your mySQL logs. There may be information as to the problem in there.
|
The thing that doesn't make sense is that only thing I'm changing is the hosts line. It works fine when I do "127.0.0.1" The problem only arises when I change it to the socket.
Keep in mind that the socket works fine for the aliases file.
Quote:
Originally Posted by Noway2
|
I've goggled the error and haven't gotten very good results. A lot of the solutions cover how to get the socket working (which it is) to making sure that the inet portion works on 127.0.0.1 instead of localhost.
It's just so odd that it works for one type of file but not the other. Here's a diff of the two files:
Code:
root@helo:/etc/postfix/virtual# diff aliases.cf domains.cf
1,2c1,2
< hosts = unix:/var/run/mysqld/mysqld.sock
< #hosts = 127.0.0.1
---
> #hosts = unix:/var/run/mysqld/mysqld.sock
> hosts = 127.0.0.1
7c7
< query = SELECT goto FROM alias WHERE address='%s' AND active=1
---
> query = SELECT domain FROM domain WHERE domain='%s' AND backupmx=0 AND active=1
I'm to the point of actually e-mailing the postfix list serve but wanted to see if anyone else had the same issue. it seems like my issue is very specific.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 10:07 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|