Lösen Sie das Verbindungsproblem zwischen Django Elastic Beanstalk und RDS MySQL
P粉716228245
P粉716228245 2023-08-28 20:40:41
0
1
515
<p>Ich versuche, meinen Django Elastic Beanstalk mit meinem RDS MySQL zu verbinden. Mein Django funktioniert einwandfrei mit meinem RDS MySQL über localhost, aber wenn ich versuche, meinen Django auf Elastic Beanstalk hochzuladen, erhalte ich die Fehlermeldung „Bereitstellungsanwendung fehlgeschlagen“ und AWS zeigt den folgenden Fehler an. Mein Projekt enthält mysqlclient in der Datei „requirements.txt“, wie hier gezeigt: </p> <p>https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-rds.html</p> <p>Laut der Seite sollte das ausreichen. Ich habe auf jeden Fall versucht, nach ähnlichen Problemen zu suchen, aber bisher ohne Erfolg. Mir ist aufgefallen, dass in vielen Fragen die Notwendigkeit erwähnt wird, eine Datei „packages.config“ im Ordner „.ebextensions“ zu haben, und ich habe viele dieser Vorschläge erfolglos ausprobiert. Ist das ein Problem? Warum wird dies auf der AWS-Seite nicht erwähnt? </p> <pre class="brush:php;toolbar:false;">× python setup.py egg_info wurde nicht erfolgreich ausgeführt. – Exit-Code: 1 â•°â“€> /bin/sh: mysql_config: Befehl nicht gefunden /bin/sh: mariadb_config: Befehl nicht gefunden /bin/sh: mysql_config: Befehl nicht gefunden Traceback (letzter Anruf zuletzt): Datei "<string>", Zeile 2, in <module> Datei „<pip-setuptools-caller>“, Zeile 34, in <module> Datei „/tmp/pip-install-r0dz9d2g/mysqlclient_f2b5c53e43a648c284b06f7af63d9855/setup.py“, Zeile 15, in <module> Metadaten, Optionen = get_config() Datei „/tmp/pip-install-r0dz9d2g/mysqlclient_f2b5c53e43a648c284b06f7af63d9855/setup_posix.py“, Zeile 70, in get_config libs = mysql_config("libs") Datei „/tmp/pip-install-r0dz9d2g/mysqlclient_f2b5c53e43a648c284b06f7af63d9855/setup_posix.py“, Zeile 31, in mysql_config Erhöhe OSError("{} nicht gefunden".format(_mysql_config_path)) OSError: mysql_config nicht gefunden mysql_config --version mariadb_config --version mysql_config --libs [Ende der Ausgabe]</pre></p>
P粉716228245
P粉716228245

Antworte allen(1)
P粉777458787

回答自己的问题。稍后我问了一个类似的问题AWS Elastic Beanstalk RDS MacOS mysqlclient not working并得到了帮助。

答案确实是packages.config文件,通过yum安装所需的文件(请参考上面的链接)。我的代码中还有其他地方出了问题,但我得到的错误与上面的错误相同,尽管packages.config已经正确设置。我发现这个问题是因为我尝试将其设置回SQLite数据库并上传到Elastic Beanstalk,但它不起作用。(对不起,我不记得我得到了什么错误,我很紧张,我想是"111: Connection refused"错误。)

我让事情正常工作的方法是删除所有配置文件,然后从常规完成的项目重新开始,然后按照教程进行操作(就像我以前做的那样):https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-rds.html#python-rds-connect

从那里,我在我的.ebextensions文件夹中添加了一个packages.config文件,其中包含以下代码...

packages: 
  yum:
    python3-devel: []
    mariadb-devel: []

...正如我在上面链接的另一个问题中所提到的,以及这里:mysqlclient installation error in AWS Elastic Beanstalk

我还需要gunicorn和一个Procfile,但我之前已经解决了这个问题,但如果你因为Elastic Beanstalk和RDS的问题而来到这里,这也值得一提。

我还不明白如果我在我的计算机上没有yum,是否可以在packages.config文件中使用yum,特别是因为我使用的是MacOS,而在MacOS上使用yum并不常见。这个问题在我上面链接的另一个问题中得到了回答,答案是在这种情况下你不需要在你的计算机上安装yum,因为yum在这种情况下是由Elastic Beanstalk的Amazon Linux 2服务器使用的。

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!