1. 安装docker
apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
参考文章:
2. 安装gitlab-ce
apt-get install postfix -y
cd /tmp
curl -LO https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh
apt update
apt install gitlab-ce
# 或者从清华源上下载下来,使用 dpkg -i <deb> 手动安装
安装完成后,修改配置文件:
vim /etc/gitlab/gitlab.rb
# 修改external_url 为幺使用的服务器地址
external_url 'https://x.x.x.x:8100'
# 修改数据存放目录
git_data_dirs({
"default" => {
"path" => "/mnt/nfs-01/git-data"
}
})
设置存储仓库数据的备用目录
注意的是:自GitLab 8.10开始,可以通过在/etc/gitlab/gitlab.rb文件中添加下面的几行配置, 来增加多个 git 数据存储目录。
git_data_dirs({
"default" => { "path" => "/var/opt/gitlab/git-data" }, //默认存储目录
"alternative" => { "path" => " /home/gitlab-data" } //备用存储目录
})
# 修改postgressql的端口
# 停止gitlab服务
sudo gitlab-ctl stop
# 启动gitlab服务
sudo gitlab-ctl reconfigure
# 重启所有gitlab组件
sudo gitlab-ctl restart
# 启动所有gitlab组件
sudo gitlab-ctl start
# 启用开机自启动
sudo systemctl enable gitlab-runsvdir.service
初始化数据
gitlab-rake gitlab:setup
参考文章:
- 2023最新Ubuntu安装部署Gitlab详细教程(每个步骤均配图)_gitlab ubuntu_Palp1tate的博客-CSDN博客
- https://blog.csdn.net/u014072827/article/details/117780562
默认密码:在 /etc/gitlab/initial_root_password
中
root:。。。。
3. gitlab配置邮箱
参考文章:Gitlab服务器邮箱配置,实现自动为用户发送邮件_gitlab邮箱发送邮件_SageCat郭帅强的博客-CSDN博客
# gitlab_rails['smtp_enable'] = true
# gitlab_rails['smtp_address'] = "smtp.server"
# gitlab_rails['smtp_port'] = 465
# gitlab_rails['smtp_user_name'] = "smtp user"
# gitlab_rails['smtp_password'] = "smtp password"
# gitlab_rails['smtp_domain'] = "example.com"
# gitlab_rails['smtp_authentication'] = "login"
# gitlab_rails['smtp_enable_starttls_auto'] = true
# gitlab_rails['smtp_tls'] = false
# gitlab_rails['smtp_pool'] = false
使用命令测试邮件:
Notify.test_email('xxx@xxx.com','email title','email content desc').deliver_now
4. pip更换源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
5. 500错误处理
查看日志/var/log/gitlab/gitlab-rails/production.log
ActiveRecord::ConnectionNotEstablished (could not fork new process for connection: Resource temporarily unavailable
could not fork new process for connection: Resource temporarily unavailable
):
lib/gitlab/middleware/release_env.rb:13:in `call'
Raven 3.1.2 configured not to capture errors: DSN not set
Raven 3.1.2 configured not to capture errors: DSN not set
ActiveRecord::ConnectionNotEstablished (could not fork new process for connection: Resource temporarily unavailable
could not fork new process for connection: Resource temporarily unavailable
):
https://www.mdaima.com/it/6903.html
6. 邮件配置遇到的错误
主要有这么几种错误:
# gitlab-rails console
--------------------------------------------------------------------------------
Ruby: ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x86_64-linux]
GitLab: 16.3.2 (88bbc405d6b) FOSS
GitLab Shell: 14.26.0
PostgreSQL: 13.11
------------------------------------------------------------[ booted in 22.23s ]
Loading production environment (Rails 7.0.6)
irb(main):001:0> Notify.test_email('chengxiang.luo@test.com','email title','email content desc').deliver_now
Delivered mail 65080db86def1_3468432db4637fc@star-SYS-741GE-TNRT.mail (27.1ms)
/opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/net-protocol-0.1.3/lib/net/protocol.rb:46:in `connect_nonblock': SSL_connect returned=1 errno=0 peeraddr=127.0.0.1:25 state=error: wrong version number (OpenSSL::SSL::SSLError)
irb(main):004:0> Notify.test_email('chengxiang.luo@test.com','email title','email content desc').deliver_now
/opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/activerecord-7.0.6/lib/active_record/connection_adapters/postgresql_adapter.rb:768:in `exec_params': PG::ConnectionBad: PQconsumeInput() server closed the connection unexpectedly (ActiveRecord::StatementInvalid)
This probably means the server terminated abnormally
before or while processing the request.
/opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/activerecord-7.0.6/lib/active_record/connection_adapters/postgresql_adapter.rb:768:in `exec_params': PQconsumeInput() server closed the connection unexpectedly (PG::ConnectionBad)
This probably means the server terminated abnormally
before or while processing the request.
irb(main):005:0> Notify.test_email('chengxiang.luo@test.com','email title','email content desc').deliver_now
/opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/activerecord-7.0.6/lib/active_record/connection_adapters/postgresql_adapter.rb:768:in `exec_params': PG::ConnectionBad: PQsocket() can't get socket descriptor (ActiveRecord::StatementInvalid)
/opt/gitlab/embedded/lib/ruby/gems/3.0.0/gems/activerecord-7.0.6/lib/active_record/connection_adapters/postgresql_adapter.rb:768:in `exec_params': PQsocket() can't get socket descriptor (PG::ConnectionBad)
通常来说,都是tls的问题,需要修改配置:
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_enable_starttls_auto'] = false
这两个全改为flase即可发送成功。
7. 使用docker部署极狐版本
export GITLAB_HOME=/data1/gitlab
sudo docker run --detach \
--hostname gitlab.example.com \
--publish 8443:443 --publish 8100:80 --publish 8022:22 \
--name gitlab \
--restart always \
--volume $GITLAB_HOME/config:/etc/gitlab \
--volume $GITLAB_HOME/logs:/var/log/gitlab \
--volume $GITLAB_HOME/data:/var/opt/gitlab \
--shm-size 8192m \
registry.gitlab.cn/omnibus/gitlab-jh:latest
评论区