CentOS7之Gitlab服務(wù)

環(huán)境說(shuō)明

系統(tǒng)OS:CentOS7
IP: 192.168.1.2


配置過(guò)程

yum安裝--官方推薦

  1. 安裝 curl,policycoreutils-python,openssh-server服務(wù)
    # yum install curl policycoreutils-python openssh-server -y

  2. 啟動(dòng)sshd服務(wù),并激活開(kāi)機(jī)啟動(dòng)
    # systemctl enable sshd
    # systemctl start sshd

  3. 防火墻允許http服務(wù)通過(guò)
    # firewall-cmd --permanent --add-service=http
    # systemctl reload firewalld

  4. 安裝Postfix發(fā)送通知郵件
    # yum install postfix -y

  5. 啟動(dòng)postfix服務(wù),并激活開(kāi)機(jī)啟動(dòng)
    # systemctl enable postfix
    # systemctl start postfix

  6. 獲取GitLab-ee(企業(yè)版·免費(fèi)試用)Gitlab-ce(社區(qū)版·免費(fèi))軟件包yum源

# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | bash`

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

tips: curl命令執(zhí)行完成后,會(huì)在/etc/yum.repos.d目錄下生成 gitlab_gitlab-ee.repo
gitlab_gitlab-ce.repo文件。

tips: 關(guān)于gitlab-ee和gitlab-ce,二者是基于同樣的核心代碼進(jìn)行開(kāi)發(fā),只是gitlab-ee功能更強(qiáng)大,但需要付費(fèi)使用,有30天試用期。但試用期過(guò)后如果不付費(fèi),它就跟gitlab-ce功能是完全一樣的,只是需要付費(fèi)的功能無(wú)法再繼續(xù)使用而已,所以這兩個(gè)版本可以隨意選擇安裝,但如果將來(lái)有付費(fèi)的打算,直接安裝gitlab-ee版本是個(gè)有遠(yuǎn)見(jiàn)的選擇。當(dāng)然,即使不付費(fèi),gitlab-ee使用上和gitlab-ce沒(méi)有任何區(qū)別,所以接下來(lái)的操作我們就以安裝gitlab-ee為例進(jìn)行。

  1. 修改gitlab_gitlab-ee.repo文件的repo_gpgcheck屬性為0,以及baseurl屬性為清華大學(xué)的開(kāi)源鏡像站地址:
    https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7
[gitlab_gitlab-ee]
name=gitlab_gitlab-ee
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7
repo_gpgcheck=0
gpgcheck=1
enabled=1
gpgkey=https://packages.gitlab.com/gitlab/gitlab-ee/gpgkey
       https://packages.gitlab.com/gitlab/gitlab-ee/gpgkey/gitlab-gitlab-ee-3D645A26AB9FBD22.pub.gpg
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

修改完成后再刷新yum源:
# yum clean all
# yum yum makecache

tips: https://mirrors.tuna.tsinghua.edu.cn是國(guó)內(nèi)清華大學(xué)開(kāi)源鏡像站,避免yum install可能會(huì)因?yàn)榫W(wǎng)絡(luò)原因?qū)е率?/p>

  1. 安裝gitlab-ee(最新版本)
    # EXTERNAL_URL="http://192.168.1.2" yum install -y gitlab-ee

tips: 默認(rèn)安裝最新版本,如果需要安裝指定的版本,可以到清華大學(xué)開(kāi)源鏡像站下載指定版本的rpm包。通過(guò)rmp -ivh gitlab-ee-10.6.2-ee.0.el7.x86_64.rpm 進(jìn)行安裝,注意同樣需要先安裝yum install policycoreutils-python,openssh-server postfix -y 服務(wù)。

當(dāng)看到下面這個(gè)圖案的時(shí)候,就表示安裝成功了


安裝成功
  1. 啟動(dòng)gitlab服務(wù)
    # gitlab-ctl start

gitlab默認(rèn)端口為80,訪問(wèn) http://192.168.1.2訪問(wèn)gitlab,第一次訪問(wèn)會(huì)要你重置root用戶(hù)的密碼。

修改root用戶(hù)密碼

tips: 啟動(dòng)過(guò)程有點(diǎn)慢,訪問(wèn)的時(shí)候可能出現(xiàn)502超時(shí)請(qǐng)求,稍等一會(huì)就好了。


gitlab備份和恢復(fù)(倉(cāng)庫(kù)遷移)

  1. 備份
    # gitlab-rake gitlab:backup:create

tips: 備份文件默認(rèn)存放目錄:/var/opt/gitlab/backups/,備份文件以 時(shí)間戳_gitlab_backup.tar 命名:1521636693_2018_03_31_10.4.2_gitlab_backup.tar

  1. 恢復(fù)(把備份文件copy到新gitlab服務(wù)器的/var/opt/gitlab/backups/目錄下)
    # gitlab-rake gitlab:backup:restore BACKUP=1521636693_2018_03_31_10.4.2

tips: 恢復(fù)命令:gitlab-rake gitlab:backup:restore BACKUP=備份文件時(shí)間戳,恢復(fù)的時(shí)候如果版本不一致,可能報(bào)錯(cuò)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容