一、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