ZmSetServerName

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

ZmSetServerName

   KB 1593        Last updated on 2015-09-5  




0.00
(0 votes)

ZmSetServerName

The following article outlines how to use zmsetservername to change the Zimbra server's hostname. Please note that the usage of this CLI command differs depending on what version of ZCS you are running.

Syntax

./zmsetservername [-h] [-d] [-f] [-s] [-o <prev servername>] [-v+] -n <servername>

Description

Changes the name of the local zimbra server.

Options

Name Description
--help Displays usage options for zmsetservername.
--force Force the rename, bypassing safety checks.
--oldServerName <oldname> Previous name for the server. Defaults to LC zimbra_server_hostname.
--newServerName <newname> New name for the server.
--deletelogger Delete the logger database for the old server. Default is to remap its data to the new hostname.
--skipusers Skips modifying the user database with the new server.
--usersonly Only updates the user database. This way, you can run once to do all the server updates, and then a second time to update the accounts. Likely

requires --force.

--verbose Set the verbosity level. Can be specified multiple times to increase the level.

Steps to change the hostname at Server level

  • 1.- The first step is take a complete Zimbra Backup, Snapshot, and VM Backup, or all of them if you have the chance.
  • 2.- Backup your actual folder /opt/zimbra/ssl/zimbra/ you will need later

Deploy a SSL Self-signed instead your commercial one

/opt/zimbra/bin/zmcertmgr createca -new
/opt/zimbra/bin/zmcertmgr createcrt -new -subjectAltNames <servername> -days 365
/opt/zimbra/bin/zmcertmgr deploycrt self
/opt/zimbra/bin/zmcertmgr deployca
/opt/zimbra/bin/zmcertmgr viewdeployedcrt
zmcontrol restart
  • 3.- Change the hostname in /etc/hosts. Note that if you are running dnsmasq in your server, you should have both hostnames in the /etc/hosts like:
127.0.0.1       localhost.localdomain   localhost
192.168.211.20  NEWHOSTNAME.example.com        NEWHOSTNAME
192.168.211.20  OLDHOSTNAME.example.com        OLDHOSTNAME

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

If not you will obtain the next error:

Unable to contact ldap://OLDHOSTNAME.example.com:389: Invalid argument
  • 4.- Change the hostname in /etc/hostname

Steps to change the hostname at DNS level

You need to create or change the DNS, A and MX entry at your DNS level.

Example using dnsmasq in Single-Server

For example, running a Single-Server using dnsmasq, you need to edit the dnsmasq.conf file and change the next files with your new values:

server=8.8.8.8
server=208.67.222.222
domain=example.com
mx-host=example.com,<servername>.example.com,5
listen-address=127.0.0.1

Restart the dnsmasq service:

service dnsmasq restart

Bind server or another DNS in other server

If you have an external DNS server, you need to create a new A entry for the new hostname, and change the MX to point to the new hostname. It is important don't delete yet the old hostname A entry or you will obtain the next error:

Unable to contact ldap://OLDHOSTNAME.example.com:389: Invalid argument

Steps to change the Zimbra server's hostname using zmsetservername

Use the following steps to change the Zimbra server's hostname using the zmsetservername command line utility.

  • 1.- Stop the flow of mail/Zimbra and back up your entire /opt/zimbra and any linked folders. For more information on creating a backup, see Category:Backup and Restore.
  • 2.- The new hostname must exist in the DNS before zmsetservername is run. If it does not already exist in the DNS, add the new hostname to the DNS now.

Note: If the box is duplicate of production server, prevent this command from affecting the production server by halting communications between test and live servers.

  • 3.- Run the following commands:
su - zimbra
/opt/zimbra/libexec/zmsetservername -n <servername>

You will obtain the next output retrieving all the data of the ldap with the old hostname:

Getting local config zimbra_server_hostname=zimbra-sn-u14-01.example.com
Getting local config zimbra_ldap_userdn=uid=zimbra,cn=admins,cn=zimbra
Getting local config zimbra_ldap_password=YOURPASS
Getting local config ldap_is_master=true
Getting local config ldap_url=ldap://zimbra-sn-u14-01.example.com:389
Getting local config ldap_master_url=ldap://zimbra-sn-u14-01.example.com:389
Getting local config ldap_starttls_supported=1
Starting ldap...already running.
Renaming zimbra-sn-u14-01.example.com to zimbra-sn-u14-02.example.com
Shutting down zimbra...done.
Setting local config ldap_master_url=ldap://zimbra-sn-u14-02.example.com:389
Setting local config ldap_url=ldap://zimbra-sn-u14-02.example.com:389
Getting local config ldap_host=zimbra-sn-u14-01.example.com
Setting local config ldap_host=zimbra-sn-u14-02.example.com
Getting local config av_notify_user=admin@example.com
Getting local config av_notify_domain=example.com
Getting local config snmp_trap_host=zimbra-sn-u14-01.example.com
Setting local config snmp_trap_host=zimbra-sn-u14-02.example.com
Getting local config smtp_source=admin@example.com
Getting local config smtp_destination=admin@example.com
Setting local config zimbra_server_hostname=zimbra-sn-u14-02.example.com
Starting ldap...done.

