Courier Mail Server Domain Name Change

xiaoxiao2021-03-06  146

Courier is an open source Mail Server, which is used in our platform. For his upgrade process, you share a share, please indicate the source.

Description: [xxx @ xxxx] # indicates the command in the Linux command line, @, for the host name or host ipshell> Indicates the command shell @ xxxx in the Linux command line, indicating the command in the Linux command, @ is Hostname or host ipmysql> Indicates the execution mysql: maildb> in the mysql environment. In the mysql environment, select the MAILDB database after executing

1. After the first experiment of 192.168.100.11, the actual operating environment of the Email update operation is for the actual environment of the XXX network, do the following Email domain update:

2. Log in to Proxy with SecureCrt 4.0, log in from the machine (2.1). Log in to the Email server, open two windows, a mysql, another shellshell @ proxy> ssh root @ coierShell @ coot @ co Porter @ Courier> / usr / lib / channel / mysqldb / bin / mysql -p3309 -s / usr / lib / court / mysqldb / var / mysql.sock -udba -pwebmailmysql> USE MAILDB; mysql: maildb>

(2.2). Log in to the web server shell @ proxy> ssh root @ Web [root @ web root] #

3. In the MISQL window (3.1) on the Mail server. Take the domain name of HOME Mysql: MAildb> SELECT COUNT (Home), LOWER (Home, Locate ('@ ', home) 1)) Domain from passwd group by Lower (Substring (Home, Locate (' @ ', home) 1)); ------------- - --------------- ------------------ | Count (home) | Domain | Change | ---- --------- ------------------------------------ | 3407 | s01.test.net | S01.Test.com.cn || 587 | Demo.test.net | demo.test.com.cn || 1844 | s02.test.net | S02.Test.com.cn || 2105 | S03.Test.net | S03.Test.com.cn || 3 | Test.Test.net | Test.test.com.cn || 1 | New1.Test.com.cn | new1.test.com. CN || 1 | new2.test.com.cn | new2.test.com.cn | ------------------------------------------------------------ ---- ------------------ 7 ROWS IN SET (0.21 sec)

(3.2). Where new1.test.com.cn, new2.test.com does not change

(3.3). Statistical Var directory SHELL @ Courier> CD / var data is shell @ coIr> Find mail? -Name "* @ *" -type d -maxdepth 1 | WC -L results 7944 (3.4 ). Counting the Mail directory of each domain name, see the top table shell @ coier> Find mail? -Name "*@s01.test.com.cn" -type d -maxdepth 1 | wc -lshell @ coier> find mail? -Name "*@demo.test.com.cn" -type d -maxdepth 1 | wc -lshell @ coier> Find mail? -name "*@s02.test.com.cn" -type d -maxdepth 1 | WC -lshell @ coier> Find mail? -name "*@s03.test.com.cn" -type d -maxdepth 1 | wc -lshell @ coier> Find mail? -name "*@test.test.com" -type d -maxdepth 1 | wc -lshell @ coier> Find mail? -name "*@new1.test.com.cn" -type d -maxdepth 1 | wc -lshell @ coier> Find mail? -name "* @ NEW2.TEST.COM.CN "-type d -maxdepth 1 | wc -l

4. Preparation before upgrading (4.1). Before the actual changes, first stop Courier service shell @ coier> / usr / lib / channel / scripts / mscntl stop

(4.2). In order to prevent the occurrence of creating users in the operation, turn off the function of creation with Mail in the web service. Of course, it is best to turn off the web server if the two units use the same domain name, and two units You can exist the same name, it may cause the user's mail, which is the same as two users, which is not suitable, so please do not use the official unit of the MAIL domain when establishing the unit of the test. .

(4.3). For formal units, you must use different MAIL suffixes.

(4.4). Determine the script location: / home / channelier

(4.5). Determine the order of change and write scripts ---------------------------------------------------------------------------------------------------------------------------------- | Domain1 | Change to | -------------------------------------- | S01.Test.Net] | S01.Test.com.cn || [demo.test.net] | demo.test.com.cn || [S02.Test.Net] | S02.Test.com.cn || [s03.test.net] | S03.Test.com.cn || [Test.Test.Net] | Test.test.com.cn | ---------------- ---- ------------------

(4.6). Change DNS, new domain and set MX records, delete old DNS

(4.7). Unify more domain name

5. Unified Change Domain Name Change the HostDomains file, add new domain suffixes, and remove the old domain name, execute / usr / lib / coier / share / makehostdomainsshell @ Courier> vi / usr / lib / channel / etc / hostedDomains modified S01 .Test.net Modify demo.test.net to demo.test.com for S01.Test.com to modify S02.Test.com to save S02.Test.com to S02.Test.com.Test.com. .com.cn modified Test.Test.net for test.test.com.cnshell> / usr / lib / company / share / makehostedDomains

