docker-compose.yml 这是我的 docker-compose 文件,用于使用 docker-stack 在多个实例中部署服务。如您所见,应用程序服务是在 2 个节点中运行的 laravel 和在其中一个节点中运行的数据库(mysql)。
完整代码库: https ://github.com/taragurung/Ci-CD-docker-swarm
version: '3.4'
networks:
smstake:
ipam:
config:
- subnet: 10.0.10.0/24
services:
db:
image: mysql:5.7
networks:
- smstake
ports:
- "3306"
env_file:
- configuration.env
environment:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
MYSQL_DATABASE: ${DB_NAME}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}
volumes:
- mysql_data:/var/lib/mysql
deploy:
mode: replicated
replicas: 1
app:
image: SMSTAKE_VERSION
ports:
- 8000:80
networks:
- smstake
depends_on:
- db
deploy:
mode: replicated
replicas: 2
我面临的问题。 1. 虽然在查看服务日志时服务处于运行状态,但我只能看到迁移在一个节点上成功,而在另一个节点上没有运行。请参阅下面的日志
- 当我使应用程序服务仅在管理器节点中运行时,应用程序运行得很好。我可以登录页面并执行所有操作,但是当我仅使用副本使应用程序服务在任何节点中运行时,登录页面就会显示,但是当尝试登录时,它会重定向到 NOT FOUND 页面
这是尝试在 3 个节点上运行时的完整日志。Bellow 是在 2 个节点上运行时的示例。您可以详细查看迁移问题 https://pastebin.com/wqjxSnv2
使用检查的服务日志docker service logs <smstake_app>
| Cache cleared successfully.
| Configuration cache cleared!
| Dropped all tables successfully.
| Migration table created successfully.
|
| In Connection.php line 664:
|
| SQLSTATE[42S02]: Base table or view not found: 1146 Table 'smstake.migratio
| ns' doesn't exist (SQL: insert into `migrations` (`migration`, `batch`) val
| ues (2014_10_12_100000_create_password_resets_table, 1))
|
|
| In Connection.php line 452:
|
| SQLSTATE[42S02]: Base table or view not found: 1146 Table 'smstake.migratio
| ns' doesn't exist
|
|
| Laravel development server started: <http://0.0.0.0:80>
| PHP 7.1.16 Development Server started at Thu Apr 5 07:02:22 2018
| [Thu Apr 5 07:03:56 2018] 10.255.0.14:53744 [200]: /js/app.js
| Cache cleared successfully.
| Configuration cache cleared!
| Dropped all tables successfully.
| Migration table created successfully.
| Migrating: 2014_10_12_000000_create_users_table
| Migrated: 2014_10_12_000000_create_users_table
| Migrating: 2014_10_12_100000_create_password_resets_table
| Migrated: 2014_10_12_100000_create_password_resets_table
| Migrating: 2018_01_11_235754_create_groups_table
| Migrated: 2018_01_11_235754_create_groups_table
| Migrating: 2018_01_12_085401_create_contacts_table
| Migrated: 2018_01_12_085401_create_contacts_table
| Migrating: 2018_01_12_140105_create_sender_ids_table
| Migrated: 2018_01_12_140105_create_sender_ids_table
| Migrating: 2018_02_06_152623_create_drafts_table
| Migrated: 2018_02_06_152623_create_drafts_table
| Migrating: 2018_02_21_141346_create_sms_table
| Migrated: 2018_02_21_141346_create_sms_table
| Seeding: UserTableSeeder
| Laravel development server started: <http://0.0.0.0:80>
| PHP 7.1.16 Development Server started at Thu Apr 5 07:03:23 2018
| [Thu Apr 5 07:03:56 2018] 10.255.0.14:53742 [200]: /css/app.css
不知道是移民问题还是什么。有时我可以登录,但在单击仪表板内的链接时,我再次被重定向到未找到页面。