2018年07月15日
如果你最近使用群晖套件中心的 GitLab( 9.4.4-0050 ) ,并且勾选转换数据库( MariaDB => postgresql ),那么你很可能遇到丢失数据的问题( Version: 10.6.4-0051 ).表现为打开 GitLab 首页提示设置 root 密码,登录后台显示所有项目丢失.
故障的原因是群晖”借鉴”的 MySQL to PostgreSQL Converter 项目存在一些问题 .群晖内的具体路径为/volume1/@appstore/Docker-GitLab/mysql-postgresql-converter/db_converter.py
,转换时会发生UnicodeDecodeError: 'utf8' codec can't decode byte 0x9c
错误.截至目前尚有 30 个 PR 未处理.群晖科技在自家稳定版产品中未确认方案普适性,原项目首页强调 use with care 被无视,置客户数据安全于不顾,最终导致悲剧发生.后续我会专门谈一谈为什么 synology NAS 是危险的产品,选购群晖是对数据的不负责行为.本篇只说怎么找回你宝贵的数据.
修改 docker 环境变量,使用原 MariaDB 数据库
- 使用 admin 组的账户登录群晖 SSH .警告: 如果你不知道这步怎么操作,本修复指南可能对你来说较复杂,极易出现数据丢失.请向技术人员求助.
- 如果之前没有执行过备份(
bundle exec rake gitlab:backup:create RAILS_ENV=production
),那么执行下备份.路径类似/volume1/docker/gitlab/
. - 为 gitlab_user 授权.如果不熟悉 SQL 可以在套件中心中安装 phpMyAdmin ,然后在权限中增加用户账户的 host name 为
172.17.0.%
. - 测试数据库权限:
docker exec -it synology_gitlab bash # 进入容器终端 mysql -u gitlab_user -p -h 172.17.0.1 -P 3307 # 测试数据库链接情况 exit # 退出容器
- 套件中心 => 已安装 => GitLab => 停止.
- docker => synology_gitlab => 编辑 => 环境变量
DB_PORT 3307 DB_TYPE mysql DB_HOST 172.17.0.1
- 套件中心 => 已安装 => GitLab => 启动.
修复数据库故障
GitLab 官方明确表示不推荐使用 MariaDB / MySQL 数据库. 群晖由于某种原因仍然在使用 MariaDB 10 .本部分重点解决各类数据库问题.
- 停止 GitLab 服务
service gitlab stop
. - 登录 MariaDB 或直接使用 phpMyAdmin .让数据库支持长索引.
use gitlab; SET storage_engine=INNODB; SET GLOBAL innodb_file_per_table=1, innodb_file_format=Barracuda, innodb_large_prefix=1; SET GLOBAL log_bin_trust_function_creators = 1;
- 转换原有数据使用 utf8mb4 编码.注意下面的命令每一条的回显都要作为 SQL 语句再执行.
SELECT CONCAT('ALTER TABLE `', TABLE_NAME,'` ROW_FORMAT=DYNAMIC;') AS 'Copy & run these SQL statements:' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA="gitlab" AND TABLE_TYPE="BASE TABLE" AND ROW_FORMAT!="Dynamic";
回显类似
ALTER TABLE `abuse_reports` ROW_FORMAT=DYNAMIC; ALTER TABLE `appearances` ROW_FORMAT=DYNAMIC; ALTER TABLE `application_settings` ROW_FORMAT=DYNAMIC; ALTER TABLE `audit_events` ROW_FORMAT=DYNAMIC; ALTER TABLE `award_emoji` ROW_FORMAT=DYNAMIC; ALTER TABLE `boards` ROW_FORMAT=DYNAMIC; ALTER TABLE `broadcast_messages` ROW_FORMAT=DYNAMIC; ALTER TABLE `chat_names` ROW_FORMAT=DYNAMIC; ALTER TABLE `chat_teams` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_build_trace_section_names` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_build_trace_sections` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_builds` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_group_variables` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_job_artifacts` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_pipeline_schedule_variables` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_pipeline_schedules` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_pipeline_variables` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_pipelines` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_runner_projects` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_runners` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_stages` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_trigger_requests` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_triggers` ROW_FORMAT=DYNAMIC; ALTER TABLE `ci_variables` ROW_FORMAT=DYNAMIC; ALTER TABLE `cluster_platforms_kubernetes` ROW_FORMAT=DYNAMIC; ALTER TABLE `cluster_projects` ROW_FORMAT=DYNAMIC; ALTER TABLE `cluster_providers_gcp` ROW_FORMAT=DYNAMIC; ALTER TABLE `clusters` ROW_FORMAT=DYNAMIC; ALTER TABLE `clusters_applications_helm` ROW_FORMAT=DYNAMIC; ALTER TABLE `container_repositories` ROW_FORMAT=DYNAMIC; ALTER TABLE `conversational_development_index_metrics` ROW_FORMAT=DYNAMIC; ALTER TABLE `deploy_keys_projects` ROW_FORMAT=DYNAMIC; ALTER TABLE `deployments` ROW_FORMAT=DYNAMIC; ALTER TABLE `emails` ROW_FORMAT=DYNAMIC; ALTER TABLE `environments` ROW_FORMAT=DYNAMIC; ALTER TABLE `events` ROW_FORMAT=DYNAMIC; ALTER TABLE `feature_gates` ROW_FORMAT=DYNAMIC; ALTER TABLE `features` ROW_FORMAT=DYNAMIC; ALTER TABLE `fork_network_members` ROW_FORMAT=DYNAMIC; ALTER TABLE `fork_networks` ROW_FORMAT=DYNAMIC; ALTER TABLE `forked_project_links` ROW_FORMAT=DYNAMIC; ALTER TABLE `gcp_clusters` ROW_FORMAT=DYNAMIC; ALTER TABLE `gpg_key_subkeys` ROW_FORMAT=DYNAMIC; ALTER TABLE `gpg_keys` ROW_FORMAT=DYNAMIC; ALTER TABLE `gpg_signatures` ROW_FORMAT=DYNAMIC; ALTER TABLE `group_custom_attributes` ROW_FORMAT=DYNAMIC; ALTER TABLE `identities` ROW_FORMAT=DYNAMIC; ALTER TABLE `issue_assignees` ROW_FORMAT=DYNAMIC; ALTER TABLE `issue_metrics` ROW_FORMAT=DYNAMIC; ALTER TABLE `issues` ROW_FORMAT=DYNAMIC; ALTER TABLE `keys` ROW_FORMAT=DYNAMIC; ALTER TABLE `label_links` ROW_FORMAT=DYNAMIC; ALTER TABLE `label_priorities` ROW_FORMAT=DYNAMIC; ALTER TABLE `labels` ROW_FORMAT=DYNAMIC; ALTER TABLE `lfs_objects` ROW_FORMAT=DYNAMIC; ALTER TABLE `lfs_objects_projects` ROW_FORMAT=DYNAMIC; ALTER TABLE `lists` ROW_FORMAT=DYNAMIC; ALTER TABLE `members` ROW_FORMAT=DYNAMIC; ALTER TABLE `merge_request_diff_commits` ROW_FORMAT=DYNAMIC; ALTER TABLE `merge_request_diff_files` ROW_FORMAT=DYNAMIC; ALTER TABLE `merge_request_diffs` ROW_FORMAT=DYNAMIC; ALTER TABLE `merge_request_metrics` ROW_FORMAT=DYNAMIC; ALTER TABLE `merge_requests` ROW_FORMAT=DYNAMIC; ALTER TABLE `merge_requests_closing_issues` ROW_FORMAT=DYNAMIC; ALTER TABLE `milestones` ROW_FORMAT=DYNAMIC; ALTER TABLE `namespaces` ROW_FORMAT=DYNAMIC; ALTER TABLE `notes` ROW_FORMAT=DYNAMIC; ALTER TABLE `notification_settings` ROW_FORMAT=DYNAMIC; ALTER TABLE `oauth_access_grants` ROW_FORMAT=DYNAMIC; ALTER TABLE `oauth_access_tokens` ROW_FORMAT=DYNAMIC; ALTER TABLE `oauth_applications` ROW_FORMAT=DYNAMIC; ALTER TABLE `oauth_openid_requests` ROW_FORMAT=DYNAMIC; ALTER TABLE `pages_domains` ROW_FORMAT=DYNAMIC; ALTER TABLE `personal_access_tokens` ROW_FORMAT=DYNAMIC; ALTER TABLE `project_authorizations` ROW_FORMAT=DYNAMIC; ALTER TABLE `project_auto_devops` ROW_FORMAT=DYNAMIC; ALTER TABLE `project_custom_attributes` ROW_FORMAT=DYNAMIC; ALTER TABLE `project_features` ROW_FORMAT=DYNAMIC; ALTER TABLE `project_group_links` ROW_FORMAT=DYNAMIC; ALTER TABLE `project_import_data` ROW_FORMAT=DYNAMIC; ALTER TABLE `project_statistics` ROW_FORMAT=DYNAMIC; ALTER TABLE `projects` ROW_FORMAT=DYNAMIC; ALTER TABLE `protected_branch_merge_access_levels` ROW_FORMAT=DYNAMIC; ALTER TABLE `protected_branch_push_access_levels` ROW_FORMAT=DYNAMIC; ALTER TABLE `protected_branches` ROW_FORMAT=DYNAMIC; ALTER TABLE `protected_tag_create_access_levels` ROW_FORMAT=DYNAMIC; ALTER TABLE `protected_tags` ROW_FORMAT=DYNAMIC; ALTER TABLE `push_event_payloads` ROW_FORMAT=DYNAMIC; ALTER TABLE `redirect_routes` ROW_FORMAT=DYNAMIC; ALTER TABLE `releases` ROW_FORMAT=DYNAMIC; ALTER TABLE `routes` ROW_FORMAT=DYNAMIC; ALTER TABLE `schema_migrations` ROW_FORMAT=DYNAMIC; ALTER TABLE `sent_notifications` ROW_FORMAT=DYNAMIC; ALTER TABLE `services` ROW_FORMAT=DYNAMIC; ALTER TABLE `snippets` ROW_FORMAT=DYNAMIC; ALTER TABLE `spam_logs` ROW_FORMAT=DYNAMIC; ALTER TABLE `subscriptions` ROW_FORMAT=DYNAMIC; ALTER TABLE `system_note_metadata` ROW_FORMAT=DYNAMIC; ALTER TABLE `taggings` ROW_FORMAT=DYNAMIC; ALTER TABLE `tags` ROW_FORMAT=DYNAMIC; ALTER TABLE `timelogs` ROW_FORMAT=DYNAMIC; ALTER TABLE `todos` ROW_FORMAT=DYNAMIC; ALTER TABLE `trending_projects` ROW_FORMAT=DYNAMIC; ALTER TABLE `u2f_registrations` ROW_FORMAT=DYNAMIC; ALTER TABLE `uploads` ROW_FORMAT=DYNAMIC; ALTER TABLE `user_agent_details` ROW_FORMAT=DYNAMIC; ALTER TABLE `user_custom_attributes` ROW_FORMAT=DYNAMIC; ALTER TABLE `user_synced_attributes_metadata` ROW_FORMAT=DYNAMIC; ALTER TABLE `users` ROW_FORMAT=DYNAMIC; ALTER TABLE `users_star_projects` ROW_FORMAT=DYNAMIC; ALTER TABLE `web_hook_logs` ROW_FORMAT=DYNAMIC; ALTER TABLE `web_hooks` ROW_FORMAT=DYNAMIC;');
- 转换原有数据使用新的表空间( tablespace )格式.注意下面的命令每一条的回显都要作为 SQL 语句再执行.
SET foreign_key_checks = 0; SELECT CONCAT('ALTER TABLE `', TABLE_NAME,'` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;') AS 'Copy & run these SQL statements:' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA="gitlab" AND TABLE_COLLATION != "utf8mb4_general_ci" AND TABLE_TYPE="BASE TABLE";
回显类似
ALTER TABLE `abuse_reports` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `appearances` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `application_settings` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `audit_events` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `award_emoji` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `boards` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `broadcast_messages` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `chat_names` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `chat_teams` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_build_trace_section_names` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_build_trace_sections` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_builds` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_group_variables` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_job_artifacts` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_pipeline_schedule_variables` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_pipeline_schedules` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_pipeline_variables` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_pipelines` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_runner_projects` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_runners` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_stages` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_trigger_requests` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_triggers` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `ci_variables` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `cluster_platforms_kubernetes` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `cluster_projects` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `cluster_providers_gcp` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `clusters` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `clusters_applications_helm` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `container_repositories` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `conversational_development_index_metrics` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `deploy_keys_projects` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `deployments` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `emails` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `environments` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `events` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `feature_gates` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `features` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `fork_network_members` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `fork_networks` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `forked_project_links` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `gcp_clusters` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `gpg_key_subkeys` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `gpg_keys` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `gpg_signatures` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `group_custom_attributes` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `identities` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `issue_assignees` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `issue_metrics` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `issues` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `keys` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `label_links` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `label_priorities` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `labels` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `lfs_objects` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `lfs_objects_projects` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `lists` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `members` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `merge_request_diff_commits` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `merge_request_diff_files` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `merge_request_diffs` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `merge_request_metrics` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `merge_requests` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `merge_requests_closing_issues` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `milestones` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `namespaces` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `notes` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `notification_settings` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `oauth_access_grants` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `oauth_access_tokens` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `oauth_applications` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `oauth_openid_requests` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `pages_domains` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `personal_access_tokens` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `project_authorizations` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `project_auto_devops` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `project_custom_attributes` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `project_features` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `project_group_links` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `project_import_data` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `project_statistics` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `projects` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `protected_branch_merge_access_levels` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `protected_branch_push_access_levels` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `protected_branches` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `protected_tag_create_access_levels` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `protected_tags` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `push_event_payloads` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `redirect_routes` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `releases` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `routes` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `schema_migrations` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `sent_notifications` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `services` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `snippets` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `spam_logs` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `subscriptions` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `system_note_metadata` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `taggings` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `tags` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `timelogs` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `todos` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `trending_projects` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `u2f_registrations` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `uploads` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `user_agent_details` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `user_custom_attributes` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `user_synced_attributes_metadata` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `users` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `users_star_projects` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `web_hook_logs` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE `web_hooks` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; SET foreign_key_checks = 1;
- 执行数据库限制任务.
bundle exec rake add_limits_mysql RAILS_ENV=production
- 修改数据库迁移任务.由于 GitLab 官方要求不允许跨多个小版本升级,所以我们会遇到一些奇怪的错误,这里给出一些修复方案,我只遇到了一个.
Mysql2::Error: Index column size too large. The maximum column size is 767 bytes.: CREATE UNIQUE INDEX `index_lfs_file_locks_on_project_id_and_path` ON `lfs_file_locks` (`project_id`, `path`)
解决方案:
use gitlab; DROP TABLE lfs_file_locks;
# db/migrate/20180116193854_create_lfs_file_locks.rb # create_table :lfs_file_locks do |t| 修改为 create_table :lfs_file_locks, options: 'ROW_FORMAT=DYNAMIC' do |t|
- 执行数据库迁移.
bundle exec rake db:migrate
预编译资源
bundle exec rake gettext:compile RAILS_ENV=production
bundle exec rake yarn:install gitlab:assets:clean gitlab:assets:compile RAILS_ENV=production NODE_ENV=production
bundle exec rake cache:clear RAILS_ENV=production
备份与恢复
bundle exec rake gitlab:backup:create RAILS_ENV=production # 你会找到一个类似 /home/git/data/backups/1531046569_2018_07_14_10.6.4_gitlab_backup.tar 的文件
bundle exec rake gitlab:backup:restore RAILS_ENV=production