gitlab 迁移、升级打怪之路:8.8.5--> 8.10.8 --> 8.17.8 --> 9.5.9 --> 10.1.4 --> 10.2.5

 gitlab 迁移、升级打怪之路:8.8.5--> 8.10.8 --> 8.17.8 --> 9.5.9 --> 10.1.4 --> 10.2.5

gitlab 数据迁移、升级打怪之路:8.8.5--> 8.10.8 --> 8.17.8 --> 9.5.9 --> 10.1.4 --> 10.2.5
打怪之路背景介绍:
    我们的gitlab服务器原先服务器版本是8.8.5,使用的是源码安装,每个插件单独安装,数据库使用的是mysql5.6.39,
    现在有个需求是升级gitlab的版本。现在最新的gitlab的版本是11.0.2
    https://about.gitlab.com/blog/categories/releases/
    gitlab的版本更新也真是快,所以这里我们决定升级。
    因为我们使用的是源码安装,升级不太方便,同时gitlab不支持跨版本的数据迁移。所以......看下面:
1、新买一台服务器使用rpm(或者yum)的方式安装gitlab-ce-8.8.5(我这里用的是rpm包)
2、在老的gitlab服务器上备份数据,然后导入到新服务器的gitlab上。
3、数据导入完毕后,开始一步一步的版本升级。本次版本升级的历程是这样的:
    8.8.5--> 8.10.8 --> 8.17.8 --> 9.5.9 --> 10.1.4 --> 10.2.5


gitlab 安装包下载路径:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

gitlab 上部署pages:https://www.chenxuefei.com/2017/build-gitlab-pages/

1、初始化服务器
cd /init
sudo sh init.sh live test-gitlab

2、下载gitlab对应版本的安装包。这里我们下载8.8.5
cd /data/tools
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.8.5-ce.1.el7.x86_64.rpm

3、这里我们因为要设置把默认的数据库postgrasql 修改为mysql
这里我们之前的mysql 是5.6
所以这里我们使用yum 的形式来安装mysql
centos自带的repo是不会自动更新每个软件的最新版本,所以无法通过yum方式安装MySQL的高级版本。
所以,即使使劲用yum -y install mysql mysql-server mysql-devel,也是没用的。
所以,正确的安装mysql5姿势是要先安装带有可用的mysql5系列社区版资源的rpm包
cd /data/tools
sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

这个时候查看当前可用的mysql安装资源:
[wwwad@test-gitlab tools]$ yum repolist enabled | grep "mysql.*-community*"
mysql-connectors-community/x86_64 MySQL Connectors Community                  51
mysql-tools-community/x86_64      MySQL Tools Community                       63
mysql56-community/x86_64          MySQL 5.6 Community Server                 395

这里我们只安装mysql-server  和  mysql-client
sudo yum -y install mysql-community-server
这里我们可以看到进度条中我们安装的是mysql5.6.40
 开机自启动
 sudo systemctl enable mysqld
 启动
 sudo systemctl start mysqld
 重置密码
 mysql_secure_installation
 
下面就是mysql有关gitlab的一些操作了
mysql> CREATE DATABASE IF NOT EXISTS`gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_general_ci`;
Query OK, 1 row affected (0.00 sec)


> GRANT SELECT, INSERT, UPDATE, DELETE,CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER, LOCK TABLES, REFERENCES ON`gitlabhq_production`.* TO 'git'@'localhost' identified by "123456";
Query OK, 0 rows affected (0.00 sec)

> flush privileges;


4、接下来就是安装gitlab了
cd /data/tools/
sudo rpm -ivh gitlab-ce-8.8.5-ce.1.el7.x86_64.rpm

gitlab 的配置文件是/etc/gitlab/gitlab.rb
sudo vim /etc/gitlab/gitlab.rb
修改gitlab的访问地址
external_url "http://git.bigbao.com"

这里gitlab的默认配置文件使用的数据库是postgresql,这里我们要给他改成mysql的
postgresql['enable'] = false
gitlab_rails['db_adapter'] = 'mysql2'
gitlab_rails['db_encoding'] = 'utf8'
gitlab_rails['db_host'] = '10.19.104.17'
gitlab_rails['db_port'] = '3306'
gitlab_rails['db_username'] = 'git'
gitlab_rails['db_password'] = '123456'


执行:
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

bundle禁止使用postgresql:不要舍弃mysql包
    sudo vi  /opt/gitlab/embedded/service/gitlab-rails/.bundle/config
    把mysql替换成postgresql

安装插件ruby插件,要不然执行gitlab:check 会报错,如果没有安装mysql-devel库也会有提示的。
cd /opt/gitlab/embedded/bin/
这里我们更换gem 源

#查看gem源
/opt/gitlab/embedded/bin/gem source
*** CURRENT SOURCES ***
 
https://rubygems.org/
 
#更换开源中国的gem源,否则使用时会出现错误
/opt/gitlab/embedded/bin/gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
 
/opt/gitlab/embedded/bin/gem sources --add https://rubygems.org/ --remove https://gems.ruby-china.org/

#查看更好后的gem源
/opt/gitlab/embedded/bin/gem sources
*** CURRENT SOURCES ***
 
https://gems.ruby-china.org/
 
#更改配置Gemfile文件的gem源
vi /opt/gitlab/embedded/service/gitlab-rails/Gemfile
source 'https://gems.ruby-china.org'

bundle install安装更新
cd /opt/gitlab/embedded/service/gitlab-rails/
执行下面的命令之前必须执行上面这一步,在这个目录下执行才有效
sudo /opt/gitlab/embedded/bin/bundle install    ---》这个命令会尝试更新系统中已经存在的gem包
报错了:
An error occurred while installing mysql2 (0.3.20), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.20'` succeeds before bundling.

执行一下

这里报错了:
libmysqlclient is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', and try again.

yum install mysql-devel
cd /opt/gitlab/embedded/service/gitlab-rails/
sudo /opt/gitlab/embedded/bin/gem install mysql2 -v'0.3.20'  这里安装之后check 的话一直说没有,就用了下面指定-i的方法。gem源我也是一直在切换china  和  官方源来回切
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.20
Parsing documentation for mysql2-0.3.20
Installing ri documentation for mysql2-0.3.20
Done installing documentation for mysql2 after 0 seconds
1 gem installed


这里我们要指定 -i 路径。之前这里被坑了
cd /opt/gitlab/embedded/service/gitlab-rails/
sudo /opt/gitlab/embedded/bin/gem install -i /opt/gitlab/embedded/service/gem/ruby/2.1.0  mysql2 -v'0.3.20'
[root@test-gitlab backups]# sudo /opt/gitlab/embedded/bin/gem install -i /opt/gitlab/embedded/service/gem/ruby/2.1.0  mysql2 -v'0.3.20'
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.20    这里会提示success
1 gem installed


这里我check的时候提示没有表,先不管,我们那老机器的备份文件来恢复
 gitlab-rake gitlab:backup:restore BACKUP:1530554436

还是提示没有相关表
那么执行初始化数据库
gitlab-rake gitlab:setup

 gitlab-rake gitlab:backup:restore BACKUP:1530554436
再次报错
ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'keys CASCADE' at line 1: DROP TABLE IF EXISTS keys CASCADE

》》keys占用了关键字,导入备份drop表的时候报错了,登录到数据库drop tables `keys`;成功删除表后,重新导入备份

mysql> use gitlabhq_production;
mysql> drop tables `keys`;

再来:
 gitlab-rake gitlab:backup:restore BACKUP:1530554436

终于导入成功了。要死人啊

这里我配置的URL是git.bigbao.com

所以这里修改数据库
use gitlabhq_production;

update  application_settings set signin_enabled = '1';

update  application_settings set home_page_url = 'http://git.bigbao.com';

update  application_settings set after_sign_out_path = 'http://git.bigbao.com'

浏览器访问登录 http://git.bigbao.com
访问成功,yes,感谢上帝,点击项目,我擦,500 了
看日志
tail -f production.log

Started GET "/market/market" for 180.163.108.210 at 2018-07-03 18:15:44 +0800
Processing by ProjectsController#show as HTML
  Parameters: {"namespace_id"=>"market", "id"=>"market"}
Completed 500 Internal Server Error in 57ms (ActiveRecord: 3.6ms)

OpenSSL::Cipher::CipherError (bad decrypt):
  app/models/project.rb:383:in `import_url'
  app/models/project.rb:413:in `external_import?'
  app/models/project.rb:405:in `import?'
  app/models/project.rb:421:in `import_in_progress?'
  app/controllers/projects_controller.rb:93:in `show'
  lib/gitlab/middleware/go.rb:16:in `call'

google 搜索 OpenSSL::Cipher::CipherError (bad decrypt):
找到解决方案:
https://gitlab.com/gitlab-org/gitlab-ce/issues/17873
gitlab-ce: 执行下面的这个命令即可恢复:
gitlab-rails runner  "Project.where.not(import_url: nil).each { |p| p.import_data.destroy if p.import_data }"



接下来不如gitlab的正式升级之路
升级目前的流程定位8.8.5--> 8.10.8 --> 8.17.8 --> 9.5.9 --> 10.1.4
我们现在下载8.10.8 安装包
cd /data/tools
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.10.8-ce.0.el7.x86_64.rpm

关闭gitlab 的部分服务:
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl stop nginx
sudo rpm -Uvh gitlab-ce-8.10.8-ce.0.el7.x86_64.rpm
[wwwad@test-gitlab tools]$ sudo rpm -Uvh gitlab-ce-8.10.8-ce.0.el7.x86_64.rpm
Preparing...                          ################################# [100%]
gitlab preinstall: Automatically backing up only the GitLab SQL database (excluding everything else!)
Dumping database ...
Dumping MySQL database gitlabhq_production ... mysqldump: Got error: 1130: Host 'git.bigbao.com' is not allowed to connect to this MySQL server when trying to connect
[FAILED]
Backup failed
gitlab preinstall:
gitlab preinstall: Backup failed! If you want to skip this backup, run the following command and
gitlab preinstall: try again:

又报错,解决,mysql去给这个host授权一下。目前只受理了select,我擦,select的权限还是权限拒绝,添加权限
mysql> GRANT SELECT, INSERT, UPDATE, DELETE,CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER, LOCK TABLES, REFERENCES ON`gitlabhq_production`.* TO 'git'@'git.bigbao.com' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

再次执行:sudo rpm -Uvh gitlab-ce-8.10.8-ce.0.el7.x86_64.rpm
又报别的错误了:
    Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
    ================================================================================
    
    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of "bash"  "/tmp/chef-script20180704-5663-1ykn369" ----
    STDOUT: rake aborted!
    Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

   这个mysql2 我已经添加到gem里面了,我去

[root@test-gitlab tools]# cat  /opt/gitlab/embedded/service/gitlab-rails/.bundle/config
---
BUNDLE_RETRY: 5
BUNDLE_PATH: "/opt/gitlab/embedded/service/gem"
BUNDLE_JOBS: 9
BUNDLE_WITHOUT: development:test:mysql
BUNDLE_DISABLE_SHARED_GEMS: '1'

我们看到这里变成了mysql
我们修改一下,把这里的mysql变成postgresql

重新配置gitlab和重启
gitlab-ctl reconfigure
gitlab-ctl restart

yes 升级成功,我的小心脏。。。

我们登录到git.bigbao.com 查看一下面板,终于变成了8.10.8


接下来我们升级到8.17.8
cd /data/tools
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.17.8-ce.0.el7.x86_64.rpm
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl stop nginx
sudo rpm -Uvh gitlab-ce-8.17.8-ce.0.el7.x86_64.rpm
果然又报上面的同一个错误了,这个错误是在检测的时候报的错误。我们不需要再次执行rpm -Uvh gitlab-ce-8.17.8-ce.0.el7.x86_64.rpm,
执行一下也没有问题。会提示你已经安装    package gitlab-ce-8.17.8-ce.0.el7.x86_64 is already installed
sudo sed -i "s#mysql#postgresql#g"  /opt/gitlab/embedded/service/gitlab-rails/.bundle/config
我擦,这样修改尽然不可以了
仔细看一下报错内容:尽然和上面的报错不一样,大意了
  ================================================================================
    Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
    ================================================================================
    
    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of "bash"  "/tmp/chef-script20180704-10569-fpnl6g" ----
    STDOUT: bundler: failed to load command: rake (/opt/gitlab/embedded/bin/rake)
    Bundler::GemNotFound: Your bundle is locked to rake (10.5.0),
    but that version could not be found in any of the sources listed in your Gemfile.
    If you haven't changed sources, that means the author of rake (10.5.0) has removed it.
    You'll need to update your bundle to a different version of rake (10.5.0) that hasn't been removed in order to install.

这里我们查看gem源是官方国外源,修改一下
cd /opt/gitlab/embedded/service/gitlab-rails/
/opt/gitlab/embedded/bin/gem source
*** CURRENT SOURCES ***
 
https://rubygems.org/

/opt/gitlab/embedded/bin/gem sources --add https://gems.ruby-china.org/ --remove https://ruby
sudo vim  /opt/gitlab/embedded/service/gitlab-rails/Gemfile


sudo /opt/gitlab/embedded/bin/bundle install
又报错:
An error occurred while installing charlock_holmes (0.7.3), and Bundler cannot continue.
Make sure that `gem install charlock_holmes -v '0.7.3'` succeeds before bundling.

sudo /opt/gitlab/embedded/bin/gem install bundler

sudo /opt/gitlab/embedded/bin/gem install charlock_holmes -v '0.7.3'
再次报错:
make: g++: Command not found
make: *** [transliterator.o] Error 127

make failed, exit code 2

报错再解决:
yum -y install gcc automake autoconf libtool make  gcc-c++

再执行:sudo /opt/gitlab/embedded/bin/gem install charlock_holmes -v '0.7.3'
好了,通过

gitlab-ctl reconfigure
再次报错:
    ================================================================================
    Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
    ================================================================================
    
    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of "bash"  "/tmp/chef-script20180704-32605-15064zs" ----
    STDOUT: `/var/opt/gitlab` is not writable.
    Bundler will use `/tmp/bundler/home/wwwad' as your home directory temporarily.
    bundler: failed to load command: rake (/opt/gitlab/embedded/service/gem/ruby/2.3.0/bin/rake)
    Bundler::GemNotFound: Could not find activesupport-4.2.7.1 in any of the sources

处理思路:
 sudo /opt/gitlab/embedded/bin/bundle install
一个报错没解决,又来一个:
Downloading omniauth-google-oauth2-0.4.1 revealed dependencies not in the API or the lockfile (omniauth-oauth2 (>= 1.3.1), jwt (~> 1.5.2)).
Either installing with `--full-index` or running `bundle update omniauth-google-oauth2` should fix the problem.

In Gemfile:
  omniauth-google-oauth2

sudo /opt/gitlab/embedded/bin/bundle install --full-index
报相同的错误,那么执行
sudo /opt/gitlab/embedded/bin/bundle update omniauth-google-oauth2
又来一个报错:屋漏偏逢连夜雨......
An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.4' --source 'https://gems.ruby-china.org/'` succeeds before bundling.

In Gemfile:
  pg


解决方案:
sudo yum  install  freetype-devel  ghostscript-devel   jasper-devel   lcms-devel   libpng-devel    libtiff-devel   zlib-devel libxml2-devel
sudo yum install ImageMagick-devel
sudo yum install postgresql-devel
sudo /opt/gitlab/embedded/bin/gem install pg -v '0.18.4'

再次执行:
sudo /opt/gitlab/embedded/bin/bundle update omniauth-google-oauth2

又报错:
An error occurred while installing rugged (0.24.0), and Bundler cannot continue.
Make sure that `gem install rugged -v '0.24.0' --source 'https://gems.ruby-china.org/'` succeeds before bundling.

In Gemfile:
  gemnasium-gitlab-service was resolved to 0.2.6, which depends on
    rugged

执行:
sudo /opt/gitlab/embedded/bin/gem install rugged -v '0.24.0'
再报错:
        Building native extensions.  This could take a while...
        ERROR:  Error installing rugged:
            ERROR: Failed to build gem native extension.

            current directory: /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rugged-0.24.0/ext/rugged
        /opt/gitlab/embedded/bin/ruby -r ./siteconf20180704-9867-61nf8j.rb extconf.rb
        checking for gmake... yes
        checking for cmake... no
        ERROR: CMake is required to build Rugged.
        *** extconf.rb failed ***
        Could not create Makefile due to some reason, probably lack of necessary
        libraries and/or headers.  Check the mkmf.log file for more details.  You may
        need configuration options.

        Provided configuration options:
            --with-opt-dir
            --with-opt-include
            --without-opt-include=${opt-dir}/include
            --with-opt-lib
            --without-opt-lib=${opt-dir}/lib
            --with-make-prog
            --without-make-prog
            --srcdir=.
            --curdir
            --ruby=/opt/gitlab/embedded/bin/$(RUBY_BASE_NAME)
            --use-system-libraries

        To see why this extension failed to compile, please check the mkmf.log which can be found here:

          /opt/gitlab/embedded/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/rugged-0.24.0/mkmf.log

        extconf failed, exit code 1

        Gem files will remain installed in /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rugged-0.24.0 for inspection.
        Results logged to /opt/gitlab/embedded/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/rugged-0.24.0/gem_make.out

sudo yum -y install cmake
sudo /opt/gitlab/embedded/bin/gem install rugged -v '0.24.0'
sudo /opt/gitlab/embedded/bin/bundle install

