Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
407 views
in Technique[技术] by (71.8m points)

mysql - I ran into a problem using Elastic Beanstalk from aws

I have a problem. I checking my database connection, and i was using this application on my localhost, and it was okay. but when i deploy this web application, i always facing 502 error. i was tried modify security group and etc, but it never work. and i get a some last 100 line log message from elastic beanstalk log, so if you can solve problem, plz help me. thank you.

this is the log.

    enter code here ----------------------------------------
/var/log/nginx/error.log
----------------------------------------
2021/01/06 07:23:24 [error] 3544#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 222.108.35.81, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "couponservice-env.eba-7apfigmx.ap-northeast-2.elasticbeanstalk.com"
2021/01/06 07:23:24 [error] 3544#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 222.108.35.81, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:5000/favicon.ico", host: "couponservice-env.eba-7apfigmx.ap-northeast-2.elasticbeanstalk.com", referrer: "http://couponservice-env.eba-7apfigmx.ap-northeast-2.elasticbeanstalk.com/"
2021/01/06 07:24:50 [error] 3544#0: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 222.108.35.81, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "couponservice-env.eba-7apfigmx.ap-northeast-2.elasticbeanstalk.com"
2021/01/06 07:24:50 [error] 3544#0: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 222.108.35.81, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:5000/favicon.ico", host: "couponservice-env.eba-7apfigmx.ap-northeast-2.elasticbeanstalk.com", referrer: "http://couponservice-env.eba-7apfigmx.ap-northeast-2.elasticbeanstalk.com/"
2021/01/06 07:25:11 [error] 3544#0: *9 connect() failed (111: Connection refused) while connecting to upstream, client: 222.108.35.81, server: , request: "POST /couponapi/coupons HTTP/1.1", upstream: "http://127.0.0.1:5000/couponapi/coupons", host: "couponservice-env.eba-7apfigmx.ap-northeast-2.elasticbeanstalk.com"


----------------------------------------
/var/log/eb-engine.log
----------------------------------------
2021/01/06 07:21:09.211870 [INFO] Running command /bin/sh -c systemctl show -p PartOf healthd.service
2021/01/06 07:21:09.216802 [INFO] Running command /bin/sh -c systemctl is-active healthd.service
2021/01/06 07:21:09.220123 [INFO] Running command /bin/sh -c systemctl start healthd.service
2021/01/06 07:21:09.259532 [INFO] Copying file /opt/elasticbeanstalk/config/private/healthd/healthd_logformat.conf to /var/proxy/staging/nginx/conf.d/healthd_logformat.conf
2021/01/06 07:21:09.260732 [INFO] Copying file /opt/elasticbeanstalk/config/private/healthd/healthd_nginx.conf to /var/proxy/staging/nginx/conf.d/elasticbeanstalk/healthd.conf
2021/01/06 07:21:09.262012 [INFO] Executing instruction: configure log streaming
2021/01/06 07:21:09.262023 [INFO] log streaming is not enabled
2021/01/06 07:21:09.262027 [INFO] disable log stream
2021/01/06 07:21:09.262046 [INFO] Running command /bin/sh -c systemctl show -p PartOf amazon-cloudwatch-agent.service
2021/01/06 07:21:09.270643 [INFO] Running command /bin/sh -c systemctl stop amazon-cloudwatch-agent.service
2021/01/06 07:21:09.281164 [INFO] Executing instruction: GetToggleForceRotate
2021/01/06 07:21:09.281181 [INFO] Checking if logs need forced rotation
2021/01/06 07:21:09.281203 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:ap-northeast-2:908803455527:stack/awseb-e-parj2s23pb-stack/810a0e30-4fef-11eb-ab7d-02ea5112e8c2 -r AWSEBAutoScalingGroup --region ap-northeast-2
2021/01/06 07:21:09.852882 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:ap-northeast-2:908803455527:stack/awseb-e-parj2s23pb-stack/810a0e30-4fef-11eb-ab7d-02ea5112e8c2 -r AWSEBBeanstalkMetadata --region ap-northeast-2
2021/01/06 07:21:10.418675 [INFO] Generating rsyslog config from Procfile
2021/01/06 07:21:10.420226 [INFO] Running command /bin/sh -c systemctl restart rsyslog.service
2021/01/06 07:21:10.437082 [INFO] Executing instruction: PostBuildEbExtension
2021/01/06 07:21:10.437101 [INFO] Starting executing the config set Infra-EmbeddedPostBuild.
2021/01/06 07:21:10.437120 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-init -s arn:aws:cloudformation:ap-northeast-2:908803455527:stack/awseb-e-parj2s23pb-stack/810a0e30-4fef-11eb-ab7d-02ea5112e8c2 -r AWSEBAutoScalingGroup --region ap-northeast-2 --configsets Infra-EmbeddedPostBuild
2021/01/06 07:21:10.805240 [INFO] Finished executing the config set Infra-EmbeddedPostBuild.

