GitLab:修订间差异

来自Gea-Suan Lin's Wiki
跳到导航 跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
 
(未显示同一用户的16个中间版本)
第7行: 第7行:
== 安裝 ==
== 安裝 ==


 官方 說明記憶體一般 建議 為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
 官方 建議 服務500人 )<ref>{{Cite web |url=https://docs.gitlab.com/ee/install/requirements.html |title=Requirements |accessdate=2023-03-08}}</ref>
 
* 4 CPU cores
* 4 GB RAM
* 2 GB Swap
 
實際測試發現剛裝完大約吃1.5 GB的記憶體,一個人自己用之後會 到3 GB左右。


 這邊介紹的是[[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>:
第31行: 第37行:
=== 帳號 ===
=== 帳號 ===


* 安裝完 後馬上透過網頁連,可以設定 密碼 。設定完後可以用預設帳號root與剛剛所設定 密碼登入
* 安裝完 後console會出現指示初始 密碼 ,目前 版本會在<code>/etc/gitlab/initial_root_password</codE>
* 通常會關閉註冊(在網頁界面上就可以關閉)。
* 通常會關閉註冊(在網頁界面上就可以關閉)。
* 使用LDAP認證的設定需要透過<code>/etc/gitlab/gitlab.rb</code>修改,使用LDAPS的需要改設定使用<code>port: 636</code>與<code>encryption: 'simple_tls'</code>:
* 使用LDAP認證的設定需要透過<code>/etc/gitlab/gitlab.rb</code>修改,使用LDAPS的需要改設定使用<code>port: 636</code>與<code>encryption: 'simple_tls'</code>:
第62行: 第68行:
=== 記錄檔 ===
=== 記錄檔 ===


 最容易爆掉的是[[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>flags</code>限縮大小:
 最容易爆掉的是[[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">
<syntaxhighlight lang="ruby">
第71行: 第77行:
}
}
</syntaxhighlight>
</syntaxhighlight>
=== 自己的nginx ===
官方有文件說明如何修改<ref>{{Cite web| url=https://docs.gitlab.com/omnibus/settings/nginx.html#using-a-non-bundled-web-server| title=Using a non-bundled web-server |language=en |accessdate=2021-06-24}}</ref>,先從<code>/etc/gitlab/gitlab.rb</code>裡關閉[[nginx]]相關設定。找到各自對應的區塊加上對應的設定:
<syntaxhighlight lang="ruby">
nginx['enable'] = false
web_server['external_users'] = ['www-data']
gitlab_rails['trusted_proxies'] = [ '127.0.0.0/8' ]
</syntaxhighlight>
接下來讓設定生效:
<syntaxhighlight lang="bash">
sudo gitlab-ctl reconfigure
</syntaxhighlight>
後續就可以設定自己的nginx了。


== 常用指令 ==
== 常用指令 ==


* sudo gitlab-ctl reconfigure
重新讀取設定檔並且更新環境:
* sudo gitlab-ctl renew-le-certs
 
* sudo gitlab-ctl restart
<syntaxhighlight lang="bash">
sudo gitlab-ctl reconfigure
</syntaxhighlight>
 
更新[[Let's Encrypt]]的憑證:
 
<syntaxhighlight lang="bash">
sudo gitlab-ctl renew-le-certs
</syntaxhighlight>
 
== 相關連結 ==
 
* [[GitLab/Runner]]


== 參考資料 ==
== 參考資料 ==

2023年5月26日 (五) 13:30的最新版本

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

简介

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

安装

官方的建议是(服务500人)[1]

  • 4 CPU cores
  • 4 GB RAM
  • 2 GB Swap

实际测试发现刚装完大约吃1.5 GB的内存,一个人自己用之后会到3 GB左右。

这边介绍的是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

设定

账号

  • 安装完后console会出现指示初始密码,目前的版本会在/etc/gitlab/initial_root_password
  • 通常会关闭注册(在网页界面上就可以关闭)。
  • 使用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",
}

自己的nginx

官方有文件说明如何修改[6],先从/etc/gitlab/gitlab.rb里关闭nginx相关设定。找到各自对应的区块加上对应的设定:

nginx['enable'] = false
web_server['external_users'] = ['www-data']
gitlab_rails['trusted_proxies'] = [ '127.0.0.0/8' ]

接下来让设定生效:

sudo gitlab-ctl reconfigure

后续就可以设定自己的nginx了。

常用指令

重新读取设定档并且更新环境:

sudo gitlab-ctl reconfigure

更新Let's Encrypt的凭证:

sudo gitlab-ctl renew-le-certs

相关连结

参考资料

外部链接