前提・実現したいこと
前提
Ruby on Rails6にてアプリを作成
AWS amazon linux2
デプロイ作業を行いました
実現したいこと
本番環境でRailsを起動させたい
発生している問題・エラーメッセージ
ターミナル [ec2-user@********** Dr_tetsu]$ less log/unicorn.stderr.log I, [2020-12-07T06:03:34.092137 #12835] INFO -- : Refreshing Gem list I, [2020-12-07T06:03:36.545685 #12835] INFO -- : listening on addr=0.0.0.0:3000 fd=11 E, [2020-12-07T06:03:36.546263 #12835] ERROR -- : Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (Mysql2::Error::ConnectionError) /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `connect' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `initialize' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/mysql2_adapter.rb:24:in `new' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/mysql2_adapter.rb:24:in `mysql2_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:887:in `new_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `checkout_new_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:910:in `try_to_checkout_new_connection'
該当するソースコード
database.yml # MySQL. Versions 5.5.8 and up are supported. # # Install the MySQL driver # gem install mysql2 # # Ensure the MySQL gem is defined in your Gemfile # gem 'mysql2' # # And be sure to use new-style password hashing: # https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html # default: &default adapter: mysql2 encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root password: kenichi1203 socket: /tmp/mysql.sock development: <<: *default database: Dr_tetsu_development # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default database: Dr_tetsu_test # As with config/credentials.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is # ever seen by anyone, they now have access to your database. # # Instead, provide the password as a unix environment variable when you boot # the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database # for a full rundown on how to provide these environment variables in a # production deployment. # # On Heroku and other platform providers, you may have a full connection URL # available as an environment variable. For example: # # DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" # # You can use this database configuration with: # # production: # url: <%= ENV['DATABASE_URL'] %> # production: <<: *default database: Dr_tetsu_production username: root password: <%= ENV['DATABASE_PASSWORD'] %> socket: /var/lib/mysql/mysql.sock
試したこと(仮説)
ERROR -- : Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
上記のエラー内容で検索行い下記のリンクを参考にしましたが変化はありませんでした。
リンク内容
リンク内容
リンク内容
仮説として上記のリンクを参照した際に
[ec2-user@******** Dr_tetsu]$ sudo mysql.server start sudo: mysql.server: コマンドが見つかりません
とMy SQL が起動していないのが原因なのでしょうか??
補足
初心者で言葉足らずで申し訳ありませんがご教示頂けたらと思い質問させて頂きました。
宜しくお願い致します。
補足2
/log/unicorn.stderr.log /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:205:in `pid=': Already running on PID:18695 (or pid=/var/www/Dr_tetsu/tmp/pids/unicorn.pid is stale) (ArgumentError) from /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:137:in `start' from /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' from /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `load' from /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `<main>' I, [2020-12-10T06:22:53.949207 #18695] INFO -- : reaped #<Process::Status: pid 18699 exit 0> worker=0 I, [2020-12-10T06:22:53.949342 #18695] INFO -- : master complete I, [2020-12-10T06:22:57.328776 #18777] INFO -- : Refreshing Gem list I, [2020-12-10T06:22:58.956594 #18777] INFO -- : listening on addr=0.0.0.0:3000 fd=11 I, [2020-12-10T06:22:58.962392 #18777] INFO -- : master process ready I, [2020-12-10T06:22:58.967624 #18781] INFO -- : worker=0 ready I, [2020-12-10T06:25:16.316706 #18777] INFO -- : reaped #<Process::Status: pid 18781 exit 0> worker=0 I, [2020-12-10T06:25:16.316854 #18777] INFO -- : master complete I, [2020-12-10T06:25:50.238430 #18956] INFO -- : Refreshing Gem list I, [2020-12-10T06:25:51.895253 #18956] INFO -- : listening on addr=0.0.0.0:3000 fd=11 I, [2020-12-10T06:25:51.901216 #18956] INFO -- : master process ready :
あなたの回答
tips
プレビュー