这个问题我大概花了一整天的时间。我找不到我的MongoDB存储数据的位置。它不在user/data/db中。我运行了ps-xa | grep mongod,它不在列出的任何目录中。当我启动mongodb并执行show dbs时,我得到一个空数据库的列表。不知道硬盘在哪里。在这一点上,我不知道发生了什么。我正在运行的代码来自另一个网站,并且正在运行。它显示元素被插入到数据库中。我尝试了我所知道的一切,但没有任何效果。代码如下:
auth1 = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth1.set_access_token(access_token, access_token_secret)
class StreamListener(tweepy.StreamListener):
def on_status(self, tweet):
print tweet.text
def on_error(self, status_code):
print 'Error: ' + repr(status_code)
return False
def on_data(self, data):
print 'Ok! Inserting Data.'
from pymongo import MongoClient
client = MongoClient()
client = MongoClient('localhost', 27017)
db = client.test
test_id = db.twittertest.insert(json.loads(data))
l = StreamListener()
streamer = tweepy.Stream(auth=auth1, listener=l)
streamer.sample()
根据您使用的*ix,考虑尝试lsof-p或fuser。在
…其中“$$”是一些pid,例如来自mongo进程的pid。在
您可以通过使用^{} command 找到当前
dbpath
的设置。在例如,使用
mongo
shell:具体来说,您将发现
^{pr2}$dbpath
为:如果没有通过配置设置}(在Windows上)。在
dbpath
,那么默认目录是/data/db
(在Linux/OS X上)或{相关问题 更多 >
编程相关推荐