6. Mail domain name change mysql> select vdid, description from tbl_vdinfo; -------------------------------------------------------------------------------------------------------------------------------------------------------------- - | VDID | Description | ------------------------------------ | S02. TEST.NET | S02.Test.net || S03.Test.net | S03.Test.net || Demo.test.net || S01.Test.net | S01.Test.Net || Test.test.net | Test.test.net || New2.test.com.cn | New2.test.com.cn || New1.Test.com.cn | new1.test.com.cn | --- --------------- ------------------ 7 ROWS IN Set (0.00 sec)

MySQL @ Courier: MAildb> Update Set vdid = ''

Update TBL_VDINFO SET VDID = Concat (LEFT (VDID, Locate (', VDID)),' Test.com.cn '), Description = Concat (Left (Description, Locate (', Description), 'Test .com.cn ') WHERE LOWER (Substring (VDID, Locate ('. ', VDID) 1)) =' Test.net ';

7. Change [S01.Test.Net] ==> S01.Test.com.cn, the process is as follows: (7.1). Change Mail's mailbox path, using database generation modification script mysql@211.68.29.200: maildb> select concat 'mv' '', Home, '' '' ', Concat (Left (Home, Locate (' @ ', home)),' s01.test.com.cn '),' '') Movecmd from Passwd WHERE LOWER (Home, Locate 1)) = 's01.test.net' intfile '/Home/courier/s01.test.net.sh'; Query Ok, 3411 Rows Affected (0.04 sec) shell @ Courier> CD / home / co portierHell @ Courier> chmod x s01.test.net.shshell@courier> ./s01.test.net.sh (7.2). Change the domain name suffix in the Mail database MySQL @courier: maildb> Update passwd set id = Concat (id, locate ('@', id)), 's01.test.com.cn'), Home = Concat (left (home, locate ('@' , Home), 's01.test.com.cn'), Maildir = Concat (LEFT (MAildir, Locate), 'S01.Test.com.cn', Substring (Maildir, Locate) (MAILDIR, LOCATE) '/', maildir, locate ('@', maildir) 1))) Where set (Id, Locate 1)) = 's01.test.net';

Query Ok, 3411 Rows Affected (0.20 Sec) Rows Match: 3411 Changed: 3411 WARNINGS: 0

Mysql @ Courier: MAildb> commit;

8. Change [demo.test.net] ==> demo.test.com.cn, the process is as follows: (8.1). Change Mail's mailbox path, use the database generation modified script mysql @ Courier: MAildb> Select Concat ('MV) '' ', HOME,' '' '', Concat (Left (Home, Locate), 'Demo.test.com.cn'), '' ') Movecmd from Passwd Where Lower (Home, Locate 1))) = 'demo.test.net' Into Outfile '/Home/courier/demo.test.net.sh'; Query Ok, 587 Rows Affected (0.03 SEC) Shell> CD / Home / Couriershell> chmod x demo.test.net.shshell> ./demo.test.net.sh (8.2). Change the domain name suffix in the Mail database MySQL @ Courier: MAildb> Update Passwd Set ID = Concat (Left (ID, Locate), 'Demo.test.com.cn'), Home = Concat (Left (Home, Locate ('@', home), 'Demo. Test.com.cn '), Maildir = Concat (LEFT (MAildir, Locate),' Demo.test.com.cn ', Substring (Maildir, Locate (' / ', MAILDIR, LOCATE '@', maildir) 1))))) Where lower (Id, Locate 1)) = 'demo.test.net'; Query OK, 587 ROWS Affected (0.05 sec) ROWS Match: 587 Changed: 587 WARNINGS: 0

Mysql @ Courier: MAildb> commit;

9. Change [S02.Test.Net] ==> S02.Test.com.cn, the process is as follows: (9.1). Change the Mail's mailbox path, using the database generated modified script mysql@211.68.29.200: maildb> select concat 'mv' '', Home, '' '' ', Concat (Left (Home, Locate (' @ ', home)),' s02.test.com.cn '),' '') Movecd from Passwd WHERE Lower (Home, Locate 1)) = 's02.test.net' Into Outfile '/Home/courier/s02.test.net.sh'; Query OK, 1844 ROWS AFFECTED (0.02 sec)

