環(huán)境說(shuō)明
系統(tǒng)OS:CentOS7
IP: 192.168.1.2
配置過(guò)程
yum安裝--官方推薦
安裝 curl聪全,policycoreutils-python应结,openssh-server服務(wù)
# yum install curl policycoreutils-python openssh-server -y
啟動(dòng)sshd服務(wù)羹唠,并激活開(kāi)機(jī)啟動(dòng)
# systemctl enable sshd
# systemctl start sshd
防火墻允許http服務(wù)通過(guò)
# firewall-cmd --permanent --add-service=http
# systemctl reload firewalld
安裝Postfix發(fā)送通知郵件
# yum install postfix -y
啟動(dòng)postfix服務(wù),并激活開(kāi)機(jī)啟動(dòng)
# systemctl enable postfix
# systemctl start postfix
獲取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)行玩敏。
- 修改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>
- 安裝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í)候碱璃,就表示安裝成功了
- 啟動(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用戶的密碼嵌器。
tips: 啟動(dòng)過(guò)程有點(diǎn)慢肛真,訪問(wèn)的時(shí)候可能出現(xiàn)502超時(shí)請(qǐng)求,稍等一會(huì)就好了爽航。
gitlab備份和恢復(fù)(倉(cāng)庫(kù)遷移)
- 備份
# 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
- 恢復(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ò)