gitlab-ctl reconfigure
感谢上帝,终于成功了,重启访问看看。。。。。=
gitlab-ctl restart

伤心透了,访问500,直接页面都没了
看日志吧:
    Started GET "/" for 180.163.108.210 at 2018-07-04 12:52:06 +0800
    Processing by RootController#index as HTML
    Completed 500 Internal Server Error in 77ms (ActiveRecord: 4.8ms)

    ActiveRecord::StatementInvalid (Mysql2::Error: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '=': SELECT project_id, MAX(access_level) AS access_level FROM (SELECT 1 AS user_id, projects.id AS project_id, 40 AS access_level FROM `projects` INNER JOIN `namespaces` ON `projects`.`namespace_id` = `namespaces`.`id` WHERE `projects`.`pending_delete` = 0 AND `namespaces`.`deleted_at` IS NULL AND `namespaces`.`owner_id` = 1 AND `namespaces`.`type` IS NULL
    UNION
    SELECT members.user_id, projects.id AS project_id, members.access_level FROM `projects` INNER JOIN `namespaces` ON `projects`.`namespace_id` = `namespaces`.`id` INNER JOIN `members` ON `namespaces`.`id` = `members`.`source_id` WHERE `projects`.`pending_delete` = 0 AND `namespaces`.`deleted_at` IS NULL AND `namespaces`.`type` IN ('Group') AND `members`.`source_type` = 'Namespace' AND `members`.`user_id` = 1 AND `members`.`type` IN ('GroupMember') AND `members`.`requested_at` IS NULL
    UNION
    SELECT members.user_id, projects.id AS project_id, members.access_level FROM `projects` INNER JOIN `members` ON `projects`.`id` = `members`.`source_id` WHERE `projects`.`pending_delete` = 0 AND `members`.`source_type` = 'Project' AND `members`.`user_id` = 1 AND `members`.`type` IN ('ProjectMember') AND `members`.`requested_at` IS NULL
    UNION
    SELECT members.user_id, projects.id AS project_id, LEAST(project_group_links.group_access, members.access_level) AS access_level FROM `namespaces` INNER JOIN `project_group_links` ON `project_group_links`.`group_id` = `namespaces`.`id` INNER JOIN `projects` ON `projects`.`id` = `project_group_links`.`project_id` AND `projects`.`pending_delete` = 0 INNER JOIN `members` ON `namespaces`.`id` = `members`.`source_id` INNER JOIN namespaces project_namespace ON project_namespace.id = projects.namespace_id WHERE `namespaces`.`deleted_at` IS NULL AND `members`.`source_type` = 'Namespace' AND `namespaces`.`type` IN ('Group') AND `members`.`user_id` = 1 AND `members`.`type` IN ('GroupMember') AND `members`.`requested_at` IS NULL AND (project_namespace.share_with_group_lock = 0)
    UNION
    SELECT members.user_id, projects.id AS project_id, members.access_level FROM `projects` INNER JOIN `namespaces` ON `namespaces`.`id` = `projects`.`namespace_id` AND `namespaces`.`deleted_at` IS NULL INNER JOIN `routes` ON `routes`.`source_id` = `projects`.`id` AND `routes`.`source_type` = 'Project' INNER JOIN routes r2 ON routes.path LIKE CONCAT(REPLACE(r2.path, '_', '\_'), '/%')
                   INNER JOIN members ON members.source_id = r2.source_id
                   AND members.source_type = r2.source_type WHERE `projects`.`pending_delete` = 0 AND (namespaces.parent_id IS NOT NULL) AND (members.user_id = 1)) project_authorizations GROUP BY `project_id`):
      config/initializers/connection_fix.rb:20:in `execute'
      app/services/users/refresh_authorized_projects_service.rb:90:in `fresh_access_levels_per_project'
      app/services/users/refresh_authorized_projects_service.rb:50:in `execute_without_lease'
      app/services/users/refresh_authorized_projects_service.rb:41:in `execute'
      app/models/user.rb:467:in `refresh_authorized_projects'
      app/models/user.rb:481:in `authorized_projects'
      app/controllers/dashboard/projects_controller.rb:5:in `index'
      app/controllers/root_controller.rb:16:in `index'
      lib/gitlab/middleware/multipart.rb:93:in `call'
      lib/gitlab/request_profiler/middleware.rb:14:in `call'
      lib/gitlab/middleware/go.rb:16:in `call'

这里问了一下DBA这个是字符编码的问题,找DBA帮忙处理了一下

alter  table abuse_reports default character set=utf8 collate=utf8_unicode_ci;             
alter  table appearances default character set=utf8 collate=utf8_unicode_ci;               
alter  table application_settings default character set=utf8 collate=utf8_unicode_ci;      
alter  table audit_events default character set=utf8 collate=utf8_unicode_ci;              
alter  table broadcast_messages default character set=utf8 collate=utf8_unicode_ci;        
alter  table ci_application_settings default character set=utf8 collate=utf8_unicode_ci;   
alter  table ci_builds default character set=utf8 collate=utf8_unicode_ci;                 
alter  table ci_commits default character set=utf8 collate=utf8_unicode_ci;                
alter  table ci_events default character set=utf8 collate=utf8_unicode_ci;                 
alter  table ci_jobs default character set=utf8 collate=utf8_unicode_ci;                   
alter  table ci_projects default character set=utf8 collate=utf8_unicode_ci;               
alter  table ci_runner_projects default character set=utf8 collate=utf8_unicode_ci;        
alter  table ci_runners default character set=utf8 collate=utf8_unicode_ci;                
alter  table ci_sessions default character set=utf8 collate=utf8_unicode_ci;               
alter  table ci_taggings default character set=utf8 collate=utf8_unicode_ci;               
alter  table ci_tags default character set=utf8 collate=utf8_unicode_ci;                   
alter  table ci_trigger_requests default character set=utf8 collate=utf8_unicode_ci;       
alter  table ci_triggers default character set=utf8 collate=utf8_unicode_ci;               
alter  table ci_variables default character set=utf8 collate=utf8_unicode_ci;              
alter  table deploy_keys_projects default character set=utf8 collate=utf8_unicode_ci;      
alter  table emails default character set=utf8 collate=utf8_unicode_ci;                    
alter  table events default character set=utf8 collate=utf8_unicode_ci;                    
alter  table forked_project_links default character set=utf8 collate=utf8_unicode_ci;      
alter  table identities default character set=utf8 collate=utf8_unicode_ci;                
alter  table issues default character set=utf8 collate=utf8_unicode_ci;                    
alter  table keys default character set=utf8 collate=utf8_unicode_ci;                      
alter  table label_links default character set=utf8 collate=utf8_unicode_ci;               
alter  table labels default character set=utf8 collate=utf8_unicode_ci;                    
alter  table lfs_objects default character set=utf8 collate=utf8_unicode_ci;               
alter  table lfs_objects_projects default character set=utf8 collate=utf8_unicode_ci;      
alter  table members default character set=utf8 collate=utf8_unicode_ci;                   
alter  table merge_request_diffs default character set=utf8 collate=utf8_unicode_ci;       
alter  table merge_requests default character set=utf8 collate=utf8_unicode_ci;            
alter  table milestones default character set=utf8 collate=utf8_unicode_ci;                
alter  table namespaces default character set=utf8 collate=utf8_unicode_ci;                
alter  table notes default character set=utf8 collate=utf8_unicode_ci;                     
alter  table notification_settings default character set=utf8 collate=utf8_unicode_ci;     
alter  table oauth_access_grants default character set=utf8 collate=utf8_unicode_ci;       
alter  table oauth_access_tokens default character set=utf8 collate=utf8_unicode_ci;       
alter  table oauth_applications default character set=utf8 collate=utf8_unicode_ci;        
alter  table project_group_links default character set=utf8 collate=utf8_unicode_ci;       
alter  table project_import_data default character set=utf8 collate=utf8_unicode_ci;       
alter  table projects default character set=utf8 collate=utf8_unicode_ci;                  
alter  table protected_branches default character set=utf8 collate=utf8_unicode_ci;        
alter  table releases default character set=utf8 collate=utf8_unicode_ci;                  
alter  table schema_migrations default character set=utf8 collate=utf8_unicode_ci;         
alter  table sent_notifications default character set=utf8 collate=utf8_unicode_ci;        
alter  table services default character set=utf8 collate=utf8_unicode_ci;                  
alter  table snippets default character set=utf8 collate=utf8_unicode_ci;                  
alter  table spam_logs default character set=utf8 collate=utf8_unicode_ci;                 
alter  table subscriptions default character set=utf8 collate=utf8_unicode_ci;             
alter  table taggings default character set=utf8 collate=utf8_unicode_ci;                  
alter  table tags default character set=utf8 collate=utf8_unicode_ci;                      
alter  table todos default character set=utf8 collate=utf8_unicode_ci;                     
alter  table users default character set=utf8 collate=utf8_unicode_ci;                     
alter  table users_star_projects default character set=utf8 collate=utf8_unicode_ci;       
alter  table web_hooks default character set=utf8 collate=utf8_unicode_ci;     
      
      修改过之后还是有之前一样的报错,DBA帮忙看了一下还是要修改,使用下面的sql,dba说可能只要执行下面这个,上面的不用执行,但是这个之前已经执行过了,等到线上版本真正升级的时候,再试试只用下面的sql
      这里在第二次进行升级的时候验证了。只要执行下面这一句sql 就行
      use gitlabhq_production;
      ALTER TABLE `members` MODIFY COLUMN `source_type`  varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER `source_id`;
访问成功,yes

gitlab  访问502  Google 说可能是unicorn的问题,查看日志,是mysql授权问题

接下来接着干,升级到9.5.9
cd /data/tools/
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-9.5.9-ce.0.el7.x86_64.rpm
这里把后面要升级用到的压缩包都下载下来:
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.1.4-ce.0.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.8.5-ce.0.el7.x86_64.rpm


sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl stop nginx
sudo rpm -Uvh gitlab-ce-9.5.9-ce.0.el7.x86_64.rpm
下面截取了一段升级的进度条,可以看到它做了哪些事情
            [root@test-gitlab tools]# sudo rpm -Uvh gitlab-ce-9.5.9-ce.0.el7.x86_64.rpm
            warning: gitlab-ce-9.5.9-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
            Preparing...                          ################################# [100%]
            gitlab preinstall: Automatically backing up only the GitLab SQL database (excluding everything else!)
            `/var/opt/gitlab` is not writable.
            Bundler will use `/tmp/bundler/home/wwwad' as your home directory temporarily.
            Dumping database ...
            Dumping MySQL database gitlabhq_production ... [DONE]
            done
            Dumping repositories ...
            [SKIPPED]
            Dumping uploads ...
            [SKIPPED]
            Dumping builds ...
            [SKIPPED]
            Dumping artifacts ...
            [SKIPPED]
            Dumping pages ...
            [SKIPPED]
            Dumping lfs objects ...
            [SKIPPED]
            Dumping container registry images ...
            [DISABLED]
            Creating backup archive: 1530689080_2018_07_04_gitlab_backup.tar ... done
            Uploading backup archive to remote storage  ... skipped
            Deleting tmp directories ... done
            done
            Deleting old backups ... skipping
            Updating / installing...
               1:gitlab-ce-9.5.9-ce.0.el7         ################################# [ 50%]


                   *.                  *.
                  ***                 ***
                 *****               *****
                .******             *******
                ********            ********
               ,,,,,,,,,***********,,,,,,,,,
              ,,,,,,,,,,,*********,,,,,,,,,,,
              .,,,,,,,,,,,*******,,,,,,,,,,,,
                  ,,,,,,,,,*****,,,,,,,,,.
                     ,,,,,,,****,,,,,,
                        .,,,***,,,,
                            ,*,.

                 _______ __  __          __
                / ____(_) /_/ /   ____ _/ /_
               / / __/ / __/ /   / __ `/ __ \
              / /_/ / / /_/ /___/ /_/ / /_/ /
              \____/_/\__/_____/\__,_/_.___/


            gitlab: Thank you for installing GitLab!
            gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:

            sudo gitlab-ctl reconfigure

            gitlab: GitLab should be reachable at http://git.bigbao.com
            gitlab: Otherwise configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
            gitlab: And running reconfigure again.
            gitlab:
            gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme
            gitlab: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
            gitlab:
            Cleaning up / removing...
               2:gitlab-ce-8.17.8-ce.0.el7        ################################# [100%]
            Checking PostgreSQL executables:Starting Chef Client, version 12.12.15


意料之内,继续报错:
  ================================================================================
    Error executing action `run` on resource 'execute[clear the gitlab-rails cache]'
    ================================================================================
    
    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of /opt/gitlab/bin/gitlab-rake cache:clear ----
    STDOUT: `/var/opt/gitlab` is not writable.
    Bundler will use `/tmp/bundler/home/wwwad' as your home directory temporarily.
    STDERR: rake aborted!
    Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

 sudo vi  /opt/gitlab/embedded/service/gitlab-rails/.bundle/config