Shell> CD / Home / Couriershell> chmod x S02.test.net.shshell> ./s02.test.net.sh (9.2). Change the domain name suffix in the Mail database mysql@211.68.29.200: MAildb> Update Passwd Set ID = Concat (Left (ID, Locate), 'S02.Test.com.cn'), Home = Concat (Left (Home, Locate ('@', home), 'S02. Test.com.cn '), Maildir = Concat (LEFT (MAildir, Locate),' S02.Test.com.cn ', Substring (Maildir, Locate (' / ', MAILDIR, LOCATE '@', maildir) 1)))))) Where Lower (Id, Locate 1)) = 's02.test.net'; Query Ok, 1844 Rows Affected (0.12 sec) ROWS Match: 1844 Changed: 1844 Warnings: 0mysql@211.68.29.200: MAildb> commit;

10. Change [S03.Test.Net] ==> S03.Test.com.cn, the process is as follows: (10.1). Change Mail's mailbox path, using database generation modification script mysql@211.68.29.200: maildb> select concat 'MV' ', Home,' '' '', Concat (Left (Home, Locate ('@', home)), 's03.test.com.cn'), '' ') Movecmd from Passwd WHERE LOWER (Substring ('@', home) 1)) = 's03.test.net' Into outfile '/Home/courier/s03.test.net.sh'; Query OK, 2105 ROWS AFFECTED (0.02 sec) shell> CD / home / court.Net.shshell> ./s03.test.net.sh error, about 7 people don't, one is called Wangguohua, but several of him a few Not remember

(10.2). Change the domain name suffix in the MAIL database mysql@211.68.29.200: mailb> update passwd set id = concat (id, locate), 's03.test.com.cn') Home = Concat (Left (Home, Locate), 'S03.Test.com.cn'), MAILDIR = Concat (LEFT (MAILDIR, LOCATE ('@', maildir), 'S03 .Test.com.cn ', Substring (', ', MAildir, Locate (' @ ', maildir) 1)) Where Lower (Substring (ID, Locate (' @ ', ID) 1 )) = 's03.test.net'; Query OK, 2105 ROWS Affected: 2105 Changed: 2105 Warnings: 0Mysql: MAildb> commit; 11. Change [Test.Test.Net] ==> Test .test.com.cn, the process is as follows: (11.1). Change Mail's mailbox path, using database generation modification script mysql: maildb> select concat ('mv' ', home,' '' ', Concat) (Home, Locate), 'Test.Test.com.cn'), '' ') Movecmd from Passwd Where Lower (Home, Locate (' @ ', home) 1) ) = 'test.test.net' Into outfile '/home/courier/test.test.net.sh'; Query OK, 3 Rows Affected (0.02 sec) shell> CD / Home / CourierShell> chmod x test.test .Net.shshell> ./test.test.net.sh

(11.2). Change the domain name suffix in the MAIL database MySQL: MAildb> Update Passwd Set = Concat (Left (ID, Locate ('@', ID)), 'Test.Test.com.cn'), Home = Concat (Left (Home, Locate), 'Test.Test.com.cn'), Maildir = Concat (Left (MAILDIR, LOCATE ('@', maildir), 'Test.Test.com .cn ', Substring (' / ', maildir, locate (' @ ', maildir 1))) Where lower (Id, Locate 1)) =' Test.test.net '; Query OK, 3 Rows Affected: 3 Changd: 3 Warnings: 0mysql: MAildb> Commit; 12. After the change (12.1) .mysql @ 211.68.29.200: map> commit; (12.3). Start the Courier mail server (14.4). Test the changed mail is normal mysql: maildb> select ID, left (id, locate) user, limited (ID, locate)) USER, LOWER (Id, Locate) @ ', id) 1)) Domain from passwd where limited (Substring (ID, Locate (' @ ', id) 1)) =' Test.test.com.cn '; from the user to yourself, internal users Exterior Mail account sends a Mail to accept yourself, interior, exterior Mail ----------------- ----- ---------------- | ID | User | Domain | ----------------- --------- ---------- ------------------ | cam@test.test.com.cn | CAM @ | Test.test.com.cn | GDHW001@test.test.com.cn | GDHW001 @ | Test.test.com.cn || wangtao@test.test.com.cn | wangtao @ | Test.test.com.cn | ----- -------------------- --------------------------------------------- - 3 ROWS IN SET (0.03 sec)

SELECT ID, LEFT (ID, Locate) USER, LOWER (Substring (Id, Locate 1) Domain from passwd where limited (Substring (ID, Locate) ', ID) 1)) =' new1.test.com.cn '; ------------------------------ ---- ------------------------------------ | ID | User | Domain | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ---- ------------------ | Admin_XDZ200410@new1.test.com.cn | Admin_XDZ200410 @ | new1.test.com.cn | --- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ---------------- 1 ROW IN Set (0.03 sec) to this, upgrade the existing mail part is completed.

转载请注明原文地址:https://www.9cbs.com/read-127806.html

New Post(0)