2021/01/06 07:21:10.805258 [INFO] Executing instruction: CleanEbExtensions
2021/01/06 07:21:10.805287 [INFO] Cleaned ebextensions subdirectories from app staging directory.
2021/01/06 07:21:10.805292 [INFO] Executing instruction: RunAppDeployPreDeployHooks
2021/01/06 07:21:10.805300 [INFO] The dir .platform/hooks/predeploy/ does not exist in the application. Skipping this step...
2021/01/06 07:21:10.805316 [INFO] Executing instruction: stop X-Ray
2021/01/06 07:21:10.805320 [INFO] stop X-Ray ...
2021/01/06 07:21:10.805343 [INFO] Running command /bin/sh -c systemctl show -p PartOf xray.service
2021/01/06 07:21:10.811931 [WARN] stopProcess Warning: process xray is not registered 
2021/01/06 07:21:10.811961 [INFO] Running command /bin/sh -c systemctl stop xray.service
2021/01/06 07:21:10.819094 [INFO] Executing instruction: stop proxy
2021/01/06 07:21:10.819116 [INFO] Running command /bin/sh -c systemctl show -p PartOf httpd.service
2021/01/06 07:21:10.823306 [WARN] deregisterProcess Warning: process httpd is not registered, skipping...

2021/01/06 07:21:10.823337 [INFO] Running command /bin/sh -c systemctl show -p PartOf nginx.service
2021/01/06 07:21:10.829206 [WARN] deregisterProcess Warning: process nginx is not registered, skipping...

2021/01/06 07:21:10.829230 [INFO] Executing instruction: FlipApplication
2021/01/06 07:21:10.829235 [INFO] Fetching environment variables...
2021/01/06 07:21:10.829325 [INFO] Purge old process...
2021/01/06 07:21:10.829370 [INFO] Register application processes...
2021/01/06 07:21:10.829376 [INFO] Registering the proc: web

