概要 公司使用GitLab7.9.2, 现需要9.4.5
, 由PG转到MySQL
升级前准备
HOSTS
vim /etc/hosts 192.168.1.45 dev-office-dev-192.168.1.45.centos65.sh.com 192.168.1.45 gitlab.sh.com
在1.45创建数据库
CREATE DATABASE `gitlab` GRANT ALL ON gitlab.* TO gitlab@'%' IDENTIFIED BY '2GhYCJAFbXPWfXjC'; FLUSH PRIVILEGES ; # 改连接 vim /home/git/gitlab/config/database.yml host: '192.168.1.45'
同步
# 同步数据 sudo - git /home/git rsync -avzP . git@192.168.1.45:/home/git
清空旧备份
cd /home/git/gitlab/tmp/backups && rm -f *
清缓存
su - git git$ bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production
备份 # git 用户完成 bundle exec rake gitlab:backup:create RAILS_ENV=production
转换成pgsql
# git 用户完成 cd /home/git/gitlab mkdir -p tmp/backups/postgresql mv tmp/backups/TIMESTAMP_gitlab_backup.tar tmp/backups/postgresql/ # 注意文件名 时间戳 cd tmp/backups/postgresql # 导出数据 mysqldump --compatible=postgresql --default-character-set=utf8 -r gitlabhq_production.mysql -u root gitlab └─> ls 1502864668_gitlab_backup.tar gitlabhq_production.mysql # 转换脚本 git clone https://github.com/gitlabhq/mysql-postgresql-converter.git -b gitlab └─> pwd /home/git/gitlab/tmp/backups/postgresql mkdir db /home/git/.pyenv/versions/2.7.13/bin/python mysql-postgresql-converter/db_converter.py gitlabhq_production.mysql db/database.sql ed -s db/database.sql < mysql-postgresql-converter/move_drop_indexes.ed #### gzip db/database.sql # 重新封装备份 tar rf TIMESTAMP_gitlab_backup.tar db/database.sql # 注意文件名 为时间戳 ┌─( git ) - ( dev-office-dev-192.168.1.45.centos65.sanhao.com )- ( /home/git/gitlab/tmp/backups/postgresql ) └─> tree . ├── 1502864668_gitlab_backup.tar # 一键安装包使用此备份文件 ├── db │ └── database.sql.gz ├── gitlabhq_production.mysql └── mysql-postgresql-converter ├── db_converter.py ├── LICENSE ├── move_drop_indexes.ed └── README.md
一键安装包 下载地址 https://downloads-packages.s3.amazonaws.com/centos-6.6/gitlab-7.9.2_omnibus-1.el6.x86_64.rpm 清华大学镜像
https://mirrors.tuna.tsinghua.edu.cn/help/gitlab-ce/ 官方地址
https://packages.gitlab.com/gitlab/
scp zhourudong@192.168.1.51:/tmp/gitpkg/gitlab-7.9.2_omnibus-1.el6.x86_64.rpm . # yum install gitlab-7.9.2_omnibus-1.el6.x86_64.rpm -y
vim /etc/gitlab/gitlab.rb # 第四行 external_url 'http:// gitlab.sh.45.com' # 找到数据库连接修改 gitlab_rails['db_encoding'] = "utf8" # 必须退出git用户 否则无法初始化 gitlab-ctl reconfigure
访问URL进行测试
http://gitlab.sh.com/users/sign_in
还原 # cd /var/opt/gitlab/backups/ && cp /home/git/gitlab/tmp/backups/postgresql/1502864668_gitlab_backup.tar . # 注意文件名的时间戳 cd /var/opt/gitlab/backups/ && cp $(find /home/git/gitlab/tmp/backups/postgresql/ -name '15*') . ls /var/opt/gitlab/backups 1503455703_gitlab_backup.tar gitlab-rake gitlab:backup:restore BACKUP=1503455703 This will rebuild an authorized_keys file. You will lose any data stored in authorized_keys file. Do you want to continue (yes/no)? yes # 直接替换key
备份 pg版本的备份
cd /var/opt/gitlab/backups && rm -f 15* gitlab-rake gitlab:backup:create
升级gitlab-ce-7.14.3 scp zhourudong@192.168.1.51:/tmp/gitpkg/gitlab-ce-7.14.3-ce.1.el6.x86_64.rpm . /opt/gitlab/bin/gitlab-rake cache:clear # install yum install gitlab-ce-7.14.3-ce.1.el6.x86_64.rpm -y cd /etc/gitlab && rm -f gitlab-secrets.json && gitlab-ctl upgrade cd /etc/gitlab && rm -f gitlab-secrets.json && gitlab-ctl reconfigure
升级 gitlab-ce-9.4.5 scp zhourudong@192.168.1.51:/tmp/gitpkg/gitlab-ce-9.4.5-ce.0.el6.x86_64.rpm . /opt/gitlab/bin/gitlab-rake cache:clear yum install gitlab-ce-9.4.5-ce.0.el6.x86_64.rpm -y cd /etc/gitlab && rm -f gitlab-secrets.json && gitlab-ctl upgrade cd /etc/gitlab && rm -f gitlab-secrets.json && gitlab-ctl reconfigure
升级后配置
停止监控prometheus
go开发分布式监控系统 vim /etc/gitlab/gitlab.rbprometheus_monitoring['enable'] = false
修改配置后都需要重载 cd /etc/gitlab && rm -f gitlab-secrets.json && gitlab-ctl reconfigure
配置ldap 邮箱 vim /etc/gitlab/gitlab.rb