一、gitlab部署

1.参考网站

https://about.gitlab.com/downloads/#centos6

2.部署步骤:

2.1. Install and configure the necessary dependencies

sudo yum install curl openssh-server openssh-clients postfix cronie

sudo service postfix start

sudo chkconfig postfix on

sudo lokkit -s http -s ssh

2.2 Add the GitLab package server and install the package

yum clean all

新建 /etc/yum.repos.d/gitlab-ce.repo,内容为

touch /etc/yum.repos.d/gitlab-ce.repo

你的CentOS/RHEL版本:   

[gitlab-ce]

name=gitlab-ce

baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6

repo_gpgcheck=0

gpgcheck=0

enabled=1

gpgkey=https://packages.gitlab.com/gpg.key

再执行

sudo yum makecache

sudo yum install gitlab-ce 

清华大学 TUNA 协会最初叫清华

或者RPM包安装

rpm -ivh gitlab-ce-8.6.5-ce.0.el6.x86_64.rpm


2.3Configure and start GitLab

sudo gitlab-ctl reconfigure

2.4Browse to the hostname and login

------------------------------------------------------------------------------------------------------------------------------------------------------

安装后的配置文件目录:

主文件:/etc/gitlab/   

主配置文件:/var/opt/gitlab/ 

 /opt/gitlab/

日志目录:/var/log/gitlab/


二、目录以及备份迁移

1. 安装和配置必要的依赖关系Install and configure the necessary dependencies

如果你安装postfix发送邮件,请选择“网站设置”中。而不是使用后缀也可以用邮件或 配置自定义SMTP服务器。如果你想使用的进出口,请 配置为SMTP服务器。

在CentOS7,下面的命令将在系统防火墙打开HTTP和SSH访问。

yum install curl openssh-server postfix

systemctl enable sshd postfix

systemctl start sshd postfix

firewall-cmd –permanent –add-service=http

systemctl reload firewalld

2. 添加gitlab包服务器安装包Add the GitLab package server and install the package

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh| sudo bash

yum install gitlab-ce

3. 配置并启动gitlab Configure and start GitLab

gitlab-ctl reconfigure

gitlab-ctl status

gitlab-ctl stop

gitlab-ctl start

这个是如何备份 http://dev.jmd4you.vbst.net/help/raketasks/backup_restore.md

备份和恢复omnibus-gitlab配置

创建一个应用程序备份

恢复备份的应用程序

使用non-packaged数据库备份和恢复

上传备份到远程存储(云)

手动管理备份目录

基本上都在/var/opt/gitlab/   http://doc.gitlab.com/omnibus/settings/configuration.html

Gitlab 创建备份

使用Gitlab一键安装包安装Gitlab非常简单, 同样的备份恢复与迁移也非常简单. 使用一条命令即可创建完整的Gitlab备份:


gitlab-rake gitlab:backup:create


使用以上命令会在/var/opt/gitlab/backups目录下创建一个名称类似为1393513186_gitlab_backup.tar的压缩包, 这个压缩包就是Gitlab整个的完整部分, 其中开头的1393513186是备份创建的日期.

Gitlab 修改备份文件默认目录

你也可以通过修改/etc/gitlab/gitlab.rb来修改默认存放备份文件的目录:

gitlab_rails['backup_path'] = '/mnt/backups'

/mnt/backups修改为你想存放备份的目录即可, 修改完成之后使用gitlab-ctl reconfigure命令重载配置文件即可.

Gitlab 自动备份

也可以通过crontab使用备份命令实现自动备份:

sudo su -

crontab -e

加入以下, 实现每天凌晨2点进行一次自动备份:

0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create

Gitlab 恢复

同样, Gitlab的从备份恢复也非常简单:

# 停止相关数据连接服务

gitlab-ctl stop unicorn

gitlab-ctl stop sidekiq

# 从1393513186编号备份中恢复

gitlab-rake gitlab:backup:restore BACKUP=1393513186# 启动Gitlab

sudo gitlab-ctl start

Gitlab迁移

迁移如同备份与恢复的步骤一样, 只需要将老服务器/var/opt/gitlab/backups目录下的备份文件拷贝到新服务器上的/var/opt/gitlab/backups即可(如果你没修改过默认备份目录的话). 但是需要注意的是新服务器上的Gitlab的版本必须与创建备份时的Gitlab版本号相同. 比如新服务器安装的是最新的7.60版本的Gitlab, 那么迁移之前, 最好将老服务器的Gitlab 升级为7.60在进行备份.

其他

最新版本的Gitlab已经修复了HTTPS设备的BUG, 现在使用官方HTTPS配置即可轻松启用HTTPS.

还有一个方法,是找到备份出来的tar文件,然后解压后,编辑backup_information.yml文件,将

:gitlab_version: 8.4.1 改成 :gitlab_version: 8.6.0 ,然后重新打包(记得打包名字和之前备份的要一样,如果是在备份目录重新打包,记得将原备份文件改名)。之后运行还原就可以。

三、gitlab升级

gitlab升级:

注意事项,不要停止服务,

yum update  gitlab-ce

  

四、https配置

https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md#nginx-settings

mkdir -p /etc/gitlab/ssl

chmod 700 /etc/gitlab/ssl

在目录/etc/gitlab/下生产如下两个文件

openssl req -new -x509 -nodes -days 3560 -out gitlab.crt -keyout gitlab.key

执行后他会提示你注册一些 国家 省市 公司 邮件的信息

cp gitlab.example.com.key gitlab.example.com.crt /etc/gitlab/ssl/

然后在/etc/gitlab/gitlab.rb里配置

external_url "https://gitlab.898.com"

nginx['redirect_http_to_https'] = true

nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.crt"

nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.key"

重启配置

[root@gitlab gitlab]# gitlab-ctl reconfigure

客户端

如果你用的自己生成的非授权KEY 每个客户端都得执行这条命令去关闭 官方授权

https://gitlab.com/gitlab-org/gitlab-ce/issues/788

先 git -c http.sslVerify=false clone https://domain.com/path/to/git

然后git config http.sslVerify false


git学习参考资料

http://www.myexception.cn/software/1891171.html