mysql  改成  postgresql

接着报错:
    ================================================================================
    Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
    ================================================================================
    
    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of "bash"  "/tmp/chef-script20180704-29515-xn0x51" ----
    STDOUT: `/var/opt/gitlab` is not writable.
    Bundler will use `/tmp/bundler/home/wwwad' as your home directory temporarily.
    bundler: failed to load command: rake (/opt/gitlab/embedded/bin/rake)
    Bundler::GemNotFound: Could not find mysql2-0.4.5 in any of the sources
我们之前装的是0.3.20,按照报错提示他是找不到mysql2-0.4.5,找不到,那我们就装
cd /opt/gitlab/embedded/service/gitlab-rails/
sudo /opt/gitlab/embedded/bin/gem install -i /opt/gitlab/embedded/service/gem/ruby/2.3.0  mysql2 -v'0.4.5'

我们之前把包都是安装在/opt/gitlab/embedded/service/gem/ruby/2.1.0 ,现在都是安装在2.3.0下面
[root@test-gitlab gitlab-rails]# ls /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/mysql2-0.
mysql2-0.3.20/ mysql2-0.4.5/  
我们可以看到已经有mysql2-0.4.5
这里我刚刚尝试了一下不指定 -i 的话,他这里也没有报错,但是到路径下面找,找不到

gitlab-clt reconfigure
又来一个报错
    ================================================================================
    Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
    ================================================================================
    
    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of "bash"  "/tmp/chef-script20180704-31975-16kgpc3" ----
    STDOUT: `/var/opt/gitlab` is not writable.
    Bundler will use `/tmp/bundler/home/wwwad' as your home directory temporarily.
    bundler: failed to load command: rake (/opt/gitlab/embedded/bin/rake)
    Bundler::GemNotFound: Could not find peek-mysql2-1.1.0 in any of the sources
