Changing the Zimbra server's hostname
1. Stop the flow of mail/Zimbra & MAKE A VERY GOOD BACKUP (your entire /opt/zimbra and any linked folders) Backup_and_Restore_Articles
2. For good measure make sure you don't violate logical hostname principles.
3. The commands (you did step 1 right?):
su - zimbra zmcontrol stop /opt/zimbra/libexec/zmsetservername NEW_HOSTNAME
STOP IF RUNNING ZCS 4.5.7 OR LATER
4. In versions of ZCS before 4.5.7 (now handled automatically), some additional conf files will need to be modified manually to reflect the new hostname. You can run /opt/zimbra/libexec/zmmtainit to update these files to use the host(s) listed in the ldap_url localconfig parameter:
ldap-scm.cf ldap-transport.cf ldap-vad.cf ldap-vmd.cf ldap-vmm.cf ldap-vam.cf
That will still leave perdition.conf and swatchrc with the old hostname..
You can fix all the files and back them up at the same time like this - carefully:
for f in `grep -l OLD_HOSTNAME /opt/zimbra/conf/*`; do echo "fixing $f"; perl -pi.bak -e 's/OLD_HOSTNAME/NEW_HOSTNAME/g' $f; done
When in doubt go with manual changes.
Now update the ip address(es) and host name(s) for the server(s) in the following places.
5. Update DNS server
6. Edit /etc/sysconfig/network
7. Edit /etc/hosts file with new hostname
(Those in multi-server setups: Be sure to change any corresponding references to the old hostname & restart services on all hosts)
9. Manual double-check of attributes:
Use zmlocalconfig and zmprov to check the global config, server configs, user settings, etc.
zmprov gacf | grep oldhostname zmprov gs `zmhostname` | grep oldhostname zmlocalconfig | grep oldhostname
10. Errors are usually certificates / you will probably need to obtain new certs to match the new hostname.
(bug 26411 might address auto re-creation of self-signed certs)
- [Administration Console and CLI Certificate Tools]
-New admin console gui.
Notes in http://bugzilla.zimbra.com/show_bug.cgi?id=23294#c9
11. zmprov gacf | grep SpamAccount
(as often it's firstname.lastname@example.org depending on your original domain during setup)
zmprov -l mcf zimbraSpamIsSpamAccount email@example.com
zmprov -l mcf zimbraSpamIsNotSpamAccount firstname.lastname@example.org
If errors - additional things to check
If getting errors/funny quirks afterwards double check a few of the below comments & suggestions:
Notes on what people had to change manually after zmsetservername:
zmprov mcf zimbraLogHostname zimbra.company.com zmlocalconfig -e zimbra_server_hostname=zimbra.company.com zmlocalconfig -e ldap_master_url=ldap://zimbra.company.com:389 zmlocalconfig -e ldap_url=ldap://zimbra.company.com zmlocalconfig -e snmp_trap_host=zimbra.company.com zmlocalconfig -e email@example.com zmlocalconfig -e firstname.lastname@example.org zmlocalconfig -e email@example.com
Another response: Files in which I found the old host name after making all the above changes - edited them as root:
amavisd.conf perdition.conf swatchrc
Entry in /opt/zimbra/postfix/conf/main.cf (myhostname)
If you follow the directions exactly (stopping the services first), you get an error. If, instead, you just run the command, there is no error, and it stops the services automatically. That seems to have solved my "problem", or at least alleviated my fears. Since the internal DNS lists both domains fully, I'm not too worried about any leftover domain issues.
I can confirm the previous note. The following are files that I had to change:
on 4.5.7 under Linux, I also had to manually change
postfix/conf/main.cf conf/amavisd.cf cyrus-sasl.../etc/saslauthd.conf ssl/ssl/zmssl.cnf
Note: I didn't run zmmtainit, which may have fixed those. Also the ssl file is probably mentioned in regenerate self-signed certificates
Notes in need of cleanup/validity check
The logger/stats graphs issues (this is mainly if you didn't zmcontrol stop/reboot):
I had to switch the domain name and found troubles with the logger and server statistics-extra steps needed: (zimbra 4.5.5 on ubuntu 6.06)
the not stopping services first thing
then: change of /etc/hosts and hostname newhostname
su - zimbra zmloggerctl stop ps aux | grep zmlogger kill any logger processes zmloggerctl start /opt/zimbra/libexec/zmlogprocess
And my graps started working on the fly
But after this, I had TWO server-statistics: 1. the old ones with the old servername 2. a new - empty - set with the new servername.
at this point dnsdomainname still gave me the old domain !
I changed the content of the filename /etc/hostname (containing the old hostname ) and did a reboot.
Now serverstatistics gives me only one servername, the new one, with the old statistical data still there and the new one displayed in a new set of graphs.
Beware: Before going the way described above, I had tried to solve the logging problem with: zmprov mcf zimbraLogHostname newhostname I finished up with a big mess and had to reverse completely to the old hostname to get the admin-console working again.
(ie: If you're still running an old server)
I went through the very painful process of chaning my hostname without reinstalling zimbra. This will probably void your warranty, but it worked for me (FC4, M1):
Change your hostname using hostname. Change your hosts file and your /etc/sysconfig/network
use zmprov to change the following fields to your new hostname zimbraLmtpAdvertisedName zimbraServiceHostname zimbraSmtpHostname
zmprov cs oldserver.com zimbraLmtpAdvertisedName newserver.com ....
Then, for every single user in your sytem (that's right), you have to do this:
zmprov ma firstname.lastname@example.org zimbraMailHost new.domain.com
I suggest writing a shell script.
To get a list of users, do this or something similar:
zmprov gaa -v | grep '# name'
Once your done with this tedious task, do a:
grep -il oldserver.com ~zimbra/conf/*
Change the hostname in any of the files returned by this command using vi or whatever.
Then shutdown your zimbra software (zmcontrol shutdown/stop)
Start it back up (zmcontrol startup/start)
The only service that will start is ldap and zmmon (for the server in question, at least). This is where it gets fun. You have to manually edit the directory as follows.
First figure out your DN. From ~zimbra/openldap/bin do a:
./ldapsearch -x | grep oldservername.com
You will see a line that looks like this:
# oldhost.domain.com, servers, zimbra dn: cn=oldhost.domain.com,cn=servers,cn=zimbra [snip] cn: oldhost.domain.com
This is the dn of your server. You will need to change it. To do so create a file called, for example, changes.ldif. For the above example, it would look like this:
Now, grab your zimbra_ldap_password from ~zimbra/conf/localconfig.xml.
Then run the following command from your ~zimbra/openldap/bin dir:
./ldapmodrdn -h localhost -w password_From_above -D "uid=zimbra,cn=admins,cn=zimbra" -x -r -f changes.ldif
Now do a zmcontrol shutdown.
Then do a ps -U zimbra and kill any zimbra-related processes that are still hanging around. If you kill perl, you should clear the .pid file here: /opt/zimbra/zimbramon/FIFO/zm.pid
Now rebuild your SSL keys for the new hostname.
If all went well, everything should start on a zmcontrol startup.
One thing I didn't address is changing the hostname on statistics data in mysql, but it doesn't seem to cause a problem, so I haven't gotten around to it yet.
Old Logger Data
Issue: Server is creating new data in the graphs of the server statistics admin page, but all of the old data that was generated as the old host name is not showing.
Solution: Update all the tables manually in the zimbra_logger database to reflect the name change.
+-------------------------+ | Tables_in_zimbra_logger | +-------------------------+ | amavis | | amavis_aggregate | | config | | disk_aggregate | | disk_status | | mta | | mta_aggregate | | processing_history | | raw_logs | | service_status | +-------------------------+
You should probably do something like:
mysql> select * from `amavis` limit 1\G
To find out what the old hostname is set to so that you set the new hostname similarly. Likely the hostname will be just the name, without the domain, of your system. So if your system is mail.domain.com the host field will have mail.
So you'll need to do something like:
zimbra@mail:~> logmysql zimbra_logger mysql> update `amavis` set host='newhostname' where host='oldhostname';
for each of the tables.
Bugs being tracked
This article will not be certified at the current time, please file bugs for any errors your encounter to help improve this command.
bug 26411 - auto re-creation of self-signed certs