2021/01/06 07:21:10.829389 [INFO] Running command /bin/sh -c systemctl show -p PartOf web.service
2021/01/06 07:21:10.835429 [INFO] Running command /bin/sh -c systemctl daemon-reload
2021/01/06 07:21:10.908738 [INFO] Running command /bin/sh -c systemctl reset-failed
2021/01/06 07:21:10.912741 [INFO] Running command /bin/sh -c systemctl is-enabled eb-app.target
2021/01/06 07:21:10.916222 [INFO] Copying file /opt/elasticbeanstalk/config/private/aws-eb.target to /etc/systemd/system/eb-app.target
2021/01/06 07:21:10.917734 [INFO] Running command /bin/sh -c systemctl enable eb-app.target
2021/01/06 07:21:11.000983 [INFO] Running command /bin/sh -c systemctl start eb-app.target
2021/01/06 07:21:11.006200 [INFO] Running command /bin/sh -c systemctl enable web.service
2021/01/06 07:21:11.093044 [INFO] Running command /bin/sh -c systemctl show -p PartOf web.service
2021/01/06 07:21:11.097989 [INFO] Running command /bin/sh -c systemctl is-active web.service
2021/01/06 07:21:11.101314 [INFO] Running command /bin/sh -c systemctl start web.service
2021/01/06 07:21:11.115896 [INFO] Executing instruction: start X-Ray
2021/01/06 07:21:11.115910 [INFO] X-Ray is not enabled.
2021/01/06 07:21:11.115915 [INFO] Executing instruction: start proxy with new configuration
2021/01/06 07:21:11.115939 [INFO] Running command /bin/sh -c /usr/sbin/nginx -t -c /var/proxy/staging/nginx/nginx.conf
2021/01/06 07:21:11.136081 [INFO] Running command /bin/sh -c cp -rp /var/proxy/staging/nginx/* /etc/nginx
2021/01/06 07:21:11.139384 [INFO] Running command /bin/sh -c systemctl show -p PartOf nginx.service
2021/01/06 07:21:11.147234 [INFO] Running command /bin/sh -c systemctl daemon-reload
2021/01/06 07:21:11.235279 [INFO] Running command /bin/sh -c systemctl reset-failed
2021/01/06 07:21:11.244986 [INFO] Running command /bin/sh -c systemctl show -p PartOf nginx.service
2021/01/06 07:21:11.254903 [INFO] Running command /bin/sh -c systemctl is-active nginx.service
2021/01/06 07:21:11.262544 [INFO] Running command /bin/sh -c systemctl start nginx.service
2021/01/06 07:21:11.344371 [INFO] Executing instruction: configureSqsd
2021/01/06 07:21:11.344388 [INFO] This is a web server environment instance, skip configure sqsd daemon ...
2021/01/06 07:21:11.344393 [INFO] Executing instruction: startSqsd
2021/01/06 07:21:11.344397 [INFO] This is a web server environment instance, skip start sqsd daemon ...
2021/01/06 07:21:11.344401 [INFO] Executing instruction: Track pids in healthd
2021/01/06 07:21:11.344405 [INFO] This is an enhanced health env...
2021/01/06 07:21:11.344424 [INFO] Running command /bin/sh -c systemctl show -p ConsistsOf aws-eb.target | cut -d= -f2
2021/01/06 07:21:11.359446 [INFO] cfn-hup.service healthd.service nginx.service

2021/01/06 07:21:11.359494 [INFO] Running command /bin/sh -c systemctl show -p ConsistsOf eb-app.target | cut -d= -f2
2021/01/06 07:21:11.378785 [INFO] web.service

2021/01/06 07:21:11.378913 [INFO] Executing instruction: RunAppDeployPostDeployHooks
2021/01/06 07:21:11.378925 [INFO] The dir .platform/hooks/postdeploy/ does not exist in the application. Skipping this step...
2021/01/06 07:21:11.378930 [INFO] Executing cleanup logic
2021/01/06 07:21:11.379030 [INFO] CommandService Response: {"status":"SUCCESS","api_version":"1.0","results":[{"status":"SUCCESS","msg":"Engine execution has succeeded.","returncode":0,"events":[{"msg":"Instance deployment successfully detected a JAR file in your source bundle.","timestamp":1609917668,"severity":"INFO"},{"msg":"Instance deployment successfully generated a 'Procfile'.","timestamp":1609917668,"severity":"INFO"},{"msg":"Instance deployment completed successfully.","timestamp":1609917671,"severity":"INFO"}]}]}

2021/01/06 07:21:11.379165 [INFO] Platform Engine finished execution on command: app-deploy

2021/01/06 07:25:23.304531 [INFO] Starting...
2021/01/06 07:25:23.304584 [INFO] Starting EBPlatform-PlatformEngine
2021/01/06 07:25:23.304608 [INFO] reading event message file
2021/01/06 07:25:23.304721 [INFO] no eb envtier info file found, skip loading env tier info.
2021/01/06 07:25:23.304787 [INFO] Engine received EB command cfn-hup-exec

2021/01/06 07:25:23.422026 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:ap-northeast-2:908803455527:stack/awseb-e-parj2s23pb-stack/810a0e30-4fef-11eb-ab7d-02ea5112e8c2 -r AWSEBAutoScalingGroup --region ap-northeast-2
2021/01/06 07:25:24.160493 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:ap-northeast-2:908803455527:stack/awseb-e-parj2s23pb-stack/810a0e30-4fef-11eb-ab7d-02ea5112e8c2 -r AWSEBBeanstalkMetadata --region ap-northeast-2
2021/01/06 07:25:24.503333 [INFO] checking whether command tail-log is applicable to this instance...
2021/01/06 07:25:24.503346 [INFO] this command is applicable to the instance, thus instance should execute command
2021/01/06 07:25:24.503350 [INFO] Engine command: (tail-log)

2021/01/06 07:25:24.503401 [INFO] Executing instruction: GetTailLogs
2021/01/06 07:25:24.503406 [INFO] Tail Logs...
2021/0

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This looks like Inbound Rules issue. In the AWS tutorial that uses a web application that uses AWS RDS, Inbound Rules are mentioned. You need to make sure the IP address of the Elastic Beanstalk instance is specified. If you do not do this, then the connection does not work.

Here is the AWS RDS tutorial that discusses this subject matter:

https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/usecases/Creating_rds_item_tracker


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...