環境配置
CentOS Version | 7.6 |
Gitlab Version | gitlab-ce-13.12.15-ce.0.el7.x86_64 |
下載rpm包
Gitlab歷史版本下載地址:https://packages.gitlab.com/gitlab/gitlab-ce(我在這裡下載的 gitlab-ce-13.12.15-ce.0.el7.x86_64.rpm 建議使用下載工具進行下載)
wget https://d20rj4el6vkp4c.cloudfront.net/7/8/el/7/package_files/76487.rpm?t=1718811948_59a1b0efcb67106db99181bc8e4ceecdd9b6f3d9
清華大學的映象站更新比較慢,有的老版本(如13版本)都沒有更新到13版本的最新版本
安裝依賴
yum -y install policycoreutils openssh-server openssh-clients postfix policycoreutils-python
開始rpm安裝gitlab-ce-13.12.15-ce.0.el7.x86_64.rpm檔案
rpm -ivh gitlab-ce-13.12.15-ce.0.el7.x86_64.rpm
安裝完成關注以下輸出,表示已經安裝成功
修改gitlab配置檔案資訊,指定服務ip和埠號
view /etc/gitlab/gitlab.rb
修改內容如下:
將external_url後面的url替換為自己的ip+埠號,(檢視埠是否被佔用,防火牆是否放開)
新增配置資訊
第一次配置資訊,需要一定的時間,請耐心等待,直到最後看到gitlab Reconfigured! 表示配置完成。
[root@localhost ~]# gitlab-ctl reconfigure ..... ..... ..... Running handlers: Running handlers complete Chef Client finished, 426/609 resources updated in 02 minutes 55 seconds gitlab Reconfigured!
注:如果發現ip或者埠等配置資訊需要更改,每次更改完之後,一定要重新載入配置 gitlab-ctl reconfigure
重啟gitlab服務
看到如下的資訊,“ok,run ”表示各個模組啟動成功。gitlab-ctl start | stop | restart
[root@localhost ~]# gitlab-ctl restart ok: run: alertmanager: (pid 224124) 0s ok: run: gitaly: (pid 224146) 0s ok: run: gitlab-monitor: (pid 224167) 1s ok: run: gitlab-workhorse: (pid 224192) 0s ok: run: logrotate: (pid 224211) 1s ok: run: nginx: (pid 224218) 0s ok: run: node-exporter: (pid 224294) 1s ok: run: postgres-exporter: (pid 224307) 0s ok: run: postgresql: (pid 224318) 0s ok: run: prometheus: (pid 224327) 0s ok: run: redis: (pid 224371) 0s ok: run: redis-exporter: (pid 224376) 1s ok: run: sidekiq: (pid 224393) 0s ok: run: unicorn: (pid 224409) 0s
到這裡已經完成了對gitlab的安裝
瀏覽器登陸
瀏覽器訪問,http://ip:埠號
第一次訪問,直接進入更改root賬號密碼的頁面,只需要填寫密碼即可,修改完,直接跳入到登陸頁面
進入到gitlab頁面後,即可開始建立自己專案(完成)
遇到問題
1、訪問首頁報502檢視後臺日誌返現兩個錯誤
2024-06-20_01:12:21.24719 {"timestamp":"2024-06-20T01:12:21.245Z","pid":24887,"message":"* Listening on unix:///var/opt/gitlab/gitlab-rails/sockets/gitlab.socket"} 2024-06-20_01:12:21.25125 bundler: failed to load command: puma (/opt/gitlab/embedded/bin/puma) 2024-06-20_01:12:21.25130 Errno::EADDRINUSE: Address already in use - bind(2) for "127.0.0.1" port 8080 2024-06-20_01:12:21.25131 /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/puma-5.1.1/lib/puma/binder.rb:288:in `initialize' 2024-06-20_01:12:21.25133 /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/puma-5.1.1/lib/puma/binder.rb:288:in `new' 2024-06-20_01:12:21.25134 /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/puma-5.1.1/lib/puma/binder.rb:288:in `add_tcp_listener' 2024-06-20_01:12:21.25135 /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/puma-5.1.1/lib/puma/binder.rb:168:in `block in parse' 2024-06-20_01:12:21.25139 /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/puma-5.1.1/lib/puma/binder.rb:152:in `each' 2024-06-20_01:12:21.25141 /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/puma-5.1.1/lib/puma/binder.rb:152:in `parse' 2024-06-20_01:12:21.25142 /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/puma-5.1.1/lib/puma/runner.rb:144:in `load_and_bind' 2024-06-20_01:12:21.25143 /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/puma-5.1.1/lib/puma/cluster.rb:342:in `run' 2024-06-20_01:12:21.25144 /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/puma-5.1.1/lib/puma/launcher.rb:182:in `run' 2024-06-20_01:12:21.25145 /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/puma-5.1.1/lib/puma/cli.rb:80:in `run' 2024-06-20_01:12:21.25151 /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/puma-5.1.1/bin/puma:10:in `<top (required)>' 2024-06-20_01:12:21.25194 /opt/gitlab/embedded/bin/puma:23:in `load' 2024-06-20_01:12:21.25197 /opt/gitlab/embedded/bin/puma:23:in `<top (required)>'
第1個報錯是:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: connection refused
第2個報錯是:Errno::EADDRINUSE: Address already in use - bind(2) for "127.0.0.1" port 8080
在我的環境只解決埠被佔用的問題就可以了,把上面“修改gitlab配置檔案資訊,指定服務ip和埠號”,調整為8082就可以了(重新gitlab-ctl reconfigure/gitlab-ct restart即可)
補充:報8080埠被佔用,檢視8080埠發現是puma在監聽8080埠;經過上訴辦法調整成8082後重啟,發現監聽8082埠的是nginx,8080看來是puma的埠所以衝突了
其他
郵件配置
gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "your.smtp.server" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "your.smtp user" gitlab_rails['smtp_password'] = "your.smtp password" gitlab_rails['smtp_domain'] = "your.demain.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'peer' gitlab_rails['gitlab_email_from'] = 'gitlab@mail.domain.com' gitlab_rails['gitlab_email_reply_to'] = 'noreply@mail.domain.com'
檢視服務
檢視服務狀態
[root@localhost ~]# gitlab-ctl status run: alertmanager: (pid 224124) 81166s; run: log: (pid 223418) 81323s run: gitaly: (pid 224146) 81166s; run: log: (pid 223304) 81324s run: gitlab-monitor: (pid 224167) 81166s; run: log: (pid 223352) 81324s run: gitlab-workhorse: (pid 224192) 81165s; run: log: (pid 223250) 81325s run: logrotate: (pid 236092) 1964s; run: log: (pid 223251) 81325s run: nginx: (pid 227942) 80560s; run: log: (pid 223181) 81326s run: node-exporter: (pid 224294) 81164s; run: log: (pid 223308) 81324s run: postgres-exporter: (pid 224307) 81163s; run: log: (pid 223428) 81323s run: postgresql: (pid 224318) 81163s; run: log: (pid 223216) 81325s run: prometheus: (pid 224327) 81162s; run: log: (pid 223417) 81323s run: redis: (pid 224371) 81162s; run: log: (pid 223215) 81325s run: redis-exporter: (pid 224376) 81162s; run: log: (pid 223354) 81324s run: sidekiq: (pid 227863) 80573s; run: log: (pid 223158) 81326s run: unicorn: (pid 228149) 80549s; run: log: (pid 223157) 81326s 格式: 程序名稱:(程序ID編號)程序執行時間(秒);程序的日誌服務程序Id 日誌執行時間 run 表示程序執行正常 down 表示程序沒有啟動或者掛掉,我們可以檢視服務的日誌資訊,來定位問題。
檢視服務日誌
# 檢查redis的日誌 gitlab-ctl tail redis # 檢查postgresql的日誌 gitlab-ctl tail postgresql # 檢查gitlab-workhorse的日誌 gitlab-ctl tail gitlab-workhorse # 檢查logrotate的日誌 gitlab-ctl tail logrotate # 檢查nginx的日誌 gitlab-ctl tail nginx # 檢查sidekiq的日誌 gitlab-ctl tail sidekiq # 檢查unicorn的日誌 gitlab-ctl tail unicorn
注:每次修改完配置,記得啟動配置更新。
到這裡gitlab已經安裝完成