提问人:JCMcRae 提问时间:10/17/2023 最后编辑:AzeemJCMcRae 更新时间:10/22/2023 访问量:90
MySQL 容器无法在 GitHub Actions 中启动
MySQL Container Fails to Start in GitHub Actions
问:
我正在尝试在 GitHub Actions 中为 CI 设置一个 Rails 应用程序,该应用程序使用 MySQL 进行持久性。我的样子是这样的:main.yml
name: CI
on:
pull_request:
branches: ['*']
push:
branches: ['*']
jobs:
build:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8
env:
MYSQL_HOST: 127.0.0.1
MYSQL_DATABASE: SHOP_test
MYSQL_USER: ${{secrets.MYSQL_USER}}
MYSQL_PASSWORD: ${{secrets.MYSQL_PASSWORD}}
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v2
- name: Setup Ruby 3.2.2
uses: ruby/setup-ruby@v1
with:
bundler: default
bundler-cache: true
- name: Install dependent libraries
run: sudo apt-get install mysql-server
- name: Bundle install
run: |
gem install bundler
bundle install --jobs 4 --retry 3
- name: Setup Database
run: |
bundle exec rake db:create
bundle exec rake db:schema:load
env:
RAILS_ENV: test
MYSQL_USER: root
MYSQL_PASSWORD: root
- name: Run RSpec
run: COVERAGE=true bundle exec rspec --require rails_helper
env:
RAILS_ENV: test
MYSQL_USER: root
MYSQL_PASSWORD: root
当我将一些代码推送到远程分支时,它会成功设置作业,但是当它需要初始化容器时,它会启动MySQL,然后停止服务器并返回错误。
GitHub 在操作控制台中返回以下内容:
/usr/bin/docker logs --details fe4f75e7be4cf7269b7e25a45ac808125db82578ea683e5b36baf50ab8bd3535
2023-10-16 02:18:55+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.1.0-1.el8 started.
2023-10-16T02:18:56.007684Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2023-10-16 02:18:55+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
Warning: 2023-10-16T02:18:56.009607Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-10-16 02:18:55+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.1.0-1.el8 started.
2023-10-16T02:18:56.009701Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.1.0) initializing of server in progress as process 80
2023-10-16T02:18:56.016595Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-10-16T02:18:56.316133Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
Warning: 2023-10-16T02:18:57.312550Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2023-10-16T02:18:59.151999Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.
2023-10-16T02:18:59.205278Z 0 [System] [MY-015015] [Server] MySQL Server - start.
Warning: 2023-10-16T02:18:59.443722Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-10-16T02:18:59.445793Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.1.0) starting as process 122
2023-10-16T02:18:59.458386Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-10-16T02:18:59.620820Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
Warning: 2023-10-16T02:18:59.812258Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-10-16T02:18:59.812293Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
Warning: 2023-10-16T02:18:59.813696Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2023-10-16T02:18:59.830687Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
2023-10-16T02:18:59.830941Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.1.0' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server - GPL.
2023-10-16T02:18:59.833484Z 0 [System] [MY-015016] [Server] MySQL Server - end.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2023-10-16T02:19:01.763894Z 13 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.1.0).
2023-10-16T02:19:03.296520Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.1.0) MySQL Community Server - GPL.
2023-10-16T02:19:03.299884Z 0 [System] [MY-015016] [Server] MySQL Server - end.
2023-10-16T02:19:03.780491Z 0 [System] [MY-015015] [Server] MySQL Server - start.
Warning: 2023-10-16T02:19:04.010820Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-10-16T02:19:04.012121Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.1.0) starting as process 1
2023-10-16T02:19:04.019105Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-10-16T02:19:04.164169Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
Warning: 2023-10-16T02:19:04.319860Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-10-16T02:19:04.319900Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
Warning: 2023-10-16T02:19:04.321297Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2023-10-16T02:19:04.338712Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2023-10-16T02:19:04.339257Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.1.0' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
2023-10-16 02:18:55+00:00 [Note] [Entrypoint]: Initializing database files
2023-10-16 02:18:59+00:00 [Note] [Entrypoint]: Database files initialized
2023-10-16 02:18:59+00:00 [Note] [Entrypoint]: Starting temporary server
2023-10-16 02:18:59+00:00 [Note] [Entrypoint]: Temporary server started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2023-10-16 02:19:01+00:00 [Note] [Entrypoint]: Creating database SHOP_test
2023-10-16 02:19:01+00:00 [Note] [Entrypoint]: Creating user ***
2023-10-16 02:19:01+00:00 [Note] [Entrypoint]: Giving user *** access to schema SHOP_test
2023-10-16 02:19:01+00:00 [Note] [Entrypoint]: Stopping temporary server
2023-10-16 02:19:03+00:00 [Note] [Entrypoint]: Temporary server stopped
2023-10-16 02:19:03+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
Error: Failed to initialize container mysql:8
Error: One or more containers failed to start.
我不确定我在设置中做错了什么或遗漏了什么。我是否为此添加了不必要的内容,或者我是否遗漏了 GitHub 需要的东西?.yml
答:
1赞
Alec DuBois
10/19/2023
#1
可能与您的健康检查有关 - 这是;在这种情况下,您运行的是 mysql:8,所以应该是 .我只是在调试类似的东西,这纠正了它,所以试试吧。--health-cmd pg_isready
--health-cmd mysqladmin ping
另外,作为一个可能的陷阱,我很确定mysql docker映像不允许你再设置MYSQL_USER,所以确保你没有这样做root
评论
0赞
JCMcRae
10/21/2023
这似乎确实奏效了。我认为你对这个变量的看法是正确的,因为这是我的下一个错误,所以我接下来要研究这个问题,我认为 SO 已经有关于这方面的文章了。感谢您的帮助!MYSQL_USER
0赞
JCMcRae
10/21/2023
另外,我认为你可能有一个额外的破折号---health-cmd mysqladmin ping
0赞
Alec DuBois
10/22/2023
谢谢!更新。此外,如果您愿意作为用户,您可以省略,因为这是该 env var 的默认值MYSQL_USER
root
0赞
JCMcRae
10/24/2023
好的,再来一个。如果它告诉我它是怎么办?unable to find image ping:local locally
评论