Postfix kann DB nicht finden

Postfix, QMail, Sendmail, Dovecot, Cyrus, Courier, Anti-Spam
matbehns
Posts: 95
Joined: 2004-01-28 14:00
Location: Berlin

Postfix kann DB nicht finden

Post by matbehns » 2004-08-19 16:31

Hallo,

habe mich an das HowTo von

http://www.workaround.org/articles/ispm ... #id2493380

gehalten, um mir Postfix zu installieren.

Dazu habe ich das skip-networking aktiviert und einen postfix user in der MySQL angelegt mit diesen Rechten:

In der Tabelle user:

Code: Select all

user: postfix
host: loclahost
permissions: none
In der Tabelle db:

Code: Select all

database: postfix
user: postfix
hosts: localhost
permissions: Select | Insert | Update | Delete | Create | Drop | References | Index | Alter
Dennoch steht in der /var/log/mail.log immer, dass der mysql nicht erreicht werden kann. Hier ein Auszug:

Code: Select all

Aug 19 14:25:48 m17s5 postfix/master[13400]: warning: process /usr/lib/postfix/trivial-rewrite pid 12192 exit status 1
Aug 19 14:25:48 m17s5 postfix/master[13400]: warning: /usr/lib/postfix/trivial-rewrite: bad command startup -- throttling
Aug 19 14:26:48 m17s5 postfix/trivial-rewrite[12217]: warning: connect to mysql server localhost: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Aug 19 14:26:48 m17s5 postfix/trivial-rewrite[12217]: fatal: transport table lookup problem
Aug 19 14:26:49 m17s5 postfix/master[13400]: warning: process /usr/lib/postfix/trivial-rewrite pid 12217 exit status 1
Aug 19 14:26:49 m17s5 postfix/master[13400]: warning: /usr/lib/postfix/trivial-rewrite: bad command startup -- throttling
Aug 19 14:27:49 m17s5 postfix/trivial-rewrite[12265]: warning: connect to mysql server localhost: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Aug 19 14:27:49 m17s5 postfix/trivial-rewrite[12265]: fatal: transport table lookup problem
Aug 19 14:27:50 m17s5 postfix/master[13400]: warning: process /usr/lib/postfix/trivial-rewrite pid 12265 exit status 1
Aug 19 14:27:50 m17s5 postfix/master[13400]: warning: /usr/lib/postfix/trivial-rewrite: bad command startup -- throttling
kann mir vielleicht jemand sagen warum? Ich verstehe es einfach nicht!

Danke, Mat

squize
Userprojekt
Userprojekt
Posts: 741
Joined: 2003-05-19 16:46
Location: Karlsruhe

Re: Postfix kann DB nicht finden

Post by squize » 2004-08-19 16:44

Wahrscheinlich wird es darin liegen, dass postfix im chroot läuft und deswegen keinen Zugriff auf das mysql socket hat.

hier mal eine Lösung:
First, you have to configure postfix to connect to mysql database which is installed via phpmywebhosting.

First of all an important note (thanks to Ulrich Hammer). Remember that Postfix runs in a chroot environment. Thus it would not be able to access MySQL's socket file at /var/run/mysqld/mysqld.sock. There are two ways to work around this:
Mario Duve (et al) propose an addition to the start section of /etc/init.d/postfix like this:

if [ -e /var/spool/postfix/var/run/mysqld/mysqld.sock ]; then
rm /var/spool/postfix/var/run/mysqld/mysqld.sock
fi

mkdir -p /var/spool/postfix/var/run/mysqld
chown mysql /var/spool/postfix/var/run/mysqld
ln /var/run/mysqld/mysqld.sock /var/spool/postfix/var/run/mysqld/mysqld.sock


In case of power failure postfix won't start working because the socket of mysql is not valid. To prevent this edit /etc/init.d/postfix and add the above lines in the start section under echo -n "Starting mail transport agent: Postfix". Result is:

case "$1" in
start)
echo -n "Starting mail transport agent: Postfix"
if [ -e /var/spool/postfix/var/run/mysqld/mysqld.sock ]; then
rm /var/spool/postfix/var/run/mysqld/mysqld.sock
fi
mkdir -p /var/spool/postfix/var/run/mysqld
chown mysql /var/spool/postfix/var/run/mysqld
ln /var/run/mysqld/mysqld.sock /var/spool/postfix/var/run/mysqld/mysqld.sock

# see if anything is running chrooted.
[...]


Also take care, that postfix is started after mysql. Check it with the following command:

bash #> ls /etc/rc$(grep initdefault /etc/inittab | cut -d: -f2).d/ | grep -E "(postfix|mysql)"
S20mysql
S20postfix
bash #>


If it is like above, everything is alright. If not, delete the links in /etc/rc{runlevel}.d/ and create them new.
Gruss

Marc