在這裡使用了一個liunx下的命令查看磁碟空間
df: disk free http://www.cnblogs.com/chenwenbiao/archive/2011/08/07/2129831.html
常用參數:df -h
-------------------------------------
1.在Linux下重新啟動postgre
pg_ctl restart (postgres 使用者)
今天遇到的問題
由於匯入資料,造成資料庫不斷產生備份檔案,佔滿了空間
無法繼續啟動。
解決方案:
備份檔案所在目錄結構
root
databases
archieves
data
pg_xlog
archive_status
(archieves 檔案;檔案;記錄)
刪除這些目錄下面的資料備份檔案
-------------------------------------------------------------------------------
錯誤現象
執行pg_ctl restart命令
報錯
could not change directory to "/root"
pg_ctl:PID file "/database/data/postmaster.pid" does not exist
出現這種問題的原因
不是因為目錄下沒有這個檔案,而是因為磁碟空間太小
進程執行時,沒有足夠的空間來讀取這個檔案。
使用postgres使用者執行以下命令
df -h可以查看資料庫的空間的使用狀況
FIlesystem size used avail Use% Mounted on
/dev/sda3 70 70 0 100 /
進程沒有足夠的空間來運行,所以出現了上面的錯誤
----------------------------------------------------
問題產生
使用預存程序對postgre插入資料
每次插入10萬條資料,由此在上面的那些目錄產生了n多的備份檔案
這些備份檔案佔用了大量的磁碟空間
當最後一次執行這個批處理命令時
控制台報錯,說磁碟空間不足,緊接著這邊就再也串連不上資料庫了
查看進程,發現postgre的進程已經停掉
重新啟動時,就報了上面的那個錯誤
could not change directory to "/root"
pg_ctl:PID file "/database/data/postmaster.pid" does not exist
----------------------------------------
注意:
是什麼吃掉了磁碟空間
是備份檔案吃掉的巨大的磁碟空間
其實,那幾百萬條資料並沒有佔用多少磁碟空間