And then, you will see the next output with all the changes with the new hostname:

Searching for ldap server entry...done.
Renaming cn=zimbra-sn-u14-01.example.com,cn=servers,cn=zimbra...done.
Updating zimbraServiceHostname for cn=zimbra-sn-u14-02.example.com,cn=servers,cn=zimbra...done.
Updating zimbraSpellCheckURL for cn=zimbra-sn-u14-02.example.com,cn=servers,cn=zimbra...done.
Updating zimbraSmtpHostname for cn=zimbra-sn-u14-02.example.com,cn=servers,cn=zimbra...done.
Updating zimbraLogHostname for cn=config,cn=zimbra...done.
Updating zimbraMailHost for uid=admin,ou=people,dc=example,dc=com...done.
Updating zimbraMailHost for uid=spam.y8za6ogxq,ou=people,dc=example,dc=com...done.
Updating zimbraMailHost for uid=ham.unqt3dpn,ou=people,dc=example,dc=com...done.
Updating zimbraMailHost for uid=virus-quarantine.mezhhbmuys,ou=people,dc=example,dc=com...done.
Updating zimbraMailHost for uid=galsync.r9xuodn2,ou=people,dc=example,dc=com...done.
Updating zimbraMailTransport for uid=admin,ou=people,dc=example,dc=com...done.
Updating zimbraMailTransport for uid=spam.y8za6ogxq,ou=people,dc=example,dc=com...done.
Updating zimbraMailTransport for uid=ham.unqt3dpn,ou=people,dc=example,dc=com...done.
Updating zimbraMailTransport for uid=virus-quarantine.mezhhbmuys,ou=people,dc=example,dc=com...done.
Updating zimbraMailTransport for uid=galsync.r9xuodn2,ou=people,dc=example,dc=com...done.
Services: 
Getting local config ldap_port=389
Reinitializing the mta config...done.
Reinitializing the snmp config...done.
  • 4.- Delete the entry to the old hostname in /etc/hosts if you are using dnsmasq, and delete the A entry in for the old hostname in the DNS if you are running external DNS Server

Clean the zmloggerhostmap

Zimbra didn't clean the zmloggerhostmap, so you need to remove the old hostname manually. Check what is the actual status of the zmloggerhostmap:

zmloggerhostmap
 Zimbra Logger Service Hostname Map

---------------------    ---------------------
DNS Hostname             Zimbra Hostname
---------------------    ---------------------
zimbra-sn-u14-02.example.com    zimbra-sn-u14-02.example.com
zimbra-sn-u14-01.example.com    zimbra-sn-u14-01.example.com
zimbra-sn-u14-01    zimbra-sn-u14-02.example.com
zimbra-sn-u14-02    zimbra-sn-u14-02.example.com

Remove all the references to the old hostname:

zmloggerhostmap -d zimbra-sn-u14-01.example.com    zimbra-sn-u14-01.example.com
zmloggerhostmap -d zimbra-sn-u14-01    zimbra-sn-u14-02.example.com

You will see the next output per each delete:

Deleted mapping for zimbra-sn-u14-01 to zimbra-sn-u14-02.example.com

Stop the Zimbra services:

zmcontrol stop

Reboot and test the new hostname in the Admin Console

Do the final reboot and login in the Admin Console and navigate under Home > Monitor > Server Status

Zimbra-renameserver-001.png

Note: If you have a multi-server setup, be sure to change any corresponding references to the old hostname & restart services on all hosts.

Check the configuration using zmlocalconfig

Use zmlocalconfig and zmprov to manually double-check the global config, server configs, user settings, etc.

zmprov gacf | grep oldhostname
zmprov gs `zmhostname` | grep oldhostname
zmlocalconfig | grep oldhostname

Errors are usually certificates. If you are experiencing errors, you will probably need to obtain new certs to match the new hostname. For more information on working with certificates, see Administration Console and CLI Certificate Tools. For more information on troubleshooting certificate issues, see Category:Troubleshooting Certificates.

Additional Content

This article will not be certified at the current time, please file bugs for any errors your encounter to help improve this command.

  • Bug 10696
  • Bug 23404
  • Bug 26411 - auto re-creation of self-signed certs
  • Bug 34026


Verified Against: Zimbra Collaboration 8.6, 8.5, 8.0 Date Created: 08/17/2007
Article ID: https://wiki.zimbra.com/index.php?title=ZmSetServerName Date Modified: 2015-09-05



Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »


Wiki/KB reviewed by Jorge SME2 Copyeditor Last edit by Jorge de la Cruz
Jump to: navigation, search