• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

MySQL Server Error – “Can’t Create A New Thread (errno 11)”

by admin

OS error 11 is “Resource temporarily unavailable”. The most common cause of receiving this error when trying to create a new thread is having hit the process’s kernel enforced a limit on open file descriptors. The second most common cause is having hit the process’s kernel enforced limit on the number of processes/threads.

Here are the factors involved:

  1. The system-wide limits: sysctl -e fs.file-max && sysctl -e kernel.threads-max
  2. The per-process limits (in a *new* shell): ulimit -n, grep nofile /etc/security/limits.conf and ulimit -u, grep nproc /etc/security/limits.conf.
  3. The open_files_limit setting in mysqld (mysql> show global variables like “open_files_limit”;).
  4. The other settings within mysqld that can affect the number of open FDs and threads that the process may use (max_connections, thread_cache_size, table_open_cache, table_definition_cache, innodb_open_files, etc.)

Assuming that it was in fact that we hit the open-files-limit, which defaults to 1024 on most Linux systems – we should be able to avoid the issue by taking these steps:

1. Increasing the explicit open files limit in mysqld by making this change to the my.cnf file:

[mysqld]

# Here X could be (max_connections+table_cache)*3  OR you could simply set it very high, for example 32000
open-files-limit = X 

2. Restart mysqld service:

/etc/init.d/mysql restart

NPROC limits

If it instead appears that the nproc limit is the cause (CentOS 6 puts a low limit on this in /etc/security/limits.conf), then we can increase the nproc limit in a few different ways.

1. Edit limits.conf:

We can set the limits for the mysql user in the limits.conf file, for example:

mysql soft nproc 10240
mysql hard nproc 40960

Note that limits.conf only applies to login shells and does not affect processes started by init or systemd. Any changes to limits.conf will only apply to new logins, you must log out and log in to start a new session.

2. Edit the mysqld_safe script:

We can also simply add a ulimit call near the top of the mysqld_safe script, for example:

$ ulimit -u 40000

3. Use a wrapper script:

Refer below post on “How to use a Wrapper Script to set Custom Per-Process Attributes for MySQL Server”.

How to use a Wrapper Script to set Custom Per-Process Attributes for MySQL Server

We will need to restart mysqld in order for the changes to take effect.

Filed Under: Linux, mysql

Some more articles you might also be interested in …

  1. nano: command not found
  2. Wallch (Wallpaper Changer) – Rotate Ubuntu Desktop Wallpapers
  3. How to Configure YUM to connect to Oracle Public Repository in Oracle Enterprise Linux
  4. Hostname change not reflecting in sar report for CentOS/RHEL
  5. How to disable IPv6 on CentOS / RHEL 7
  6. How to use compress, zip, gzip commands under Linux
  7. whois: command not found
  8. dmidecode: command not found
  9. How to Configure firewalld Logging in CentOS/RHEL 8
  10. CentOS / RHEL LVM : Backing Up Volume Group Metadata

You May Also Like

Primary Sidebar

Recent Posts

  • fprintd-delete Command Examples in Linux
  • fprintd-delete: command not found
  • foreman: command not found
  • foreman Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright