自己的案列:win7上安裝ubuntu (win7作為slaver,ubuntu作為master )
修改配置文件redis.conf
1)打開配置文件把下面對應的注釋掉
# bind 127.0.0.1
2)Redis默認不是以守護進程的方式運行,可以通過該配置項修改,設置為no
daemonize no
3)保護模式
protected-mode no
關鍵的一步:ubuntu終端命令中重啟redis服務的時候如下操作:
redis-server redis.conf
在win7上安裝RedisDesktopManage查看ubuntur Redis數據庫 (連接方法:完成以上1,2,3即可連接 注意:ubuntu的網絡適配器要選擇橋接模式。)
在編寫爬蟲的時候:
發現這樣寫域名的范圍會報錯(在ubuntu中push url后爬蟲沒有爬取數據):
#動態域范圍的獲取
def __init__(self, *args, **kwargs):
# Dynamically define the allowed domains list.
domain = kwargs.pop('domain', '')
self.allowed_domains = filter(None, domain.split(','))
super(MySpider, self).__init__(*args, **kwargs)
而這樣寫不會報錯:
allowed_domains = ["xxx.com"]
在爬蟲的settings.py中指明主機地址以及端口號
如:
REDIS_HOST = 'x.x.x.x' 主機地址(ubuntu IP地址)
REDIS_PORT = 6379