基本介紹nginx
GitLab是一個自託管的Git項目倉庫,能夠本身搭建我的代碼管理的倉庫,功能與github相似。git
安裝github
下載 gitlab下載地址: https://about.gitlab.com/downloads/redis
安裝依賴的包sql
sudo yum install curl-devel
sudo yum install expat-devel
sudo yum install gettext-devel
sudo yum install openssl-devel
sudo yum install zlib-devel
sudo yum install perl-devel
sudo yum install curl
sudo yum install openssh-server
sudo yum install openssh-clients
sudo yum install postfix
sudo yum install cronie
Ubuntu系統使用apt-get方式安裝依賴包。數據庫
使用gitlab官網的腳本安裝ruby
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
或者使用gitlab的yum安裝gitlabbash
sudo yum install gitlab-ce
安裝完畢後,使用Web登陸運維
技術分享ssh
進入gitlab的管理頁面,進行經常使用的分組,工程,用戶等功能點的維護。
技術分享
安裝完gitlab後的運維操做
初次配置服務
sudo gitlab-ctl reconfigure
啓動服務
sudo gitlab-ctl start
中止服務
sudo gitlab-ctl stop
重啓服務
sudo gitlab-ctl restart
檢查服務的日誌信息
sudo gitlab-ctl tail redis
sudo gitlab-ctl tail postgresql
sudo gitlab-ctl tail gitlab-workhorse
sudo gitlab-ctl tail logrotate
sudo gitlab-ctl tail nginx
sudo gitlab-ctl tail sidekiq
sudo gitlab-ctl tail unicorn
檢查服務狀態
sudo gitlab-ctl status
通常服務狀態顯示信息
顯示格式:
狀態 : 進程名稱:(進程ID)運行時間(秒);進程的日誌服務進程和運行時間
run: gitlab-workhorse: (pid 4752) 10759s; run: log: (pid 1077) 13185s
run: logrotate: (pid 12616) 3557s; run: log: (pid 1079) 13185s
run: nginx: (pid 4764) 10758s; run: log: (pid 1076) 13185s
run: postgresql: (pid 4770) 10757s; run: log: (pid 1073) 13185s
run: redis: (pid 4778) 10757s; run: log: (pid 1072) 13185s
run: sidekiq: (pid 4782) 10756s; run: log: (pid 1075) 13185s
run: unicorn: (pid 4786) 10756s; run: log: (pid 1074) 13185s
狀態 說明
run 運行狀態
down 服務中止
常見的問題
500
Whoops, something went wrong on our end.
Try refreshing the page, or going back and attempting the action again.
Please contact your GitLab administrator if this problem persists.
如何檢查和定位問題?
使用命令檢查全部服務的狀態
sudo gitlab-ctl status
檢查服務狀態以下
run: gitlab-workhorse: (pid 4752) 10862s; run: log: (pid 1077) 13288s
run: logrotate: (pid 16553) 59s; run: log: (pid 1079) 13288s
run: nginx: (pid 4764) 10861s; run: log: (pid 1076) 13288s
run: postgresql: (pid 4770) 10860s; run: log: (pid 1073) 13288s
run: redis: (pid 4778) 10860s; run: log: (pid 1072) 13288s
run: sidekiq: (pid 4782) 10859s; run: log: (pid 1075) 13288s
run: unicorn: (pid 4786) 10859s; run: log: (pid 1074) 13288s
定位問題
從服務狀態信息中顯示數據庫postgresql的狀態是down,即服務中止。
檢查數據庫postgresql的運行日誌,檢查出現什麼錯誤?
$ sudo gitlab-ctl tail postgresql
==> /var/log/gitlab/postgresql/state <==
==> /var/log/gitlab/postgresql/current <==
2017-12-21_02:49:51.42192 FATAL: terminating connection due to administrator command
2017-12-21_02:49:51.42194 FATAL: terminating connection due to administrator command
2017-12-21_02:49:51.42194 LOG: autovacuum launcher shutting down
2017-12-21_02:49:51.42287 FATAL: terminating connection due to administrator command
2017-12-21_02:49:51.42289 FATAL: terminating connection due to administrator command
2017-12-21_02:49:51.42463 LOG: shutting down
2017-12-21_02:49:51.59345 LOG: database system is shut down
2017-12-21_02:50:43.38811 LOG: database system was shut down at 2017-12-21 02:49:51 GMT
2017-12-21_02:50:43.41991 LOG: database system is ready to accept connections
2017-12-21_02:50:43.42055 LOG: autovacuum launcher started
日誌顯示,數據庫的訪問權限應該是隻有用戶自己有讀寫執行的權限,用戶組和其餘用戶不能有權限。
修改數據庫數據的權限後,檢查服務運行正常。
瞭解了問題的定位和解決方式,其餘問題也很容易在日誌中發現和解決,問題多是磁盤空間少,用戶權限錯誤或者其餘緣由。
Gitlab 修改root用戶密碼
使用rails工具打開終端
sudo gitlab-rails console production
查詢用戶的email,用戶名,密碼等信息,id:1 表示root帳號
user = User.where(id: 1).first
從新設置密碼
user.password = ‘新密碼‘
user.password_confirmation = ‘新密碼‘
保存密碼
user.save!
完整的操做ruby腳本
user = User.where(id: 1).first
user.password = ‘新密碼‘
user.password_confirmation = ‘新密碼‘
user.save!
而後使用重置過的密碼從新登陸。
git 客戶端下載地址:https://git-scm.com/download/winLinux有關的能夠直接yum 安裝或者apt-get 安裝Centos: yum install git Ubuntu: apt-get install git