天天看點

gitlab搭建

安裝基礎包

     yum -y install curl policycoreutils openssh-server openssh-clients

啟動sshd

systemctl enable sshd

systemctl start sshd

安裝postfix

yum -y install postfix

systemctl enable postfix

systemctl start postfix

添加防火牆規則

firewall-cmd --permanent --add-service=http

systemctl reload firewalld

下載下傳并安裝軟體包(軟體包下載下傳較慢)

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

yum install gitlab-ce

預設安裝的是最新的gitlab-ce的包,如果需要特定的版本可以在官網去下載下傳特定的版本 

位址:https://packages.gitlab.com/gitlab/gitlab-ce/

配置并啟動gitlab

gitlab-ctl reconfigure

(執行上面的指令會報錯

gitlab-ctl reconfigure 報錯解決方法

gitlab搭建

解決方法:

是因為/etc/gitlab/gitlab.rb檔案中的内容是:

external_url 'hostname'

将其修改為:

external_url='hostname'

即可,隻需要在原來的配置項中添加個 ‘=’ 即可,為了避免域名引起的問題,也可以直接配置ip,如下所示:

external_url='192.168.1.49'。

預設賬戶密碼是

Username: root

Password: 5iveL!fe

備份指令

gitlab-rake gitlab:backup:create

預設的備份目錄為: /var/opt/gitlab/backups

備份檔案名類似: 1393513186_gitlab_backup.tar 

備份目錄的修改

vi /etc/gitlab/gitlab.rb

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

提示:gitlab資料的恢複或者遷移成功的前提——兩台伺服器的gitlab的版本必須相同,若不相同則可能遷移或者恢複失敗

将備份檔案放在gitlab的預設備份目錄

比如/var/opt/gitlab/backups下的1458217074_gitlab_backup.tar

恢複或者還原

停服務

gitlab-ctl stop unicorn

gitlab-ctl stop sidekiq

恢複資料

gitlab-rake gitlab:backup:restore BACKUP=1458213020

BACKUP後面跟的是備份檔案的時間戳,比如恢複備份檔案1458217074_gitlab_backup.tar

gitlab-rake gitlab:backup:restore BACKUP=1458217074

回複完啟動服務

gitlab-ctl start