MYSQL大數(shù)據(jù)表聯(lián)查(20W*20W)時報錯, 小表查詢正常偷遗,檢查MYSQL服務(wù)器error.log:
210420 10:24:12 [ERROR] /usr/sbin/mysqld: Sort aborted: Error writing file '/tmp/MYxJWWvV' (Errcode: 28)
#查看詳細MYSQL錯誤日志:
vi /var/log/mysql/error.log
210420 10:22:20 [ERROR] /usr/sbin/mysqld: Sort aborted: Error writing file '/tmp/MY0buVRE' (Errcode: 28)
210420 10:22:22 [ERROR] /usr/sbin/mysqld: Incorrect key file for table '/tmp/#sql_1ecb_0.MYI'; try to repair it
210420 10:22:22 [ERROR] Got an error from unknown thread, /build/mysql-5.5-xFqLis/mysql-5.5-5.5.60/storage/myisam/mi_write.c:226
210420 10:22:23 [ERROR] /usr/sbin/mysqld: Sort aborted: Error writing file '/tmp/MY21PWvi' (Errcode: 28)
210420 10:24:12 [ERROR] /usr/sbin/mysqld: Sort aborted: Error writing file '/tmp/MYxJWWvV' (Errcode: 28)
查詢MYSQL-ERRCODE:28 可知磁盤空間不足获询,檢查服務(wù)器可知磁盤正常:
@see perror命令
#檢查ERROR:28錯誤原因:(No space left on device 磁盤空間不足)
root@DemoA:~# perror 28
OS error code 28: No space left on device
root@DemoA:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/DemoA--vg-root 15G 13G 839M 94% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 3.9G 4.0K 3.9G 1% /dev
tmpfs 799M 532K 798M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 3.9G 0 3.9G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/sda1 236M 220M 4.0M 99% /boot
overflow 1.0M 4.0K 1020K 1% /tmp
/dev/sdc 9.8G 48M 9.2G 1% /mnt
經(jīng)查BAIDU+BING+GOOGLE粉渠,發(fā)現(xiàn)可能為緩存目錄不夠?qū)е耇MPDIR="/tmp"贞让,只有1M,大表查詢可能會出現(xiàn)磁盤不足錯誤,深入檢查并實驗后解決此問題:
# 增加磁盤掛載+100M到TMPDIR: 因為業(yè)務(wù)特殊原因不能修改/tmp目錄位置
mount -o remount,size=100M tmpfs /tmp
# 檢查掛載是否成功:/tmp -> 100M [OK]
root@DemoA:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/DemoA--vg-root 15G 13G 839M 94% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 3.9G 4.0K 3.9G 1% /dev
tmpfs 799M 532K 798M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 3.9G 0 3.9G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/sda1 236M 220M 4.0M 99% /boot
overflow 100M 4.0K 100M 1% /tmp
/dev/sdc 9.8G 48M 9.2G 1% /mnt
重啟MYSQL服務(wù)器進行驗證
service mysql restart
查詢成功瓣铣!問題解決!