CentOS 7安裝gitlab-ee企業版

CentOS 7安裝gitlab-ee企業版

下面提供官方安裝文檔:
官方文檔地址:https://about.gitlab.com/installation/#centos-7
安裝前:

[root@localhost ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           7823         136        7486           8         200        7491
Swap:          8191           0        8191

一、安裝

1.安裝必要的依賴項

系統開放http和ssh訪問,可能有些系統沒有安裝防火牆使用的是其他安全組件,最後兩行可以不執行

sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld

安裝郵件服務器,用於發送郵件通知,如果有其他的解決方案,可以不用安裝,跳過此步

sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

安裝過程直接回車繼續…

2.下載安裝Gitlab包

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash

這一步可以設置EXTERNAL_URL=http://gitlab.example.com,用於安裝啓動後訪問gitlab,這裏如果使用https的話安裝之後還需要做一些額外的配置

sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ee

如果不設置EXTERNAL_URL=http://gitlab.example.com,可以直接安裝,安裝之後在編輯訪問url,直接安裝使用:

sudo yum install -y gitlab-ee
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.



     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ \`/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/


Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

D: %posttrans(gitlab-ee-10.1.3-ee.0.el7.x86_64): waitpid(5767) rc 5767 status 0
D: closed   db index       /var/lib/rpm/Sha1header
D: closed   db index       /var/lib/rpm/Sigmd5
D: closed   db index       /var/lib/rpm/Installtid
D: closed   db index       /var/lib/rpm/Dirnames
D: closed   db index       /var/lib/rpm/Triggername
D: closed   db index       /var/lib/rpm/Obsoletename
D: closed   db index       /var/lib/rpm/Conflictname
D: closed   db index       /var/lib/rpm/Providename
D: closed   db index       /var/lib/rpm/Requirename
D: closed   db index       /var/lib/rpm/Group
D: closed   db index       /var/lib/rpm/Basenames
D: closed   db index       /var/lib/rpm/Name
D: closed   db index       /var/lib/rpm/Packages
D: closed   db environment /var/lib/rpm
[root@localhost gitlab]# 

安裝完成以後修改文件/etc/gitlab/gitlab.rb,設置訪問url

## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
external_url 'http://10.10.10.10:80/gitlab'

二、啓動

[root@localhost gitlab]# gitlab-ctl reconfigure
....
Running handlers:
Running handlers complete
Chef Client finished, 365/538 resources updated in 03 minutes 43 seconds
gitlab Reconfigured!
[root@localhost gitlab]# free
              total        used        free      shared  buff/cache   available
Mem:        8011216     1937024     3476364       88720     2597828     5694128
Swap:       8388604           0     8388604

訪問之後系統內存(gitlab比較耗內存啊):

[root@localhost gitlab]# free
              total        used        free      shared  buff/cache   available
Mem:        8011216     3120148     2288708       88788     2602360     4510728
Swap:       8388604           0     8388604

三、修改賬號密碼

  • 注:在第一次訪問的時候會提示輸入新密碼,此時該密碼爲最初的密碼,可以在頁面設置新密碼或者通過下面的方式重置密碼
    Gitlab 修改root用戶密碼

使用root權限登錄服務器並啓動Ruby on Rails 控制檯.

[root@localhost ~]# gitlab-rails console production
Loading production environment (Rails 4.2.8)
irb(main):001:0> 

回車後感覺沒響應,耐心等待1分鐘左右…

有多種方式可以重置密碼

irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0>user.password = 'secret_pass'
irb(main):002:0>user.password_confirmation = 'secret_pass'
irb(main):002:0>user.save

或者

irb(main):001:0> user = User.find_by(email: '[email protected]')
=> #<User id:1 @root>
irb(main):002:0>user.password = 'secret_pass'
irb(main):002:0>user.password_confirmation = 'secret_pass'
irb(main):002:0>user.save

修改密碼後可以嘗試使用新密碼登錄

四、TortoiseGit clone push 項目

1.在用戶目錄下使用cmd或者git bash創建一個目錄.ssh

$ mkdir .ssh

2.使用ssh-keygen -C 郵箱 -t rsa生成公鑰和私鑰
此處郵箱爲gitlab上用戶的郵箱,輸入命令後一路回車,使用默認配置

$ ssh-keygen -C 2810010108@qq.com -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/cnlm.me/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/cnlm.me/.ssh/id_rsa.
Your public key has been saved in /c/Users/cnlm.me/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:JXOINlt4OpM92GIDCAypY97ndQcELMcjNtDE7Im9rDY 2810010108@qq.com
The key's randomart image is:
+---[RSA 2048]----+
|=. .*.o..        |
|.o . O B o       |
|. . * @ O o      |
|o. . * @ *       |
|o.. . % S .      |
| . . = * o .     |
|    + . . .      |
|   E .           |
|  . .            |
+----[SHA256]-----+

cnlm.me@DESKTOP-RKGQDB9 MINGW64 ~/.ssh

此時,生成了id-rsa私鑰和id-rsa.pub公鑰,遠程需要訪問gitlab下載和提交,需要將此公鑰配置到gitlab對應賬號下
3.配置SSH Keys

  • 登錄http://ip/gitlab
  • 點擊右上角頭像
  • settings
  • SSH Keys
  • 在Key輸入框輸入id-rsa.pub公鑰文件內容
  • 保存

4.TortoiseGit生成ppk私鑰
由於本地使用的是TortoiseGit,因此需要生成一個.ppk的私鑰

  • 在TortoiseGit安裝目錄bin下雙擊打開puttygen.exe
  • 點擊load,選中id-rsa私鑰
  • 點擊Save private key,.ssh目錄會生成一個.ppk的私鑰

5.clone

  • 鼠標右鍵,git clone …
  • URL輸入git@ip:test/pms_dev.git
  • Directory輸入….\gitlab\pms_dev
  • 勾選Load Putty Key,選擇文件C:\Users….ssh\ppk.ppk
  • OK
    成功將項目clone到了本地

6.push

  • 修改其中一個文件
  • 鼠標右鍵,Git Commit -> “master”…
  • 提交到本地倉庫後直接push到遠程gitlab master
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章