Introduction
Sometimes a misconfigured cluster ends up writing a large number of zones to the wrong server. This can happen if someone makes a mistake during cluster configuration. If you’ve made this error, don’t feel bad–you’re not alone! One of the more common questions we get in support regarding clusters is “How do I fix this and get the zones that are not managed on this webserver off of it?”
Procedure
. Make a backup of /var/named.
One easy way to do this is with the following command. You’ll want to change the backup location if you use a different backup directory:
tar -czf /backup/var_named.tar.gz /var/named
. Create a directory to keep the zones you don’t want temporarily.
One way to do this is with the following command:
mkdir /backup/named_unwanted_zones
. Create a list of zones that belong on the server.
Start with the zones in /etc/userdomains and add any zones that must be managed by this server but are not related to user accounts. To get a list of domains from /etc/userdomains, use the following command to create a file called /etc/managed_domains. Add your hostname and any nameservers that have their own zone files to the list. Be sure to remove the line with the * on it–it’s usually either the first or last line of the file.
cut -d ':' -f1 /etc/userdomains >> /etc/managed_domains
- Review the cluster configuration to ensure that the problem will not occur again.
Reference our DNS Clustering Guide to ensure that you have set things up the way you need them. - Disable DNS Clustering
If you do not disable DNS Clustering, you will remove domains from the cluster, resulting in sites not resolving.
Navigate to WHM » Clusters » DNS Clustering and click the button to disable clustering. - Stop the nameserver and disable monitoring for it.
You cannot run the nameserver while you are making these manual modifications or errors will occur with DNS resolution that may be cached.
Navigate to WHM » Service Configuration » Service Manager and deselect the checkboxes next to the nameserver (either BIND/named or PowerDNS).
Part 2: Update
- Run the following command to move all the unmanaged zones (those zones that do not have domains listed in /etc/managed_zones) out of /var/named:
for domains in $(ls /var/named/*.db | cut -d ‘/’ -f 4 | awk ‘BEGIN{FS=OFS=”.”}{NF–; print}’ ); do if ! (grep -q $domains /etc/managed_domains); then mv /var/named/${domains}.db /backup/named_unwanted_zones/${domains}.db; fi done
2. Then run the following to rebuild the named configuration file:
/scripts/rebuilddnsconfig
Part 3: Re-activate
. Review the cluster configuration one last time to be sure that it won’t write the unwanted zones back to the server.
- Restart the nameserver and re-enable monitoring:
Navigate to WHM » Service Configuration » Service Manager and select the checkboxes next to the nameserver (either BIND/named or PowerDNS). - Enable DNS Clustering:
- Navigate to WHM » Clusters » DNS Clustering and select the button to enable clustering.
- Resync zones to the cluster with the Synchronize all zones to all servers option in WHM » DNS Functions » Synchronize DNS Records.
Part 4: Cleanup
We recommend waiting around a week to ensure no issues with unwanted removals have occurred. Once you are sure that nothing that was needed was removed, you can go ahead and delete the backup files you made to reclaim the space.