执行:
cd /opt/gitlab/embedded/service/gitlab-rails/
sudo /opt/gitlab/embedded/bin/gem install -i /opt/gitlab/embedded/service/gem/ruby/2.3.0/ peek-mysql2 -v'1.1.0'

这里出现一个诡异的现象就是我执行上面那一步的时候。提示安装成功了,/opt/gitlab/embedded/service/gem/ruby/2.3.0/gems 目录下也有了
但是 gitlab-ctl reconfigure的时候还是报错,于是抱着试试的态度,执行了下面的语句
sudo /opt/gitlab/embedded/bin/gem install peek-mysql2 -v'1.1.0'
但是我看历史命令我好像没有执行sudo /opt/gitlab/embedded/bin/gem install -i /opt/gitlab/embedded/service/gem/ruby/2.3.0/ peek-mysql2 -v'1.1.0'
可能是我真的没有执行吧,错误排除就好

第二次遇到的错误:
Bundler::PermissionError: There was an error while trying to write to `/opt/gitlab/embedded/service/gitlab-rails/Gemfile.lock`. It is likely that you need to grant write permissions for that path.
说没有权限写入。那么chmod 777 /opt/gitlab/embedded/service/gitlab-rails/Gemfile.lock
问题解决



再次执行gitlab-ctl reconfigure
gitlab-ctl restart
访问又报错:500
日志:
        Started GET "/" for 180.163.108.210 at 2018-07-04 15:57:23 +0800
        Processing by RootController#index as HTML
        Completed 500 Internal Server Error in 166ms (ActiveRecord: 1.9ms)

        NoMethodError (undefined method `performance_bar_allowed_group_id' for #<ApplicationSetting:0x00007fe5389cdd10>
        Did you mean?  performance_bar_allowed_group_id=
                       performance_bar_allowed_group):
          lib/gitlab/performance_bar.rb:15:in `allowed_group_id'
          lib/gitlab/performance_bar.rb:9:in `enabled?'
          app/controllers/concerns/with_performance_bar.rb:9:in `peek_enabled?'
          lib/gitlab/middleware/multipart.rb:93:in `call'
          lib/gitlab/request_profiler/middleware.rb:14:in `call'
          lib/gitlab/middleware/go.rb:17:in `call'
          lib/gitlab/etag_caching/middleware.rb:11:in `call'
          lib/gitlab/request_context.rb:18:in `call'
          lib/gitlab/metrics/requests_rack_middleware.rb:27:in `call'
解决方案:https://gitlab.com/gitlab-org/gitlab-ce/issues/35631
gitlab-rake db:migrate
报错了:
        [root@test-gitlab wwwad]# gitlab-rake db:migrate
        `/var/opt/gitlab` is not writable.
        Bundler will use `/tmp/bundler/home/wwwad' as your home directory temporarily.
        == 20170511082759 RenameWebHooksBuildEventsToJobEvents: migrating =============
        -- transaction_open?()
           -> 0.0000s
        rake aborted!
        StandardError: An error has occurred, all later migrations canceled:

        Mysql2::Error: SELECT command denied to user 'git'@'git.xxx.com' for table 'user': SHOW FULL FIELDS FROM `mysql`.`user`

解决方案:
    GRANT all privileges  on *.* to 'git'@'git.xxx.com';
gitlab-ctl reconfigure
接着报错:
   ================================================================================
    Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
    ================================================================================
    
    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of "bash"  "/tmp/chef-script20180704-14425-b25hxm" ----
    STDOUT: `/var/opt/gitlab` is not writable.
    Bundler will use `/tmp/bundler/home/wwwad' as your home directory temporarily.
    rake aborted!
    StandardError: An error has occurred, all later migrations canceled:
    
    Mysql2::Error: Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '=': UPDATE `ci_builds` SET `stage_id` = (SELECT id FROM ci_stages
       WHERE ci_stages.pipeline_id = ci_builds.commit_id
         AND ci_stages.name = ci_builds.stage)
     WHERE `ci_builds`.`id` >= 1 AND `ci_builds`.`id` < 70 AND `ci_builds`.`stage_id` IS NULL
    /opt/gitlab/embedded/service/gitlab-rails/config/initializers/connection_fix.rb:20:in `execute'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers.rb:278:in `block in update_column_in_batches'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers.rb:255:in `loop'

又是字符编码的问题:找DBA看了一下,他说帮我把所有的字符编码都给改了
ci_stages和ci_builds字符集编码不统一。要死人
修改所有的字符编码的sql如下:
ALTER TABLE `ci_group_variables` MODIFY COLUMN `key` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `ci_group_variables` MODIFY COLUMN `value` text COLLATE utf8_general_ci;
ALTER TABLE `ci_group_variables` MODIFY COLUMN `encrypted_value` text COLLATE utf8_general_ci;
ALTER TABLE `ci_group_variables` MODIFY COLUMN `encrypted_value_salt` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `ci_group_variables` MODIFY COLUMN `encrypted_value_iv` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `ci_pipeline_schedules` MODIFY COLUMN `description` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `ci_pipeline_schedules` MODIFY COLUMN `ref` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `ci_pipeline_schedules` MODIFY COLUMN `cron` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `ci_pipeline_schedules` MODIFY COLUMN `cron_timezone` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `ci_stages` MODIFY COLUMN `name` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `ci_triggers` MODIFY COLUMN `description` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `ci_triggers` MODIFY COLUMN `ref` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `ci_variables` MODIFY COLUMN `key` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `container_repositories` MODIFY COLUMN `name` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `deployments` MODIFY COLUMN `ref` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `deployments` MODIFY COLUMN `sha` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `deployments` MODIFY COLUMN `deployable_type` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `deployments` MODIFY COLUMN `on_stop` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `environments` MODIFY COLUMN `name` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `environments` MODIFY COLUMN `external_url` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `environments` MODIFY COLUMN `environment_type` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `environments` MODIFY COLUMN `state` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `environments` MODIFY COLUMN `slug` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `feature_gates` MODIFY COLUMN `feature_key` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `feature_gates` MODIFY COLUMN `key` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `feature_gates` MODIFY COLUMN `value` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `features` MODIFY COLUMN `key` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `gpg_keys` MODIFY COLUMN `key` text COLLATE utf8_general_ci;
ALTER TABLE `members` MODIFY COLUMN `source_type` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `notes` MODIFY COLUMN `change_position` text COLLATE utf8_general_ci;
ALTER TABLE `oauth_openid_requests` MODIFY COLUMN `nonce` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `pages_domains` MODIFY COLUMN `certificate` text COLLATE utf8_general_ci;
ALTER TABLE `pages_domains` MODIFY COLUMN `encrypted_key` text COLLATE utf8_general_ci;
ALTER TABLE `pages_domains` MODIFY COLUMN `encrypted_key_iv` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `pages_domains` MODIFY COLUMN `encrypted_key_salt` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `pages_domains` MODIFY COLUMN `domain` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `personal_access_tokens` MODIFY COLUMN `token` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `personal_access_tokens` MODIFY COLUMN `name` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `personal_access_tokens` MODIFY COLUMN `scopes` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `projects` MODIFY COLUMN `ci_config_path` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `projects` MODIFY COLUMN `import_jid` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `projects` MODIFY COLUMN `delete_error` text COLLATE utf8_general_ci;
ALTER TABLE `protected_tags` MODIFY COLUMN `name` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `redirect_routes` MODIFY COLUMN `source_type` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `redirect_routes` MODIFY COLUMN `path` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `routes` MODIFY COLUMN `source_type` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `routes` MODIFY COLUMN `path` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `routes` MODIFY COLUMN `name` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `sent_notifications` MODIFY COLUMN `in_reply_to_discussion_id` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `snippets` MODIFY COLUMN `content_html` longtext COLLATE utf8_general_ci;
ALTER TABLE `snippets` MODIFY COLUMN `description` text COLLATE utf8_general_ci;
ALTER TABLE `snippets` MODIFY COLUMN `description_html` text COLLATE utf8_general_ci;
ALTER TABLE `system_note_metadata` MODIFY COLUMN `action` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `u2f_registrations` MODIFY COLUMN `certificate` text COLLATE utf8_general_ci;
ALTER TABLE `u2f_registrations` MODIFY COLUMN `key_handle` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `u2f_registrations` MODIFY COLUMN `public_key` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `u2f_registrations` MODIFY COLUMN `name` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `uploads` MODIFY COLUMN `path` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `uploads` MODIFY COLUMN `checksum` varchar(64) COLLATE utf8_general_ci;
ALTER TABLE `uploads` MODIFY COLUMN `model_type` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `uploads` MODIFY COLUMN `uploader` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `user_agent_details` MODIFY COLUMN `user_agent` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `user_agent_details` MODIFY COLUMN `ip_address` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `user_agent_details` MODIFY COLUMN `subject_type` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `users` MODIFY COLUMN `preferred_language` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `users` MODIFY COLUMN `rss_token` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `web_hook_logs` MODIFY COLUMN `trigger` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `web_hook_logs` MODIFY COLUMN `url` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `web_hook_logs` MODIFY COLUMN `request_headers` text COLLATE utf8_general_ci;
ALTER TABLE `web_hook_logs` MODIFY COLUMN `request_data` text COLLATE utf8_general_ci;
ALTER TABLE `web_hook_logs` MODIFY COLUMN `response_headers` text COLLATE utf8_general_ci;
ALTER TABLE `web_hook_logs` MODIFY COLUMN `response_body` text COLLATE utf8_general_ci;
ALTER TABLE `web_hook_logs` MODIFY COLUMN `response_status` varchar(255) COLLATE utf8_general_ci;
ALTER TABLE `web_hook_logs` MODIFY COLUMN `internal_error_message` varchar(255) COLLATE utf8_general_ci;
接下来接着干,搞10.1.4
cd /data/tools
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl stop nginx
sudo rpm -Uvh gitlab-ce-10.1.4-ce.0.el7.x86_64.rpm
没想到在这一步就报错了。你尽然需要policycoreutils-python,那我就给你装
[root@test-gitlab tools]# sudo sudo rpm -Uvh gitlab-ce-10.1.4-ce.0.el7.x86_64.rpm
warning: gitlab-ce-10.1.4-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
error: Failed dependencies:
    policycoreutils-python is needed by gitlab-ce-10.1.4-ce.0.el7.x86_64

 sudo yum -y install policycoreutils-python

 sudo vi  /opt/gitlab/embedded/service/gitlab-rails/.bundle/config
    把mysql替换成postgresql
 gitlab-ctl reconfigure
 gitlab-ctl restart

第一次我们从10.1.4--->10.8.5升级失败了,现在跨度小一点
现在升级到10.2.5
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl stop nginx
sudo rpm -Uvh gitlab-ce-10.2.5-ce.0.el7.x86_64.rpm
 sudo vi  /opt/gitlab/embedded/service/gitlab-rails/.bundle/config
    把mysql替换成postgresql
 gitlab-ctl reconfigure
gitlab-ctl restart
升级成功,


现在升级到10.3.9有数据库结构问题
按照https://gitlab.com/gitlab-org/gitlab-ce/issues/41483方法修改无效,决定到此为止,不在往上升级



下面的忽略这个是之前10.1.4直接往10.8.5升级的。错误也保留在这里,方便以后有空查看
接下来接着干,搞10.8.5
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl stop nginx
sudo rpm -Uvh gitlab-ce-10.8.5-ce.0.el7.x86_64.rpm

    ================================================================================
    Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
    ================================================================================
    
    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of "bash"  "/tmp/chef-script20180704-25712-e3yjam" ----
    STDOUT: `/var/opt/gitlab` is not writable.
    Bundler will use `/tmp/bundler/home/wwwad' as your home directory temporarily.
    bundler: failed to load command: rake (/opt/gitlab/embedded/bin/rake)
    Bundler::GemNotFound: Could not find mysql2-0.4.10 in any of the sources


上面我们装的是mysql2 0.4.5的版本,按照报错需要装0.4.10,你要啥我就给你啥
cd /opt/gitlab/embedded/service/gitlab-rails/
sudo /opt/gitlab/embedded/bin/gem install -i /opt/gitlab/embedded/service/gem/ruby/2.3.0  mysql2 -v'0.4.10'

干,又报错:
        [wwwad@test-gitlab gitlab-rails]$ sudo /opt/gitlab/embedded/bin/gem install  mysql2 -v'0.4.10'
        Fetching: mysql2-0.4.10.gem (100%)
        Building native extensions.  This could take a while...
        ERROR:  Error installing mysql2:
            ERROR: Failed to build gem native extension.

            current directory: /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/mysql2-0.4.10/ext/mysql2
        /opt/gitlab/embedded/bin/ruby -r ./siteconf20180704-27831-13q5yex.rb extconf.rb
        mkmf.rb can't find header files for ruby at /opt/gitlab/embedded/lib/ruby/include/ruby.h

        extconf failed, exit code 1

        Gem files will remain installed in /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/mysql2-0.4.10 for inspection.
        Results logged to /opt/gitlab/embedded/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.10/gem_make.out

Google让我执行bundle install
sudo vim  /opt/gitlab/embedded/service/gitlab-rails/Gemfile
改成https://gems.ruby-china.org

sudo /opt/gitlab/embedded/bin/bundle install
报错信息:
        Using devise-two-factor 3.0.0
        Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

            current directory: /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/mysql2-0.4.10/ext/mysql2
        /opt/gitlab/embedded/bin/ruby -r ./siteconf20180704-979-9ajitr.rb extconf.rb
        mkmf.rb can't find header files for ruby at /opt/gitlab/embedded/lib/ruby/include/ruby.h

        extconf failed, exit code 1

        Gem files will remain installed in /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/mysql2-0.4.10 for inspection.
        Results logged to /opt/gitlab/embedded/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.10/gem_make.out

        An error occurred while installing mysql2 (0.4.10), and Bundler cannot continue.
        Make sure that `gem install mysql2 -v '0.4.10' --source 'https://gems.ruby-china.org/'` succeeds before bundling.

        In Gemfile:
          peek-mysql2 was resolved to 1.1.0, which depends on
            mysql2

sudo /opt/gitlab/embedded/bin/gem install -i /opt/gitlab/<em></em>bedded/service/gem/ruby/2.3.0  mysql2 -v'0.4.10'

https://ruby-china.org/topics/18737?locale=en  ruby升级到2.3.7  最后问了一下群里的朋友。说是我没有安装ruby-devel。

posted @ 2018-07-04 14:26  BigBao的博客  阅读(7559)  评论(0编辑  收藏  举报