搭建私有倉庫gitlab


gitlab安裝

  1.關閉防火牆和selinux
  2.安裝gitlab依賴軟件
yum install curl openssh-server openssh-clients postfix  policycoreutils-python –y

  3.手動下載gitlab-ce安裝包

https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

  4.本地安裝軟件包

yum localinstall gitlab-ce-12.8.1-ce.0.el7.x86_64.rpm -y

  5.安裝完成后會出現下方圖示內容,需要編輯/etc/gitlab/gitlab.rb文件,修改external_url

[root@localhost ~]# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.2.3'

   6.配置郵箱服務

[root@localhost ~]# vim /etc/gitlab/gitlab.rb
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'xxxxxx@qq.com'    #發件郵箱
gitlab_rails['gitlab_email_display_name'] = 'gitlab'   #發件人顯示名稱

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "xxxxx@qq.com"
gitlab_rails['smtp_password'] = "xxxxsybdfdf"          #郵箱內設置
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true

  7.每次編輯gitlab.rb都需要重讀配置

[root@localhost ~]# gitlab-ctl reconfigure

  8.其他

[root@localhost ~]# gitlab-ctl  reconfigure  #重讀配置
[root@localhost ~]# gitlab-ctl  start      #啟動
[root@localhost ~]# gitlab-ctl  restart    #重啟
[root@localhost ~]# gitlab-ctl  status    #查看服務狀態
[root@localhost ~]# gitlab-ctl  stop   #停止
[root@localhost ~]# gitlab-ctl  stop nginx #單獨停止nginx
[root@localhost ~]# gitlab-ctl  tail          #查看日志

/opt/gitlab/        #gitlab程序安裝目錄
/var/opt/gitlab/  #gitlab數據目錄
/var/opt/gitlab/git-data/   #倉庫目錄  

gitlab郵件測試

郵件發不出去可能是配置有問題,控制台測試一下能不能發送郵件
[root@localhost ~]# gitlab-rails console
irb(main):003:0> Notify.test_email('郵箱地址','郵件標題','郵件內容').deliver_now 

gitlab漢化

萬惡的移動網絡連gitlab的網站都打不開,開始認為需要kx上網才能打開gitlab,后來搭完還是不管用,最后用聯通4G開熱點才特么的打開gitlab!!!浪費了我兩個小時!!!
  1.首先去gitlab官網下載漢化包 https://gitlab.com/xhang/gitlab/ 我這里下載是gitlab-12-1-stable-zh.tar.gz
  2.解壓漢化包
[root@localhost ~]# tar -xf gitlab-12-1-stable-zh.tar.gz

  3.停止gitlab

[root@localhost ~]# gitlab-ctl stop

  4.覆蓋漢化包,會出錯不用管

[root@localhost ~]# \cp -r gitlab-12-1-stable-zh/* /opt/gitlab/embedded/service/gitlab-rails/
cp: 無法以目錄"gitlab-12-1-stable-zh/log" 來覆蓋非目錄"/opt/gitlab/embedded/service/gitlab-rails/log"
cp: 無法以目錄"gitlab-12-1-stable-zh/tmp" 來覆蓋非目錄"/opt/gitlab/embedded/service/gitlab-rails/tmp"

  5.重新啟動gitlab

[root@localhost ~]# gitlab-ctl start
ok: run: alertmanager: (pid 13818) 0s
ok: run: gitaly: (pid 13828) 1s
timeout: down: gitlab-exporter: 0s, normally up, want up
ok: run: gitlab-monitor: (pid 13965) 0s
ok: run: gitlab-workhorse: (pid 13971) 0s
ok: run: grafana: (pid 13980) 1s
ok: run: logrotate: (pid 13990) 0s
ok: run: nginx: (pid 13997) 1s
ok: run: node-exporter: (pid 14003) 0s
ok: run: postgres-exporter: (pid 14009) 1s
ok: run: postgresql: (pid 14015) 0s
ok: run: prometheus: (pid 14024) 0s
ok: run: redis: (pid 14036) 1s
ok: run: redis-exporter: (pid 14040) 0s
ok: run: sidekiq: (pid 14047) 1s
ok: run: unicorn: (pid 14053) 0s

  6.進入web界面設置語言

 

 項目-用戶組-用戶之間的關系

1.先創建群組

 

 

 2.在創建項目,把項目歸並到這個群組里面

 3.在創建用戶,把用戶加入到這個群組里面,這時候創建用戶就會給用戶發郵件

 

 

 

禁用注冊功能

添加SSH公鑰認證

 gitlab備份

   1.可以手動更改備份文件目錄

[root@localhost ~]# vim /etc/gitlab/gitlab.rb
gitlab_rails['manage_backup_path'] = true              #開啟備份
gitlab_rails['backup_path'] = "/data/gitlab/backups"   #備份文件目錄
gitlab_rails['backup_keep_time'] = 604800              #備份文件保留時間(7天)

[root@localhost ~]# gitlab-ctl reconfigure

  2.手動備份數據文件,會在配置文件指定的地方生成備份文件

[root@localhost ~]# gitlab-rake gitlab:backup:create

[root@localhost ~]# ll /data/gitlab/backups/
總用量 160
-rw------- 1 git git 163840 2月  27 22:16 1582813002_2020_02_27_12.1.14_gitlab_backup.tar

  3.手動備份配置文件

[root@localhost ~]# ll /etc/gitlab/gitlab*
-rw------- 1 root root 100725 2月  27 22:13 /etc/gitlab/gitlab.rb
-rw------- 1 root root  15553 2月  27 22:15 /etc/gitlab/gitlab-secrets.json

[root@localhost ~]# ll /var/opt/gitlab/nginx/conf/
總用量 16
-rw-r--r-- 1 root root  902 2月  26 23:02 gitlab-health.conf
-rw-r--r-- 1 root root 4011 2月  27 17:24 gitlab-http.conf
-rw-r--r-- 1 root root 2978 2月  26 23:02 nginx.conf
-rw-r--r-- 1 root root  603 2月  26 23:02 nginx-status.conf

  4.可以結合crontab每天自動備份

00 02 * * * /usr/bin/gitlab-rake gitlab:backup:create > /dev/null

 gitlab恢復(如果是遷移,要注意gitlab版本號一致)

   1.先停掉gitlab的寫服務

[root@localhost ~]# gitlab-ctl stop unicorn
[root@localhost ~]# gitlab-ctl stop sidekiq

  2.恢復數據文件,不需要指定文件路徑,只需要指定文件的數字部分就行

[root@localhost ~]# gitlab-rake gitlab:backup:restore BACKUP=1582813002_2020_02_27_12.1.14
  3.恢復配置文件
  4.啟動gitlab
[root@localhost ~]# gitlab-ctl start

  

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM