編集:それらを追加することによって解決: TasksMax =無限大を/etc/systemd/system.confする(4915スレッドの愚かなデフォルトの制限) DefaultTasksMax =無限大は解決済みのDebian/mariadbの制限?何も助けなかった! SQLSTATE [HY000] [1135]新しいスレッドを作成できません(errno 11 "リソースは一時的に使用できません")。
を/etc/systemd/system/mysql.serviceしますまず、この問題を2ヶ月間解決しようとしました。 私はすでに聞いたことのあるすべての制限を増やしました。 問題は、mariadb(以前はmysql 5.5.xで同じ問題が発生していました)では、一度にスレッド数が約4500-4900スレッドに制限されていることです。 私のソフトウェアは、私はこのエラーを取得する複数の接続を作成しようとすると、すべてのスレッドが使用されている:[HY000] [1135]
SQLSTATEは、新しいスレッド(エラー番号11「一時的に利用できないリソース」)を作成することはできません。
ここでは、私が現在サーバー上に持っている設定と制限を示します。 See image
MySQL接続: [OK]使用可能な接続の最大使用量:59%(8200分の4890)
ルート サーバは、Debian 9
プロセスのホテルトップ番号であります:〜#cat/proc/sys/kernel/threads-max
944163
ルート#猫の/ proc/$(のpgrep -o mysqlの)/限界
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 8388608 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 472081 472081 processes
Max open files 16364 16364 files
Max locked memory 65536 65536 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 472081 472081 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us
ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 472081
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65536
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 65536
cpu time (seconds, -t) unlimited
max user processes (-u) 472081
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
猫/etc/mysql/mariadb.conf.d/50-server.cnf | grep -v "#"
[server]
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
key_buffer_size = 1G
max_allowed_packet = 64M
thread_stack = 16M
thread_cache_size = 4096
myisam_recover_options = BACKUP
max_connections = 8200
max_connect_errors = 10000000
query_cache_limit = 1G
query_cache_size = 30G
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /var/log/mysql/slow-query.log
log_queries_not_using_indexes
table_open_cache = 65536
open_files_limit = 65536
key_buffer_size = 512M
table_cache = 4096
max_heap_table_size = 512M
innodb_buffer_pool_size = 20G
innodb_log_file_size = 2G
innodb_log_buffer_size = 64M
read_rnd_buffer_size=1M
sort_buffer_size=1G
skip_name_resolve
log_error = /var/log/mysql/error.log
expire_logs_days = 10
max_binlog_size = 100M
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
[embedded]
[mariadb]
[mariadb-10.1]
猫
root soft nofile 65536
root hard nofile 65536
root soft stack 65536
root hard stack 65536
www-data soft nofile 65536
www-data hard nofile 65536
mysql soft nofile 65536
mysql hard nofile 65536
mysql soft nproc 65536
mysql hard nproc 65536
mysql soft stack 65536
mysql hard stack 65536
nobody soft nofile 65536
nobody hard nofile 65536
* soft nproc 40960
* hard nproc 40960
* soft nofile 40960
* hard nofile 40960
* soft stack 65536
* hard stack 65536
# End of file
猫に/etc/sysctl.conf
# Disable IPv6 autoconf
net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.default.autoconf = 0
net.ipv6.conf.eth2.autoconf = 0
net.ipv6.conf.all.accept_ra_defrtr = 0
net.ipv6.conf.default.accept_ra_defrtr = 0
net.ipv6.conf.eth2.accept_ra_defrtr = 0
net.ipv6.conf.all.accept_ra_pinfo = 0
net.ipv6.conf.default.accept_ra_pinfo = 0
net.ipv6.conf.eth2.accept_ra_pinfo = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
net.ipv6.conf.eth2.accept_ra = 0
net.core.somaxconn=1024
#kernel.sched_migration_cost_ns = 5000000
# Number of times SYNACKs for passive TCP connection.
net.ipv4.tcp_synack_retries = 2
# Allowed local port range
net.ipv4.ip_local_port_range = 1024 65535
# Protect Against TCP Time-Wait
net.ipv4.tcp_rfc1337 = 1
# Decrease the time default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 15
# Decrease the time default value for connections to keep alive
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 15
### TUNING NETWORK PERFORMANCE ###
# Default Socket Receive Buffer
net.core.rmem_default = 31457280
# Maximum Socket Receive Buffer
net.core.rmem_max = 16777216
# Default Socket Send Buffer
net.core.wmem_default = 31457280
# Maximum Socket Send Buffer
net.core.wmem_max = 16777216
# Increase number of incoming connections
net.core.somaxconn = 4096
# Increase number of incoming connections backlog
net.core.netdev_max_backlog = 65536
# Increase the maximum amount of option memory buffers
net.core.optmem_max = 25165824
# Increase the maximum total buffer-space allocatable
# This is measured in units of pages (4096 bytes)
net.ipv4.tcp_mem = 65536 131072 262144
net.ipv4.udp_mem = 65536 131072 262144
# Increase the read-buffer space allocatable
net.ipv4.tcp_rmem = 8192 87380 16777216
net.ipv4.udp_rmem_min = 16384
# Increase the write-buffer-space allocatable
net.ipv4.tcp_wmem = 8192 65536 16777216
net.ipv4.udp_wmem_min = 16384
# Increase the tcp-time-wait buckets pool size to prevent simple DOS attacks
net.ipv4.tcp_max_tw_buckets = 1440000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
fs.file-max = 500000
net.ipv4.tcp_max_syn_backlog = 20480
/etc/security/limits.confを私はここで何かを見つけました:
[email protected]:~# systemctl status mysql
● mariadb.service - MariaDB database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2017-10-26 17:02:27 CEST; 1 months 11 days ago
Process: 12508 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 12284 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
Process: 12106 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment
_WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
Process: 12102 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 12099 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Main PID: 12244 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 4915 (limit: 4915)
CGroup: /system.slice/mariadb.service
└─12244 /usr/sbin/mysqld
paź 26 17:02:23 baza systemd[1]: Starting MariaDB database server...
paź 26 17:02:24 baza mysqld[12244]: 2017-10-26 17:02:24 140040257753664 [Note] /usr/sbin/mysqld (mysqld 10.1.26-MariaDB-0+deb9u1) starting as process 12244 ...
paź 26 17:02:24 baza mysqld[12244]: 2017-10-26 17:02:24 140040257753664 [Warning] Could not increase number of max_open_files to more than 16364 (request: 16403)
paź 26 17:02:27 baza systemd[1]: Started MariaDB database server.
次に: systemctl show -all | grepのタスク DefaultTasksAccounting = yesの DefaultTasksMax = 4915件の
を/etc/systemd/system/mysql.serviceするTasksMax =無限大を/etc/systemd/system.confしますあなたのサーバーにはどのくらいのRAMがありますか? V8 mysqlは、あなたが求めているthread_cache_size = 100 CAP対4096を示唆しています。 mysqlcalculator.comを使用すると、「接続ごとの」RAM使用率について合理的な値に導くのに役立ちます。要求された値は上にあり、あなたはOOMになります。 –
115GBのうち29GBが使用されています。 32コアは20%で使用されます。 thread_cache_sizeをdefualtに設定すると16以上が8000に変更されません。 Mysqlには制限がありますが、この制限はまったく違うようです。 制限は4800 mysql connections/threadsです。それを超えている場合、私はこのエラーが発生します。 – silverangel
MariaDB [(none)]>状態を表示します 'variable_name' LIKE '%thread%'; |変数名|値| | Threads_cached | 2221 | |スレッドコネクト| 2595 | |スレッドの作成| | 4141324 | | Threads_Running |スレッド64 | これはメモリの問題ではありません:)そして、これのすべてのポイントです – silverangel