Linux安裝git的rpm包
安裝版本:14.8.1-jh
1.安裝配置依賴項
yum install -y curl policycoreutils-python openssh-server perl
systemctl enable sshd
systemctl start sshd
yum install postfix
systemctl enable postfix
systemctl start postfix
2.下載安裝包
將rpm包下載到指定路徑
wget -P /home/git https://omnibus.gitlab.cn/el/7/gitlab-jh-14.8.1-jh.0.el7.x86_64.rpm
3.安裝rpm包
rpm -Uvh gitlab-jh-14.8.1-jh.0.el7.x86_64.rpm
4.修改gitlab設置
vi /etc/gitlab/gitlib.rb
external_url 'http://ip'
5.使配置生效
gitlab-ctl reconfigure
6.開啟服務
gitlab-ctl start
7.訪問網頁
訪問/etc/gitlab/gitlab.rb中external_url配置的地址訪問
http://ip
8.登錄
用戶名:root
密碼是第一次運行gitlab-ctl reconfigure生成的
vim /etc/gitlab/initial_root_password

登錄成功之后,盡快修改密碼
出於安全原因,24 小時后,此文件會被第一次 gitlab-ctl reconfigure 自動刪除,因此若使用隨機密碼登錄,建議安裝成功初始登錄成功之后,立即修改初始密碼
更改git的存儲路徑
vim /etc/gitlab/gitlab.rb
修改如下
git_data_dirs({
"default" => {
"path" => "需要修改的文件夾絕對路徑"
}
})
修改之后
gitlab-ctl stop (停止GitLab服務,防止用戶寫入數據)
gitlab-ctl reconfigure (使其修改配置生效)
gitlab-ctl start(開啟服務,驗證一下是否能通過web訪問)
配置生效之后,目標文件夾下會存在/repositories子目錄
錯誤整理
1.restart_log_service
在gitlab-ctl reconfigure時出現:
Mixlib::ShellOut::ShellCommandFailed: ruby_block[restart_log_service]
解決方法:需要清理機器的緩存,之后再次運行gitlab-ctl reconfigure
echo 3 > /proc/sys/vm/drop_caches
2.編譯時遇到usermod,user,group等關鍵詞的錯誤
Running handlers: There was an error running gitlab-ctl reconfigure:
account[GitLab user and group] (gitlab::users line 28) had an error: Mixlib::ShellOut::ShellCommandFailed: linux_user[GitLab user and group] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/resources/account.rb line 51) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '8' ---- Begin output of ["usermod", "-s", "/bin/sh", "-d", "/var/opt/gitlab", "git"] ---- STDOUT: STDERR: usermod: user git is currently used by process 15309 ---- End output of ["usermod", "-s", "/bin/sh", "-d", "/var/opt/gitlab", "git"] ---- Ran ["usermod", "-s", "/bin/sh", "-d", "/var/opt/gitlab", "git"] returned 8
解決方法:需要修改配置文件中的信息,之后重新運行gitlab-ctl reconfigure
user['username'] = "gitlab"
user['group'] = "gitlab"
3.gitlab頁面出現502錯誤
(1)
頁面響應比較慢,等待20s左右的時間重新刷新,如果無法顯示,則重啟服務
gitlab-ctl restart
查看是否有服務未啟動成功
(2)
有可能是與其自帶的nginx端口沖突,換個端口就好了
vim /etc/gitlab/gitlab.rb
修改:
external_url 'http://ip:端口'
修改Advanced settings下的puma['port']
兩次修改的端口不相同,不然會沖突
vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
listen *:端口
用的是external_url配置的端口
gitlab-ctl stop (停止GitLab服務,防止用戶寫入數據)
gitlab-ctl reconfigure (使其修改配置生效)
gitlab-ctl start(開啟服務,驗證一下是否能通過web訪問)
4.某個服務未啟動
在執行gitlab-ctl start時,發現某個服務啟動失敗
例如:
timeout: down: alertmanager: 0s, normally up, want up
此時使用命令
gitlab-ctl tail 服務名
可以查看問題服務的報錯日志,根據日志解決相關問題,之后重新啟動gitlab服務
gitlab組件日志路徑:/var/log/gitlab
gitlab配置路徑:/etc/gitlab/ 路徑下有gitlab.rb配置文件
應用代碼和組件依賴程序:/opt/gitlab
各個組件存儲路徑: /var/opt/gitlab/
倉庫默認存儲路徑 /var/opt/gitlab/git-data/repositories
版本文件備份路徑:/var/opt/gitlab/backups/
nginx安裝路徑:/var/opt/gitlab/nginx/
redis安裝路徑:/var/opt/gitlab/redis
