gitlab --- The migration source packages installed rpm package rpm (c)

      Gitlab since the last upgrade fast in the past year, a lot has been updated during gitlab new version, have not been upgraded. The reason is simple, because the upgrade a lot of trouble, first with the faith and use any ideas. But before gitlab recently issued a series of older versions have security vulnerabilities, see the announcement was: "GitLab Li release security patches 12.0.3, 11.11.5 and 11.10.8, please upgrade immediately," appear "Li" word, indicating have to upgrade, after all, the code is the company's core assets.

     Then he went ahead, first go to the official website gitlab view the upgrade documentation to see what needs to be upgraded. Before my gitlab source package is installed, version 10.8.7, need to upgrade to 11.11.5 (up to version 11 version), and finally 12 to upgrade to the latest version. Summary compared, it is necessary to make the following upgrades:

software Version 10.8.7 11.11.5 version
Ruby version 2.44p96 2.5.3p105
Gem version 2.6.14.1 2.7.6
Bundler version 1.16.3 1.17.3
Rake version 12.3.1 12.3.1
Redis Version 4.9.104 4.9.104
Git version 2.18.0 2.21.x
sidekiq version 5.0.5 5.0.5
Go version go1.9.6 go1.11.5
gitlab version 10.8.7 11.11.5
Gitlab shell version 7.1.2 9.1.0
node version v8.9.4 v8.10.x
yarn version --- v1.10.x

 

 

 

 

 

 

 

 

 

  

 

 

 

 

 

 

 

  In order not to affect the normal use during the upgrade of gitlab (downtime during the upgrade, upgrade long unknown, the upgrade process will not be a problem also unknown), so do the mirroring and snapshot based on existing gitlab server environment, then according to the mirror snapshots and cloning a completely different environment; these upgrade to the full in the cloning of environments, even if the problem does not affect the normal use of the old environment, upgrade on the old server until gitlab run through the process here . When finished the software upgrade, upgrade gitlab, and cause a problem. . . . . Mainly in the update source when gitlab official website because it is in a foreign country, the update time is very slow, then a timeout has been reported. Another problem is that I see the official website said gitlab from 12 version is not supported after the mysql database, and this. . . .

  Gitlab just recently the company wants to migrate back into the network from Tencent cloud, and the last time I upgrade when he wanted to replace the source package installed gitlab rpm package installation, so that future upgrades will not be so much trouble, without a major upgrade stack software, and directly yum update like. Then take this opportunity to try, thinking: now installed directly rpm version 11.11.5 on a server within the network, the data is then migrated to upgrade to version 12. (Here's a difficulty that needs to migrate MySQL data to postgresql, here I Baidu under, there is migration of data to the mysql postgresql success stories, then that should do the same in the road)

1, the installation gitlab 11.11.5 version on the network server:

[root@dev ~]#yum install -y curl policycoreutils-python openssh-server
[root@dev ~]#systemctl enable sshd [root@dev ~]#systemctl start sshd [root@dev ~]#firewall
-cmd --permanent --add-service=http [root@dev ~]#systemctl reload firewalld [root@dev ~]#yum install postfix [root@dev ~]#systemctl enable postfix [root@dev ~]#systemctl start postfix [root@dev ~]#curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash [root@dev ~]#cd /usr/local/src [root@dev src]#wget wget https:// packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-11.11.5-ce.0.el7.x86_64.rpm [root @ dev src] # yum -y install gitlab- CE- 11.11 . 5 -ce. 0 .el7.x86_64.rpm
[root @ dev src] # ps--ef | grep gitlab - you can see gitlab has started
[root @ dev src] #cat / var / opt / gitlab / gitlab-rails / vERSION - View gitlab version
11.11.5

2, modify the configuration:

#mkdir -p /data/gitlab/backups
#mkdir -p /data/gitlab/git-data/repositories
#chown -R git:root /data/gitlab/backups/
#chown -R git.root /data/gitlab/git-data/
#vim /etc/gitlab/gitlab.rb

a, change the access URL gitlab of:

ps: Note that the port set here can not be occupied, the default port is 8080, if 8080 is already in use, customize additional ports open in the firewall settings and have corresponding port

b, change the backup path gitlab of:

c, gitlab change the default storage path of the project:

3, enable the configuration and reboot:

#gitlab-ctl reconfigure     --这一步需要一点时间

#gitlab-ctl restart   --全部“ok: run”表示重启成功

4、访问:http://192.168.1.204     初始账户:root 密码:5iveL!fe  第一次登入会要求修改密码

 5、postgresql配置:

#cd /var/opt/gitlab/postgresql/data
#vim pg_hba.conf
host     all    all    192.168.1.0/24    trust  添加这行,192.168.1.0/24这个段的ip地址不需要密码可以连接

#vim postgresql.conf
listen_addresses = '192.168.1.204'    修改监听地址为本机ip

#gitlab-ctl restart postgresql   重启数据库

#/opt/gitlab/embedded/bin/psql -U gitlab -d gitlabhq_production -h 192.168.1.204   不用输密码可进入
psql(9.6.11)
Type "help" for help
gitlabhq_production=> alter user gitlab with password 'gitlab123#@!' 修改gitlab密码,gitalb创建的数据库超级用户为gitlab-psql,想修改密码自己通过命令修改即可
gitlabhq_production=>\q 退出

#vim /var/opt/gitlab/postgresql/data/pg_hba.conf

host all all 192.168.1.0/24 md5 修改trust为md5,即连接需要密码
#gitalb-ctl restart postgresql
#/opt/gitlab/embedded/bin/psql -U gitlab -d gitlabhq_production -h 192.168.1.204
Password for user gitlab:            输入gitlab用户的密码回车即可进入数据库

既然修改了数据库gitlab用户的密码,gitlab服务器中数据库配置文件,也需要修改,不然数据库连接不上

#vim /var/opt/gitlab/gitalb-rails/etc/database.yml

  #gitlab-ctl restart   修改完数据库配置重启下服务

 做完以上配置后,就可以使用Navicat Premium连接postgresql了,用图形界面直观些。

6、数据迁移:

这里按照之前写的一篇gitlab升级(二)文档,把keys,namespaces,users三个表的数据迁移过来就好,其他的暂且就不迁了

步骤:

a、mysql中用mysqldump把这几个表只导出数据,不要表结构,表结构安装gitlab的时候已经有了

#mysqldump -t gitlabhq_production -u gitlab -p keys >keys.sql

#mysqldump -t gitlabhq_production -u gitlab -p users >users.sql

#mysqldump -t gitlabhq_production -u gitlab -p namespaces >namespaces.sql

b、查看了下gitlab 11.11.5的postgresql的表结构和 gitalb 10.8.7的mysql 表结构差不多,无非是新版本有的表多了一些字段,或者多了一些新表,但这都不影响我们导入数据。但是有个要注意的地方是,postgresql里有些字段是用的bool类型,这在mysql里没有这个类型,故数据不能直接导入,需要把mysql里不是bool类型的字段数据改成postgresql所对应的bool型数据,然后在导入。

c、导入完后,我们检查下数据是否正确,也可以拿几个账号测试下登入是否正常,如正常的话则导入就成功了,这里贴下keys表的数据:

7、导入项目,这一步开始和之前写的gitlab升级(二)里的步骤是一样的,这里就不过多阐述了。

8、gitlab 11.11.5 升级到gitalb 12.1.0

#gitlab-rake gitlab:backup:create STRATEGY=copy  --升级前先进行备份

#yum info gitlab-ce --查看gitlab-ce的版本信息,可以看到最新的版本是12.1.0 #yum -y update gitlab-ce --升级gitlab

#cat /var/opt/gitlab/gitlab-rails/VERSION --查看gitlab版本

  注:升级完可能数据库的配置被初始化了,需要重新配置下,不然数据库会连不上

 9、访问htt://192.168.1.204

 

Guess you like

Origin www.cnblogs.com/liangyou666/p/11241455.html