1. 程式人生 > >pyspider連線rabbitmq ,結果出現socket.error: [Errno 104] Connection reset by peer 這樣的報錯資訊

pyspider連線rabbitmq ,結果出現socket.error: [Errno 104] Connection reset by peer 這樣的報錯資訊

linux系統中:

pyspider+rabbitmq+mongodb環境下啟動pyspider時出現socket.error: [Errno 104] Connection reset by peer 的錯誤資訊。

首先,分享一下自己總結的做維護或者排除bug 的思路:

1.維護一定要學會定位錯誤所在。而定位錯誤日誌就是一個相當好用的工具!
2.遇到問題查詢資料去分析產生問題的原因有哪些。因為一般你找不到和你出錯一模一樣的資訊的。只能通過原因去找出自己程式出問題的位置。

其次,感謝一下這兩篇文章的作者。帶給了我思路。

好吧。把博主的錯誤貼上來吧。

根據上面兩篇文章的提示

【檢視日誌】既然定位到rabbitmq出現了問題,那看日誌吧。通過  cat   /var/log/rabbitmq/

[email protected] 即可看到相關日誌情況。
*****************************************************
=INFO REPORT==== 16-Aug-2015::09:49:29 ===
Priority queues enabled, real BQ is rabbit_variable_queue


=INFO REPORT==== 16-Aug-2015::09:49:29 ===
Memory limit set to 1531MB of 3829MB total.


=INFO REPORT==== 16-Aug-2015::09:49:29 ===
Disk free limit set to 50MB


=INFO REPORT==== 16-Aug-2015::09:49:29 ===
Disk free space insufficient. Free bytes:0 Limit:50000000
*********************************************************************

看到了吧,就是Disk space的容量出現問題。在網頁管理頁面,也可以發現Disk space顯示為0.而預設是50M,所以rabbitmq-server會受限制。

官方對這個值的配置引數disk_free_limit的解釋:

disk_free_limitDisk free space limit of the partition on which RabbitMQ is storing data. When available disk space falls below this limit, flow control is triggered. The value may be set relative to the total amount of RAM (e.g. {mem_relative, 1.0}). The value may also be set to an integer number of bytes. By default free disk space must exceed 50MB. See the memory-based flow control documentation.
Default: 50000000


檢視linux主機的磁碟使用情況:


[[email protected] pyspider]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1             20G   20G     0 100% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/xvdc1             69G   47G   19G  72% /mnt/diskc
/dev/xvdb1             30G  339M   30G   2% /mnt/diskb

看到了吧,一個磁碟滿了!上網找了一下,解決思路有:
1.刪除沒有用的日誌。以及把一些沒用的大檔案刪除吧。

2.不能刪除的就把打檔案轉移到diskb盤 或者diskc盤裡面。

重新啟動pyspider,成功了!!

【題外話】

博主我,半路出家學pyspider、mongodb資料庫、rabbitmq、更是半路出家學linux。走了很多的彎路。當作為一個在程式碼的世界裡遨遊的人,不走彎路怎麼能換來更強悍的成長呢?博主我,感受很深啊。看哪天有時間了,把自己學的東西貼上來一下。希望今天分享的對大家能有所幫助。有問題的歡迎大家留言探討哈~