DROP TABLE IF EXISTS `ci_builds`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `ci_builds` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`project_id` int(11) DEFAULT NULL,
`status` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`finished_at` datetime DEFAULT NULL,
`trace` longtext COLLATE utf8_unicode_ci,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`started_at` datetime DEFAULT NULL,
`runner_id` int(11) DEFAULT NULL,
`coverage` float DEFAULT NULL,
`commit_id` int(11) DEFAULT NULL,
`commands` text COLLATE utf8_unicode_ci,
`job_id` int(11) DEFAULT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`deploy` tinyint(1) DEFAULT '0',
`options` text COLLATE utf8_unicode_ci,
`allow_failure` tinyint(1) NOT NULL DEFAULT '0',
`stage` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`trigger_request_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_ci_builds_on_commit_id` (`commit_id`) USING BTREE,
KEY `index_ci_builds_on_project_id_and_commit_id` (`project_id`,`commit_id`) USING BTREE,
KEY `index_ci_builds_on_project_id` (`project_id`) USING BTREE,
KEY `index_ci_builds_on_runner_id` (`runner_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;DROP TABLE IF EXISTS `ci_commits`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `ci_commits` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`project_id` int(11) DEFAULT NULL,
`ref` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`sha` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`before_sha` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`push_data` mediumtext COLLATE utf8_unicode_ci,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`tag` tinyint(1) DEFAULT '0',
`yaml_errors` text COLLATE utf8_unicode_ci,
`committed_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_ci_commits_on_project_id_and_committed_at_and_id` (`project_id`,`committed_at`,`id`) USING BTREE,
KEY `index_ci_commits_on_project_id_and_committed_at` (`project_id`,`committed_at`) USING BTREE,
KEY `index_ci_commits_on_project_id_and_sha` (`project_id`,`sha`) USING BTREE,
KEY `index_ci_commits_on_project_id` (`project_id`) USING BTREE,
KEY `index_ci_commits_on_sha` (`sha`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
导入表结构
mysql -uroot -p gitlab_production < gitlab_builds.sql
执行迁移
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
重建缓存
sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production
3.6 配置更新
上面说过,虽然用git拉取了gitlab最新版本(8.0.1)但相关配置文件仍为7.9版本,因此需要更新
3.6.1 更新启动文件
#主目录
cd /usr/local/git/gitlab
#更新启动程序
cp lib/support/init.d/gitlab /etc/init.d/gitlab
#更新gitlab配置
cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
#需要修改/etc/default/gitlab文件,因为我们的gitlab安装在/usr/local/git下,并非默认目录/home/git
sed -i "s/home/usr\/local/g" /etc/default/gitlab
3.6.2 更新日志
cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
3.6.3 更新nginx配置文件
#更新gitlab的nginx配置
cp lib/support/nginx/gitlab /etc/nginx/conf.d/gitlab.conf
#同样,gitlab并非安装在默认目录,因此需要修改配置
sed -i "s/home/usr\/local/g" /etc/nginx/conf.d/gitlab.conf
3.6.4 更新gitlab.yml
cp config/gitlab.yml.example config/gitlab.yml
#当然,需要更改gitlab.yml中的配置,可以参考旧版本配置文件,新配置文件更改了一些结构,但大部分变量都沿用旧版本的
3.6.5 更新database.yml
cp config/database.yml.mysql config/database.yml
#也需要更新配置
3.6.6 更新gitlab-shell配置文件
cd /usr/local/git/gitlab-shell/
cp config.yml.example config.yml
#相关配置也要更新
4 测试gitlab8.0.1
4.1 启动gitlab
/etc/init.d/gitlab start
4.2 变量检查
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
4.3 检查所有模块是否运行正常
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
参考:
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/7.14-to-8.0.md
更多GitLab相关教程见以下内容: