我在Azure环境中工作。我有一个运行Django应用程序(Open edX)的VM和另一个VM实例(Ubuntu 16.04)上的Mongo服务器。每当我尝试在应用程序中加载任何东西(从Mongo服务器获取数据)时,我都会收到类似这样的错误:
Feb 23 12:49:43 xxxxx [service_variant=lms][mongodb_proxy][env:sandbox] ERROR [xxxxx 13875] [mongodb_proxy.py:55] - Attempt 0
Traceback (most recent call last):
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/mongodb_proxy.py", line 53, in wrapper
return func(*args, **kwargs)
File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/contentstore/mongo.py", line 135, in find
with self.fs.get(content_id) as fp:
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/gridfs/__init__.py", line 159, in get
return GridOut(self.__collection, file_id)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/gridfs/grid_file.py", line 406, in __init__
self._ensure_file()
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/gridfs/grid_file.py", line 429, in _ensure_file
self._file = self.__files.find_one({"_id": self.__file_id})
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/pymongo/collection.py", line 1084, in find_one
for result in cursor.limit(-1):
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/pymongo/cursor.py", line 1149, in next
if len(self.__data) or self._refresh():
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/pymongo/cursor.py", line 1081, in _refresh
self.__codec_options.uuid_representation))
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/pymongo/cursor.py", line 996, in __send_message
res = client._send_message_with_response(message, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 1366, in _send_message_with_response
raise AutoReconnect(str(e))
AutoReconnect: timed out
首先我认为这是因为我的Mongo服务器存在于Django应用程序的虚拟网络之外的实例中。我在同一个虚拟网络中的实例上创建了一个新的Mongo服务器,但仍然会遇到这些问题。请注意,我最终会收到数据,但如果连接正常,我觉得我不会出现timed out
错误。
如果有帮助,请使用我用于创建Mongo服务器的Ansible手册:https://github.com/edx/configuration/tree/master/playbooks/roles/mongo_3_2
此外,我已经将Mongo日志文件保留了尾标,这是我在应用服务器上出现timed out
错误的同时出现的唯一一行:
2018-02-23T12:49:20.890+0000 [conn5] authenticate db: edxapp { authenticate: 1, user: "user", nonce: "xxx", key: "xxx" }
mongostat
和mongotop
不会显示任何异常情况。此处还有htop
输出:
我不知道还有什么要寻找或如何解决这个问题。
答案 0 :(得分:1)
我忘了将Django应用程序设置中的Mongo服务器IP更改为指向虚拟网络内的新私有IP地址而不是公共IP。在我改变之后,它不再能够解决这个问题。
如果您正在阅读此内容,请确保在Azure中将私有IP更改为静态IP,如果您在Djagno应用程序设置中使用该IP地址。