How to fix high CPU usage problem on BIND (named)

DNSDNS (BIND) on CentOS 6 may use over 100% CPU when started without changes beyond creating zones and zone files, as shown below.


top - 11:32:19 up 8 days, 44 min,  1 user,  load average: 0.24, 0.09, 0.06
Tasks: 162 total,   1 running, 161 sleeping,   0 stopped,   0 zombie
Cpu(s):  7.2%us, 36.6%sy,  0.0%ni, 50.0%id,  4.1%wa,  0.0%hi,  0.0%si,  2.1%st
Mem:   3923092k total,  2268344k used,  1654748k free,   148052k buffers
Swap:  3071992k total,        0k used,  3071992k free,   602412k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
  616 named     20   0  229m  11m 2548 S 130.3  0.3   0:06.74 named

Checking /var/log/message reveals the following error:

/var/named/dynamic/managed-keys.bind.jnl: create: file not found

From the information above, the CPU usage over 100% is caused by:

  1. Having bind-chroot installed.
  2. Having SELinux enabled.

To resolve BIND (named) CPU usage over 100%:

  1. Disable SELinux by editing /etc/sysconfig/selinux to contain:

    SELINUX=disabled

    Reboot the machine. If you cannot reboot, run:

    [root@ezylinux ~]# setenforce Permissive
  2. Check whether bind-chroot is installed with:

    [root@ezylinux ~]# rpm -qa | grep -i bind

    If you see “bind-chroot”, the package is installed. Run the following command to create the directories BIND needs under the bind-chroot path.

    [root@ezylinux ~]# mkdir /var/named/chroot/var/named/dynamic
    [root@ezylinux ~]# mkdir /var/named/chroot/var/named/data
    [root@ezylinux ~]# touch /var/named/chroot/var/named/dynamic/managed-keys.bind
    [root@ezylinux ~]# touch /var/named/chroot/var/named/data/named.run
    [root@ezylinux ~]# chown -R /var/named/chroot/var/named/d*

    Then restart the BIND (named) service with:

    [root@ezylinux ~]# service named restart
EOF.← Back to articles