GitLab:修订间差异

来自Gea-Suan Lin's Wiki
跳到导航 跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
(未显示同一用户的11个中间版本)
第1行: 第1行:
'''GitLab'''是一套以[[Git]]為中心而發展出來的軟體。
'''GitLab'''是一套以[[Git]]為中心而發展出來的軟體。
== 簡介 ==
GitLab算是目前功能性與社群數量都比較成熟的方案。


== 安裝 ==
== 安裝 ==


 官方說明記憶體一般建議為8 GB<ref>{{Cite web |url=https://docs.gitlab.com/ee/install/requirements.html |title=Requirements |accessdate=2019-12-10}}</ref>, 最少4 GB 這種情況下需要外加4 GB的Swap
 官方說明記憶體一般建議為8 GB ,最少4 GB(在這種情況下需要外加4 GB的Swap)<ref>{{Cite web |url=https://docs.gitlab.com/ee/install/requirements.html |title=Requirements |accessdate=2019-12-10}}</ref> 。實際測試發現剛裝完大約吃1.5 GB的記憶體 一個人自己用之後會到2.5 GB 左右,對於只有自己 使用的服務可以考慮2 GB的機器加上1 GB的Swap。


 這邊介紹的是[[Ubuntu]]下的安裝過程<ref>{{Cite web |url=https://about.gitlab.com/install/?version=ce#ubuntu |title=GitLab Installation |accessdate=2019-12-10}}</ref>:
 這邊介紹的是[[Ubuntu]]下的安裝過程<ref>{{Cite web |url=https://about.gitlab.com/install/?version=ce#ubuntu |title=GitLab Installation |accessdate=2019-12-10}}</ref>:
第10行: 第14行:
sudo apt install -y ca-certificates curl openssh-server postfix
sudo apt install -y ca-certificates curl openssh-server postfix
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo EXTERNAL_URL="https://gitlab.example.com" apt install gitlab-ee
sudo EXTERNAL_URL="https://gitlab.example.com" apt install gitlab-ce
</syntaxhighlight>
</syntaxhighlight>


第20行: 第24行:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo gitlab-ctl uninstall
sudo gitlab-ctl uninstall; sudo gitlab-ctl cleanse; sudo gitlab-ctl remove-accounts; sudo apt purge -y gitlab-ce; sudo rm -rf /etc/gitlab /opt/gitlab /var/log/gitlab /var/opt/gitlab
sudo gitlab-ctl cleanse
</syntaxhighlight>
sudo gitlab-ctl remove-accounts
 
sudo apt purge -y gitlab-ce
== 設定 ==
sudo rm -rf /etc/gitlab /opt/gitlab /var/log/gitlab /var/opt/gitlab
 
=== 帳號 ===
 
* 安裝完後馬上透過網頁連,可以設定密碼。設定完後可以用預設帳號root與剛剛所設定的密碼登入。
* 通常會關閉註冊(在網頁界面上就可以關閉)。
* 使用LDAP認證的設定需要透過<code>/etc/gitlab/gitlab.rb</code>修改,使用LDAPS的需要改設定使用<code>port: 636</code>與<code>encryption: 'simple_tls'</code>:
<syntaxhighlight lang="ruby">
gitlab_rails['ldap_enabled'] = true
gitlab_rails['prevent_ldap_sign_in'] = false
 
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
  main:
   label: 'LDAP'
   host: 'ldap.example.com'
   port: 389
   uid: 'uid'
   bind_dn: ''
   password: ''
   encryption: 'plain'
   verify_certificates: true
   smartcard_auth: false
   active_directory: false
   allow_username_or_email_login: true
   lowercase_usernames: true
   block_auto_created_users: false
   base: 'ou=People,dc=example,dc=com'
   user_filter: ''
   attributes:
    email: ['mail', 'email', 'userPrincipalName']
EOS
</syntaxhighlight>
 
=== 記錄檔 ===
 
最容易爆掉的是[[Prometheus]]的[[TSDB]]資料<ref>{{Cite web |url=https://forum.gitlab.com/t/clear-up-postges-prometheus-data/38216 |title=Clear up Postges / Prometheus data |accessdate=2020-08-03 |date=2020-05-29 |language=en}}</ref>,這點可以設定<code>/etc/gitlab/gitlab.rb</code>內的<code>prometheus['flags']</code>限縮大小:
 
<syntaxhighlight lang="ruby">
prometheus['flags'] = {
  'storage.tsdb.path' => "/var/opt/gitlab/prometheus/data",
  'storage.tsdb.retention.time' => "15d",
  'config.file' => "/var/opt/gitlab/prometheus/prometheus.yml",
}
</syntaxhighlight>
</syntaxhighlight>



2020年8月3日 (一) 15:21的版本

GitLab是一套以Git为中心而发展出来的软体。

简介

GitLab算是目前功能性与社群数量都比较成熟的方案。

安装

官方说明记忆体一般建议为8 GB,最少4 GB(在这种情况下需要外加4 GB的Swap)[1]。实际测试发现刚装完大约吃1.5 GB的记忆体,一个人自己用之后会到2.5 GB左右,对于只有自己在使用的服务可以考虑2 GB的机器加上1 GB的Swap。

这边介绍的是Ubuntu下的安装过程[2]

sudo apt install -y ca-certificates curl openssh-server postfix
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo EXTERNAL_URL="https://gitlab.example.com" apt install gitlab-ce

最近的版本可能会需要处理安装时Let's Encrypt凭证申请失败的相关的问题[3]

移除

移除需要多个步骤[4]

sudo gitlab-ctl uninstall; sudo gitlab-ctl cleanse; sudo gitlab-ctl remove-accounts; sudo apt purge -y gitlab-ce; sudo rm -rf /etc/gitlab /opt/gitlab /var/log/gitlab /var/opt/gitlab

设定

帐号

  • 安装完后马上透过网页连,可以设定密码。设定完后可以用预设帐号root与刚刚所设定的密码登入。
  • 通常会关闭注册(在网页界面上就可以关闭)。
  • 使用LDAP认证的设定需要透过/etc/gitlab/gitlab.rb修改,使用LDAPS的需要改设定使用port: 636encryption: 'simple_tls'
gitlab_rails['ldap_enabled'] = true
gitlab_rails['prevent_ldap_sign_in'] = false

gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
  main:
    label: 'LDAP'
    host: 'ldap.example.com'
    port: 389
    uid: 'uid'
    bind_dn: ''
    password: ''
    encryption: 'plain'
    verify_certificates: true
    smartcard_auth: false
    active_directory: false
    allow_username_or_email_login: true
    lowercase_usernames: true
    block_auto_created_users: false
    base: 'ou=People,dc=example,dc=com'
    user_filter: ''
    attributes:
      email: ['mail', 'email', 'userPrincipalName']
EOS

记录档

最容易爆掉的是PrometheusTSDB资料[5],这点可以设定/etc/gitlab/gitlab.rb内的prometheus['flags']限缩大小:

prometheus['flags'] = {
  'storage.tsdb.path' => "/var/opt/gitlab/prometheus/data",
  'storage.tsdb.retention.time' => "15d",
  'config.file' => "/var/opt/gitlab/prometheus/prometheus.yml",
}

常用指令

  • sudo gitlab-ctl reconfigure
  • sudo gitlab-ctl renew-le-certs
  • sudo gitlab-ctl restart

参考资料

外部连结