linux下GitLab的安裝,linuxGitLab安裝
1、Ubuntu安裝
修改/etc/apt/sources.list.d/gitlab-ce.list,添加以下行
deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/debian jessie main
開始安裝:
# 安裝依賴包sudo apt-get install curl openssh-server ca-certificates postfix# 安裝 GitLab 社區版apt-get install gitlab-ce# 初始化,初始化完自動啟動 GitLabsudo gitlab-ctl reconfigure
2、CentOS
建立 /etc/yum.repos.d/gitlab-ce.repo,添加以下內容
[gitlab-ce]name=gitlab-cebaseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6repo_gpgcheck=0gpgcheck=0enabled=1gpgkey=https://packages.gitlab.com/gpg.key
安裝步驟:
# 安裝依賴包yum install curl openssh-server openssh-clients postfix cronie# 啟動 postfix 郵件服務service postfix start# 檢查 postfix chkconfig postfix on# 安裝 GitLab 社區版yum install gitlab-ce# 初始化 GitLabgitlab-ctl reconfigure
3、登入訪問
添加訪問的 host,修改/etc/gitlab/gitlab.rb的external_url
external_url 'http://git.test.com'
每次修改/etc/gitlab/gitlab.rb,都要運行以下命令,讓配置生效
gitlab-ctl reconfigure
在瀏覽器開啟網址http://git.test.com,登陸。預設管理員:
使用者名稱: root
密碼: 5iveL!fe
4、漢化
以下漢化步驟參考此篇文章,首先確認當前安裝版本
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
當前安裝版本是8.5.7,因此中文補丁需要打8.5版本。
複製 GitLab 源碼倉庫:
# 複製 GitLab.com 倉庫git clone https://gitlab.com/larryli/gitlab.git#或 Gitcafe.com 鏡像,速度更快git clone https://gitcafe.com/larryli/gitlab.git
運行漢化補丁:
# 8.5 版本的漢化補丁(8-5-stable是英文穩定版,8-5-zh是中文版,兩個 diff 結果便是漢化補丁)git diff origin/8-5-stable..8-5-zh > /tmp/8.5.diff# 停止 gitlabgitlab-ctl stop# 應用漢化補丁cd /opt/gitlab/embedded/service/gitlab-railsgit apply /tmp/8.5.diff # 啟動gitlabgitlab-ctl start
至此,漢化完畢
5、備份
設定檔含密碼等敏感資訊,不要和資料備份檔案放在一起。
sh -c 'umask 0077; tar -cf $(date "+etc-gitlab-%s.tar") -C /etc/gitlab'
預設資料備份目錄是/var/opt/gitlab/backups,手動建立備份檔案:
# Omnibus 方式安裝使用以下命令備份gitlab-rake gitlab:backup:create
日常備份,添加 crontab,運行crontab -e
# 每天2點執行備份0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
如要修改備份周期和目錄,在/etc/gitlab/gitlab.rb中修改以下兩個選項
# 設定備份周期為7天 - 604800秒gitlab_rails['backup_keep_time'] = 604800# 備份目錄gitlab_rails['backup_path'] = '/mnt/backups'
恢複之前,確保備份檔案所安裝 GitLab 和當前要恢複的 GitLab 版本一致。首先,恢複設定檔:
mv /etc/gitlab /etc/gitlab.$(date +%s)# 將下面配置備份檔案的時間戳記改為你所備份的檔案的時間戳記tar -xf etc-gitlab-1399948539.tar -C /
恢複資料檔案
# 將資料備份檔案拷貝至備份目錄cp 1393513186_gitlab_backup.tar /var/opt/gitlab/backups/# 停止串連資料庫的進程gitlab-ctl stop unicorngitlab-ctl stop sidekiq# 恢複1393513186這個備份檔案,將覆蓋GitLab資料庫!gitlab-rake gitlab:backup:restore BACKUP=1393513186# 啟動 GitLabgitlab-ctl start# 檢查 GitLabgitlab-rake gitlab:check SANITIZE=true
6、持續整合(GitLab-CI)
GitLab 從 8.0 之後就整合了GitLab-CI,所以不需要再另外安裝 CI。但需要安裝Runner
1.添加 Runner 安裝源
# For Debian/Ubuntucurl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.deb.sh | sudo bash# For CentOScurl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | sudo bash
安裝gitlab-ci-multi-runner
# For Debian/Ubuntuapt-get install gitlab-ci-multi-runner# For CentOSyum install gitlab-ci-multi-runner
2.註冊 Runner。擷取Token:以管理員身份登入GitLab,進入管理地區,點擊側邊欄的Runner,如,“註冊授權碼”後的字串便是Token。
sudo gitlab-ci-multi-runner registerRunning in system-mode.Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci):http://git.home.com/ciPlease enter the gitlab-ci token for this runner:xxxx # 輸入TokenPlease enter the gitlab-ci description for this runner:[xxy-web-test-02]: test-runner # 輸入runner的名稱Please enter the gitlab-ci tags for this runner (comma separated):test,php # 輸入runner的標籤,以區分不同的runner,標籤間逗號分隔Registering runner... succeeded runner=YDPz2or3Please enter the executor: ssh, shell, parallels, docker, docker-ssh, virtualbox:shellRunner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
註冊完成便可在中查看你所註冊的Runner。至此,所有安裝完畢,Runner的構建,後續補充。
centos添加gitlab-ce.repo後,需要執行sudo yum makecache
參考文章
http://serverfault.com/questions/683196/502-gitlab-is-not-responding-after-change-username
http://skyao.github.io/2015/02/16/git-gitlab-setup/
https://gitlab.com/gitlab-org/omnibus-gitlab/issues/148
http://blog.csdn.net/wangxicoding/article/details/43738137
http://stackoverflow.com/questions/27816046/gitlab-is-not-responding-502-on-ubuntu-14-04-after-starting-server
http://www.cnblogs.com/jasondan/p/4056669.html
http://www.open-open.com/lib/view/open1399684894447.html
http://www.jianshu.com/p/7a0d6917e009