Technology Sharing

  • 首页
  • 资料分享
  • 在线工具
    • 随机密码生成器
  • 介绍
  • RSS
  • privacy
  • 云产品推广
    • 腾讯云
    • 阿里云
Share IT knowledge
  1. 首页
  2. git
  3. 正文

安装gitlab-ce ( 社区版 )

2022年6月27日 241点热度 0人点赞 0条评论

环境:cenots7

添加GitLab 仓库

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

安装gitlab-ce ( 社区版 )

yum install -y gitlab-ce

配置gitlab完成初始化工作

vim /etc/gitlab/gitlab.rb

将external_url 'http://xxxx.xxxx.xxxx.xxxx'修改成你自己的域名地址或ip
例如:external_url "http://gitlab.example.com"

重新编译配置并启动 GitLab

gitlab-ctl reconfigure
gitlab-ctl start

防火墙需放行80,443端口
浏览器访问域名或ip进行登录,一开始会得到一个密码重置页面,输入密码后,使用默认用户root 登录。

启用https访问(通过ip地址访问gitlab,请跳过此步骤)

申请Let’s Encrypt的证书
安装certbot

yum install epel-release -y
yum install python2-certbot-nginx -y

获取证书,根据提示填入域名,站点等信息

certbot certonly

申请完成后,证书会放到 /etc/letsencrypt/live/gitlab.example.com 目录下

配置gitlab支持https,支持ipv6,设置时区

vim /etc/gitlab/gitlab.rb

external_url "https://gitlab.example.com"
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/letsencrypt/live/gitlab.example.com/fullchain.pem"
nginx['ssl_certificate_key'] = "/etc/letsencrypt/live/gitlab.example.com/privkey.pem"
nginx['listen_addresses'] = ['*', '[::]']
gitlab_rails['time_zone'] = 'Asia/Shanghai'

gitlab 重新编译配置

gitlab-ctl reconfigure

到此你已完成gitlab安装

Gitlab备份

使用Gitlab一键安装包安装Gitlab非常简单, 同样的备份恢复与迁移也非常简单. 使用一条命令即可创建完整的Gitlab备份:

gitlab-rake gitlab:backup:create

使用以上命令会在/var/opt/gitlab/backups目录下创建一个名称类似为1510886635_2022_06_24_15.0.0_gitlab_backup.tar的压缩包, 这个压缩包就是Gitlab整个的完整部分, 其中开头的1510886635_2022_06_24_15.0.0是备份创建的日期和版本

另外需要备份以下文件;

/etc/gitlab/gitlab.rb          gitlab 配置文件备份
/var/opt/gitlab/nginx/conf     nginx配置文件 备份
/etc/gitlab/ssl                SSL文件目录需要备份

Gitlab自动备份

实现每晚21点进行一次自动备份:通过crontab使用备份命令实现

00 21 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create

Gitlab恢复

停止相关数据连接服务

gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq

修改ownership

chown git.git 1510886635_2022_06_24_15.0.0_gitlab_backup.tar

从1510886635_2022_06_24_15.0.0 编号备份中恢复

gitlab-rake gitlab:backup:restore BACKUP=1510886635_2022_06_24_15.0.0

启动Gitlab

gitlab-ctl start

GitLab迁移

需要注意的是新服务器上的Gitlab的版本必须与创建备份时的Gitlab版本号相同. 比如新服务器安装的是最新的15.0.0版本的Gitlab, 那么迁移之前, 最好将老服务器的Gitlab 升级为15.0.0在进行备份,否则在新服务器上恢复不了。

gitlab 更新

注意,gitlab 更新,一次只能更新一个次版本,比如 15.0.x 只能更新到 15.1.x , 而不能只能 15.2.x。另外,不同版本对于 postgresql 数据库版本也不尽相同,高版本有时候会采用更高版本的 postgresql 数据库,也要随着更新。

yum --showduplicates list all | grep gitlab |grep gitlab-ce  查看最新版本(gitlab-ce-15.1.0-ce.0.el7)
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION  现在版本(gitlab-ce-15.0.0-ce.0.el7)
yum update  gitlab-ce-15.1.0-ce.0.el7
gitlab-ctl reconfigure

打赏微海报分享
标签: 暂无
最后更新:2024年1月19日

nico

Linux运维工程师 软考网络工程师 && 软考信息安全工程师

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

nico

Linux运维工程师
软考网络工程师 && 软考信息安全工程师

最新 热点 随机
最新 热点 随机
linux部署JDK环境 [Solved] MariaDB import issue: Error at line 1: Unknown command '\-'. Could not retrieve mirrorlist http://mirrorlist.centos.org/ CentOS 7 Kubernetes如何删除卡在“Terminating”状态的命名空间 解决GitLab Runner签名无效 如何禁用 Ubuntu "Daemons using outdated libraries" 弹出窗口
Apt安装最新版本的Go语言环境 curl 获取状态码和跳转链接 如何解决Linux中“device is busy”错误并介绍fuser命令(CentOS和Ubuntu) 使用 Python3 代理 Mailgun 发送电子邮件的方法 GitLab CI/CD部署 [nginx]proxy_pass 失败时回退到 try_files
最近评论
woodcockkienzlelsj8o9+73s48g9rr3m0@gmail.com 发布于 10 个月前(07月17日) necessitatibus corporis et odit nam quo harum et c...
RonaldG 发布于 10 个月前(07月07日) Very interesting topic, thank you for putting up.&...
小黑 发布于 1 年前(12月28日) 不错
nico 发布于 2 年前(02月09日) 嘻嘻嘻!!!
Bruse 发布于 2 年前(02月09日) 我来啦!!!
nico 发布于 2 年前(12月10日) 方便查询
Justin 发布于 2 年前(12月10日) 写的很好,谢谢分享!我 Mark 一下~
nico 发布于 3 年前(11月18日) 主题的原因吧
Justin 发布于 3 年前(09月22日) 这篇文章的质量很高呀!写得很详细~ 话说你的文章是隐藏了发布时间吗?
Justin 发布于 3 年前(08月27日) 好家伙,这标题乍一看还以为你打算进军英文技术写作领域了🤓

COPYRIGHT © 2023 Technology Sharing. ALL RIGHTS RESERVED.

备案图标 皖公网安备34132402000202 皖ICP备2023004851号-1