Git升级迁移
1 原有机器进行升级和备份:
https://about.gitlab.com/update/#centos-6
1. Make a backup (Optional) If you would like to make a backup before updating, the below command will backup data in /var/opt/gitlab/backups by default. sudo gitlab-rake gitlab:backup:create STRATEGY=copy
2. Update GitLab Update to the latest version of GitLab. sudo yum install -y gitlab-ce
2 新机器上安装社区版:
3 修改配置文件(可选,为改端口)
1) vim /etc/gitlab/gitlab.rb #unicorn['port'] = 8080
-->改为 unicorn['port'] = 8070 #nginx['listen_port'] = nil -->改为 nginx['listen_port'] = 5091
2) vim /var/opt/gitlab/gitlab-rails/etc/unicorn.rb #listen "127.0.0.1:8080", :tcp_nopush => true --> 改为 listen "127.0.0.1:8070", :tcp_nopush => true
3)vim /var/opt/gitlab/nginx/conf/gitlab-http.conf #listen *:80; --> 改为 listen *:5091;
gitlab-ctl reconfigure gitlab-ctl restart
4 nginx 转发配置(可选),
新建 gitlab-http.conf 放到独立nginx下
upstream gitlab-workhorse { server unix:/var/opt/gitlab/gitlab-workhorse/socket; } server { listen 80; server_name gitlab.xf120.com; location / { proxy_pass http://gitlab.xxx.com:5091; } }
5 还原
- sudo cp xxx_gitlab_backup.tar /var/opt/gitlab/backups/
- sudo gitlab-ctl stop unicorn
- sudo gitlab-ctl stop sidekiq
- sudo gitlab-rake gitlab:backup:restore BACKUP=xxx 注:xxx是第1步备份文件的前缀
- sudo gitlab-ctl start
- sudo gitlab-rake gitlab:check SANITIZE=true
http://blog.csdn.net/jenyzhang/article/details/53928438
6 卸载gitlab
sudo gitlab-ctl stop
sudo rpm -e gitlab-ce
ps -ef|grep gitlab 会看到如下一个进程
runsvdir -P /opt/gitlab/service log: ........................................................................
..............................................................................................................
..............................................................................................................
.......................................................................................................
把它kill掉
7 修改邮箱(未验证)
配置smtp邮件发送 $ sudo vi /etc/gitlab/gitlab.rb # Change the external_url to the address your users will type in their browser external_url 'http://xxhost.com' #Sending application email via SMTP gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.163.com" gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "xxuser@163.com" gitlab_rails['smtp_password'] = "xxpassword" gitlab_rails['smtp_domain'] = "163.com" gitlab_rails['smtp_authentication'] = :login gitlab_rails['smtp_enable_starttls_auto'] = true ##修改gitlab配置的发信人 gitlab_rails['gitlab_email_from'] = "xxuser@163.com" user["git_user_email"] = "xxuser@163.com"
疑难解答:
1)gitlab上传文件大小限制
# 1修改nginx conf(如果使用了nginx转发,转发的nginx和内部nginx都设置一下) http内添加client_max_body_size http{ client_max_body_size 0; } # 2 设置postBuffer(服务器和本地上都设一下) 单独项目设置: git config http.postBuffer 1024000000 全局设置: git config --global http.postBuffer 1024000000 # 3 重启 nginx 和 gitlab sudo service nginx restart sudo gitlab-ctl restart
2)有时候文件过多,下载超时,修改如下:
/var/opt/gitlab/gitlab-rails/etc/unicorn.rb timeout 600
3) 检查错误
sudo gitlab-ctl status
ok: run: gitaly: (pid 10432) 1s
ok: run: gitlab-monitor: (pid 10480) 1s
ok: run: gitlab-workhorse: (pid 10499) 0s
ok: run: logrotate: (pid 10517) 1s
ok: run: nginx: (pid 10580) 0s
ok: run: node-exporter: (pid 10808) 0s
timeout: down: postgres-exporter: 1s, normally up, want up --有问题的进程
timeout: run: postgresql: (pid 10564) 67237s --有问题的进程
ok: run: prometheus: (pid 13058) 0s
ok: run: redis: (pid 13085) 1s
ok: run: redis-exporter: (pid 13104) 0s
ok: run: sidekiq: (pid 13153) 0s
ok: run: unicorn: (pid 13173) 0s
gitlab-ctl tail postgres-exporter