成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

一個(gè)mysql/tmp目錄爆滿問題的處理

突然收到zabbix告警,說MySQL服務(wù)器的/目錄磁盤空間不足。

為企業(yè)提供做網(wǎng)站、成都做網(wǎng)站、網(wǎng)站優(yōu)化、全網(wǎng)整合營(yíng)銷推廣、競(jìng)價(jià)托管、品牌運(yùn)營(yíng)等營(yíng)銷獲客服務(wù)。成都創(chuàng)新互聯(lián)擁有網(wǎng)絡(luò)營(yíng)銷運(yùn)營(yíng)團(tuán)隊(duì),以豐富的互聯(lián)網(wǎng)營(yíng)銷經(jīng)驗(yàn)助力企業(yè)精準(zhǔn)獲客,真正落地解決中小企業(yè)營(yíng)銷獲客難題,做到“讓獲客更簡(jiǎn)單”。自創(chuàng)立至今,成功用技術(shù)實(shí)力解決了企業(yè)“網(wǎng)站建設(shè)、網(wǎng)絡(luò)品牌塑造、網(wǎng)絡(luò)營(yíng)銷”三大難題,同時(shí)降低了營(yíng)銷成本,提高了有效客戶轉(zhuǎn)化率,獲得了眾多企業(yè)客戶的高度認(rèn)可!

登錄到服務(wù)器,看了下發(fā)現(xiàn)100GB的根目錄,居然使用了差不多90GB。這臺(tái)服務(wù)器上只跑了一個(gè)MySQL,應(yīng)該不是日志未清理等其它原因造成的。

(說明:下面的幾張截圖是后期截的,當(dāng)時(shí)已經(jīng)有部分SQL跑完,釋放掉部分磁盤空間了)

lsof |grep deleted 發(fā)現(xiàn)如下:

一個(gè)mysql /tmp目錄爆滿問題的處理可以看到這個(gè)臨時(shí)文件差不多有40GB。

show processlist; 如下:

一個(gè)mysql /tmp目錄爆滿問題的處理

上圖看的話,沒有涉及到寫binlog的操作,但是由于單純的select并不會(huì)造成/tmp目錄爆滿的情況,所以猜測(cè)他這個(gè)同一個(gè)事務(wù)里面之前還有涉及到寫binlog的操作(update、delete等)。

官方的說明:

https://dev.mysql.com/doc/refman/5.6/en/binary-log.html

When a thread that handles the transaction starts, it allocates a buffer of binlog_cache_size to buffer statements. If a statement is bigger than this, the thread opens a temporary file to store the transaction. The temporary file is deleted when the thread ends.

The Binlog_cache_use status variable shows the number of transactions that used this buffer (and possibly a temporary file) for storing statements. TheBinlog_cache_disk_use status variable shows how many of those transactions actually had to use a temporary file. These two variables can be used for tuning binlog_cache_size to a large enough value that avoids the use of temporary files.

The max_binlog_cache_size system variable (default 4GB, which is also the maximum) can be used to restrict the total size used to cache a multiple-statement transaction. If a transaction is larger than this many bytes, it fails and rolls back. The minimum value is 4096.

If you are using the binary log and row based logging, concurrent inserts are converted to normal inserts for CREATE ... SELECT or INSERT ... SELECTstatements. This is done to ensure that you can re-create an exact copy of your tables by applying the log during a backup operation. If you are using statement-based logging, the original statement is written to the log.

當(dāng)事務(wù)開始時(shí),它將緩沖區(qū)語句分配一個(gè)binlog_cache_size大小的緩沖區(qū)(我這里設(shè)置的是16777216bytes,即16MB)。 如果一個(gè)語句大于此,線程將打開一個(gè)臨時(shí)文件來存儲(chǔ)事務(wù)(默認(rèn)是存放在/tmp/目錄下)。 當(dāng)線程結(jié)束時(shí),臨時(shí)文件會(huì)自動(dòng)被刪除。

上面就是因?yàn)槭聞?wù)里面的臨時(shí)文件超過16MB了,被放到/tmp目錄下了,但是這個(gè)臨時(shí)文件實(shí)在太大了,導(dǎo)致磁盤空間不足告警了。

解決方法:

等上面的查詢結(jié)束后,我們先關(guān)閉mysqld。(條件能允許的話,當(dāng)然是讓查詢自己結(jié)束。如果直接kill掉的話,估計(jì)回滾也要話挺長(zhǎng)時(shí)間的)

然后調(diào)整mysql的tmpdir到其他更大的磁盤去。

mkdir /bdata/mysql_tmp

chown mysql.mysql /bdata/mysql_tmp -R

chown 1777 -R /bdata/mysql_tmp -R

vim /etc/my.cnf 

[mysqld]

tmpdir = /bdata/mysql_tmp

然后啟動(dòng)mysql即可

再次執(zhí)行l(wèi)sof|grep deleted 可以看到臨時(shí)文件的路徑已經(jīng)改到了/bdata/mysql_tmp目錄下了。

一個(gè)mysql /tmp目錄爆滿問題的處理

當(dāng)前名稱:一個(gè)mysql/tmp目錄爆滿問題的處理
當(dāng)前URL:http://jinyejixie.com/article24/iicsce.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、服務(wù)器托管微信公眾號(hào)、面包屑導(dǎo)航、軟件開發(fā)、品牌網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司
常山县| 通河县| 普格县| 邵武市| 武鸣县| 咸宁市| 定南县| 九龙城区| 四平市| 西城区| 平凉市| 筠连县| 偃师市| 成安县| 渑池县| 贡觉县| 图们市| 云南省| 宁安市| 蒙阴县| 遵义市| 阜康市| 莎车县| 闻喜县| 霸州市| 阿拉善盟| 烟台市| 汤阴县| 鹤山市| 德保县| 平昌县| 武宣县| 石阡县| 南投市| 大埔区| 德格县| 遂平县| 峨山| 和田市| 鄂州市| 肥城市|