Mysql

InnoDB:錯誤:pthread_create 返回 12

  • July 25, 2013

已將 MySQL 安裝在特定文件夾中。我能夠執行伺服器並創建帳戶、數據庫等。但是,現在每當我嘗試啟動伺服器時,都會出現錯誤:

$ mysqld_safe --defaults-file=mysql.cnf &
[1] 2002
[compute-0-5 /amber2/scratch/myname/mysql]$ 130725 17:56:24 mysqld_safe Logging to '/amber2/scratch/myname/mysql/data/compute-0-5.local.err'.
130725 17:56:24 mysqld_safe Starting mysqld daemon with databases from /amber2/scratch/myname/mysql/data
130725 17:56:25 mysqld_safe mysqld from pid file /amber2/scratch/myname/mysql/data/compute-0-5.local.pid ended

[1]+  Done                    mysqld_safe --defaults-file=mysql.cnf

在數據文件夾內的錯誤文件中:

130725 17:17:53 mysqld_safe Starting mysqld daemon with databases from /amber2/scratch/myname/mysql/data
2013-07-25 17:17:54 0 [Warning] option 'read_buffer_size': unsigned value 2147483648 adjusted to 2147479552
2013-07-25 17:17:54 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-07-25 17:17:54 28189 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)

2013-07-25 17:17:54 28189 [Warning] Buffered warning: Changed limits: table_cache: 431 (requested 2000)

2013-07-25 17:17:54 28189 [Note] Plugin 'FEDERATED' is disabled.
2013-07-25 17:17:54 28189 [Note] InnoDB: The InnoDB memory heap is disabled
2013-07-25 17:17:54 28189 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2013-07-25 17:17:54 28189 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-07-25 17:17:54 28189 [Note] InnoDB: Using Linux native AIO
2013-07-25 17:17:54 28189 [Note] InnoDB: Not using CPU crc32 instructions
2013-07-25 17:17:54 28189 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-07-25 17:17:54 28189 [Note] InnoDB: Completed initialization of buffer pool
2013-07-25 17:17:54 28189 [Note] InnoDB: Highest supported file format is Barracuda.
InnoDB: Error: pthread_create returned 12
130725 17:17:55 mysqld_safe mysqld from pid file /amber2/scratch/myname/mysql/data/compute-0-18.local.pid ended

但是為什麼我會收到 pthread_create 錯誤 12?這似乎與空間不足有關。在 mysql 文件夾 (/amnber2//scratch/myname/mysql) 所在的設備上,我確實有空間:

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              49G  5.0G   41G  11% /
       ...
10.255.255.46:/export/scratch
                      15T   11T  4.2T  72% /amber2/scratch

我的主目錄配額中還有一些演出

$ quota -v
Disk quotas for user myname (uid 41222):
    Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
10.255.255.45:/export/ncms
               22986221  26214400 26214400               0       0       0
10.255.255.46:/export/scratch
               7321108       0       0               0       0       0

即,我使用的是 25G 中的 22G:

$ du -sh ~/.
22G /home/ncms/myname/.

我也有空閒記憶體:

$ free -mg
            total       used       free     shared    buffers     cached
Mem:            62         41         21          0          0         28
-/+ buffers/cache:         12         49
Swap:           64         13         51

在我的mysql配置文件中:

myisam_sort_buffer_size=4G   
myisam_max_sort_file_size=200G
read_buffer_size=2G

那麼為什麼我pthread_create在啟動伺服器時收到錯誤錯誤?

$ /usr/local/mysql/bin/perror 12
OS error code  12:  Cannot allocate memory

當然,你現在有記憶體,MySQL 現在沒有執行

刪除那些數千兆字節的配置條目並驗證您是否可以在沒有它們的情況下啟動伺服器。我懷疑read_buffer_size可能是讓你失望的那個,但對於新伺服器來說,它們都太大了。max_open_files您看到的警告table_cache表明您正在嘗試通過在配置中的其他地方設置較大的值來調整 MySQL 的性能。

這不會如你所願。當談到緩衝區和記憶體大小時,更多並不總是更好,而且往往更糟。註釋掉您的自定義設置並從預設設置開始,除非您有特定的理由不這樣做……並且當您進行更改時,一次不要更改超過一件事,除非更改彼此直接相關。

引用自:https://dba.stackexchange.com/questions/47029