Distributed Qmail system storage

Source: Internet
Author: User
Tags mx record qmail
Article Title: distributed Qmail storage. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

I. design purpose

It is suitable for multi-user and large-capacity mail systems and is easy to expand. It provides the mail service redundancy feature.

2. Configure the environment

My test environment uses three PC servers, both use RedHat 6.2, openldap2.0.7, qmail-1.03 and qmail-ldap, respectively run the smtp/pop3 Service, the specific configuration is as follows.

192.168.0.19 omni1.i100.com.cn master smtp/pop3 server, dns MX record, mail storage host, qmqp server 192.168.0.5 cocoon.i100.com.cn LDAP server, mail storage host 192.168.0.2 gw2.i100.com.cn mail storage host, qmqp server, at the same time, the smtp/pop3 server stores johnny emails in the/data/vuser/directory of 192.168.0.19. Store jacky emails in the/data/vuser/directory of 192.168.0.5. Store denny emails in the/var/qmail/vuser/directory of 192.168.0.2. In practice, you can configure mail storage, ldap, and smtp server on different machines.

3. Software openldap-2.0.7.tgz

Qmail-1.03.tar.gz
Qmail-ldap-1.03-20010301.patch

Ucspi-tcp-0.84.tar.gz

When compiling qmail, remember to compile the support for cluster. Edit the Makefile to reflect your setup. you can change the following values: QLDAP-CLUSTER Compiles the clustering code in. note: this doesn't mean clustering is on, it just means you _ can _ turn on clustering. qmail supports the cluster structure.

Iv. Installation of LDAP and qmail

For the installation of LDAP and qmail, here I will provide my LDAP ldif file: dn: dc = i100, dc = com, dc = cn

Objectclass: top

Objectclass: orgnization

 

Dn: cn = Manager, dc = i100, dc = com, dc = cn

Uid: Manager

Objectclass: qmailUser

Mail: johnnys@cn.solution100.com

 

Dn: cn = johnny, dc = i100, dc = com, dc = cn

Cn: johnny

Sn: johnny

Objectclass: top
Objectclass: person

Objectclass: inetOrgPerson

Objectclass: qmailUser

Mail: johnny@i100.com.cn

Mailhost: omni1.i100.com.cn

Mailalternateaddress: johnnys@i100.com.cn

Mailmessagestore:/data/vuser/johnny/

Mailquota: 51200

Uid: johnny

Userpassword: hSAMdaZcsdAOI

 

Dn: cn = jacky, dc = i100, dc = com, dc = cn

Cn: jacky

Sn: jacky

Objectclass: top

Objectclass: person

Objectclass: inetOrgPerson

Objectclass: qmailUser

Mail: jacky@i100.com.cn

Mailhost: cocoon.i100.com.cn

Mailalternateaddress: jacky@i100.com.cn

Mailmessagestore:/data/vuser/jacky/

Mailquota: 51200

Uid: jacky

Userpassword: hSAMdaZcsdAOI

 

Dn: cn = denny, dc = i100, dc = com, dc = cn
Cn: denny

Sn: denny

Objectclass: top

Objectclass: person

Objectclass: inetOrgPerson

Objectclass: qmailUser

Mail: denny@i100.com.cn

Mailhost: gw2.i100.com.cn

Mailalternateaddress: denny@i100.com.cn

Mailmessagestore:/var/qmail/vuser/denny/

Mailquota: 51200

Uid: denny

Userpassword: hSAMdaZcsdAOI and above, we can see that I have stored the emails of the three users on different machines. If there are many users, users starting with a-n and o-z can be stored on different machines.

5. Basic System Configuration
Install qmail with qmail-ldap patch on the three machines respectively. Files under/var/qmail/control must be configured in particular. Ldapuid ldapgid is the uid and gid of the system users who can read and write users' mail directories. Different configurations are available on different machines. Ensure that the user has the permission to read and write users' mail contents. Ldapserver this file specifies the IP address of the LDAP server. If you want to enable ldap server redundancy when the master LDAP server is down, you can specify this file.

For example, ldap1.i100.com.cn: 389 ldap2.i100.com.cn: 389 :) the content of ldapserver is 0 or 1, indicating whether the qmail cluster mode is enabled. Of course we have to start it. Echo 1>/var/qmail/control/ldapserver

Vi. Working Principles of Qmail Cluster

In the mail environment that allows the cluster, each host can process the mails of the domain declared by the cluster. When a mail arrives at the primary smtp server, qmail queries the user's mailhost attribute in LDAP server. If the mailhost attribute is not the host defined in/var/qmail/control/me of this server, this email is forwarded to the host defined by mailhost through qmqp.

Note: All host names must be valid dns host names.

VII. Detailed Configuration

To forward emails, run the qmail-qmqpd process on each system that runs qmail. Tcp. qmqp needs to be set

File, which defines trusted mailhost. For example: 192.168.0.: allow: deny and uses tcprules to generate the tcp. qmqp. cdb file. Run/usr/local/bin/tcpserver-v-x/var/qmail/control/tcp. qmqp. cdb-u 502-g 501 0 628/var/qmail/bin/qmail-qmqpd 2> & 1 |/var/qmail/bin/splogger qmqpd & start the qmail-qmqpd process, the listener is at port 628. On the client, use oe to set the pop3 server as the master smtp/pop3 server address (192.168.0.19), and then you can receive emails from users stored on 192.168.0.5 and 192.168.0.2. :)

8. qmail-qmqpd server

The above implements the distributed storage of mail, but with the increase of users, the main smtp/pop3 server will become the bottleneck of the entire system; and once the master smtp/pop3 server is down, the entire system will no longer be valid.

The solution is to add the qmqpd server.

Currently, the master smtp/pop3 server is 192.168.0.19. In my test environment, 192.168.0.2 is used as the qmqpd server at the same time. As a result, 192.168.0.19 can continue to provide smtp/pop3 services once it is down. I simply drop 192.168.0.19 and set pop3 and smtp server to 192.168.0.2 to verify the feasibility of this method. 192.168.0.2 is not the MX record declared by this domain. Add the qmqpservers file in the/var/qmail/control directory of the two qmqpd servers, and write the IP address of a qmqpd server in each row. :)

9. Miscellaneous

If you need the webmail function, you can integrate it with sqwebmail. This solution does not provide redundancy measures for pop3 storage. If possible, you can use Raid, NFS, or SAN solutions.


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.