問題描述
問題
我正在嘗試使用小型數(shù)據(jù)庫后端在 Elastic Beanstalk 上部署一個(gè)非常簡單的應(yīng)用程序.我嘗試安裝 mysqlclient
作為 AWS 此處.但是,當(dāng)我部署我的應(yīng)用程序時(shí),我在嘗試下載包時(shí)從我的 Elastic Beanstalk 日志中收到以下錯(cuò)誤:
I am trying to deploy a very simple app on Elastic Beanstalk with a small database backend. I try to install mysqlclient
as part of the process outlined by AWS here. However, when I deploy my app, I get the following error from my Elastic Beanstalk logs as it tries to download the package:
Collecting mysqlclient
Using cached mysqlclient-2.0.1.tar.gz (87 kB)
2020/08/21 20:30:16.419082 [ERROR] An error occurred during execution of command [app-deploy] - [InstallDependency]. Stop running the command. Error: fail to install dependencies with requirements.txt file with error Command /bin/sh -c /var/app/venv/staging-LQM1lest/bin/pip install -r requirements.txt failed with error exit status 1. Stderr: ERROR: Command errored out with exit status 1:
command: /var/app/venv/staging-LQM1lest/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-bz45889a/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-bz45889a/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-1tyle8mv
cwd: /tmp/pip-install-bz45889a/mysqlclient/
Complete output (12 lines):
/bin/sh: mysql_config: command not found
/bin/sh: mariadb_config: command not found
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-bz45889a/mysqlclient/setup.py", line 15, in <module>
metadata, options = get_config()
File "/tmp/pip-install-bz45889a/mysqlclient/setup_posix.py", line 65, in get_config
libs = mysql_config("libs")
File "/tmp/pip-install-bz45889a/mysqlclient/setup_posix.py", line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
問題
mysqlclient
是 AWS 推薦的驅(qū)動(dòng)程序,用于使用 Flask 或 Django 連接到 RDS 中的 MySQL 數(shù)據(jù)庫.如何使用 Elastic Beanstalk 安裝它?
The mysqlclient
is the AWS recommended driver to connect to a MySQL database in RDS using Flask or Django. How do I get it installed with Elastic Beanstalk?
背景
我嘗試使用 (1) Elastic Beanstalk 環(huán)境內(nèi)的數(shù)據(jù)庫或 (2) Elastic Beanstalk 環(huán)境外定期部署的 RDS 實(shí)例來實(shí)現(xiàn)我的架構(gòu)環(huán)境.在這種情況下,我們將使用選項(xiàng) (1).
I've tried to implement my architecture with either (1) a database within the Elastic Beanstalk environment or (2) a regularly deployed RDS instance outside the Elastic Beanstalk environment. In this case, we're going with option (1).
我無法使用 apt-get
安裝 mysql-server 或其他軟件包作為 在這里建議 很容易,這就是為什么我希望這不會(huì)被標(biāo)記為重復(fù).我無權(quán)訪問底層服務(wù)器.我嘗試使用平臺(tái)掛鉤和 .ebextensions,但我 無法讓它工作.在這篇文章中,我試圖退后一步,看看是否還有其他途徑.
I can't install mysql-server or other packages using apt-get
as suggested here very easily, which is why I hope this isn't labeled as a duplicate. I don't have access to the underlying servers. I attempted to using platform hooks and .ebextensions, but I wasn't able to get that to work. In this post, I'm trying to step back and see if there is another avenue.
推薦答案
對于 Amazon linux 2,您應(yīng)該能夠使用 yum
安裝它.因此,您可以在 .ebextensions
中有一個(gè)名為的文件,例如01_packages.config
內(nèi)容:
For Amazon linux 2 you should be able to install it with yum
. Thus, you can have in your .ebextensions
a file called, e.g. 01_packages.config
with the content:
packages:
yum:
MySQL-python: []
如果您需要更多 yum 依賴項(xiàng),您可以添加更多.
You can add further yum dependencies if you require more.
這篇關(guān)于我如何解決“OSError: mysql_config not found"?Elastic Beanstalk 部署期間出錯(cuò)?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!