数据库版本:5.5.14
操作系统版本:contos 6.3
服务器256G内存,安装90个实例。通过脚本启动90个mysql数据库实例,会有几个实例无法启动,进程启动后直接被杀死。查看mysql日志如下:
140729 10:32:34 [ERROR] Can‘t create thread to kill server
140729 10:46:35 mysqld_safe Starting mysqld daemon with databases from /export/data/mysql/data3363
140729 10:46:36 InnoDB: The InnoDB memory heap is disabled
140729 10:46:36 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140729 10:46:36 InnoDB: Compressed tables use zlib 1.2.3
140729 10:46:36 InnoDB: Initializing buffer pool, size = 1.0G
140729 10:46:36 InnoDB: Completed initialization of buffer pool
140729 10:46:36 InnoDB: highest supported file format is Barracuda.
InnoDB: Error: pthread_create returned 11
140729 10:46:37 mysqld_safe mysqld from pid file /export/data/mysql/data3363/mysql.pid ended
140729 10:48:26 mysqld_safe Starting mysqld daemon with databases from /export/data/mysql/data3363
140729 10:48:26 [ERROR] setuid: Resource temporarily unavailable
140729 10:48:26 [ERROR] Aborting
主要问题是系统资源限制导致,可通过修改:
[[email protected] ~]# 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) 2066313
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65535
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 1024
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
可是ulimit修改后,不是永久性的。网上说在vi /etc/security/limits.conf下添加如下:
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535
但是最终发现,也不是永久性的。而是要在此参数下修改,vi /etc/security/limits.d/90-nproc.conf
* soft nproc 65536
并手动ulimit-u 65535 即可。