gitlab

1. 服务的下载、安装和卸载

1. 环境配置

建议配置:

  1. cpu:8核
  2. 内存:32G
  3. 硬盘:建议网络存储,raid 0

实验环境:

  1. cpu:2核
  2. 内存:4G
  3. 硬盘:虚拟磁盘
  4. ip:192.168.0.130
  5. 操作系统:Ubuntu 18.04.4 LTS
  6. 安装版本:gitlab-ce_11.11.8-ce(汉化支持兼容性高)

2. 下载、安装

安装包下载位置(gitlab-ce_11.11.8-ce):
清华源 七牛

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 下载安装包
root@gitlab:~# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu/pool/bionic/main/g/gitlab-ce/gitlab-ce_11.11.8-ce.0_amd64.deb

# 直接安装
root@gitlab:~# dpkg -i gitlab-ce_11.11.8-ce.0_amd64.deb

#需要在/etc/gitlab/gitlab.rb修改配置文件,配置域名,修改邮件发送地址(非必须,用户修改密码使用。)
#configuration in /etc/gitlab/gitlab.rb file.

vim /etc/gitlab/gitlab.rb

external_url 'http://gitlab.example.com'
==>
external_url 'http://192.168.0.130'

#Then, you can start your GitLab instance by running the following command:
# sudo gitlab-ctl reconfigure
# 修改配置完成后使用gitlab-ctl reconfigure让配置生效
# 运行,第一次运行需要大概2-5分钟,看系统性能。
root@gitlab:~# gitlab-ctl reconfigure

3. 相关文件

  1. /etc/gitlab 配置文件目录
  2. /run/gitlab 运行pid目录
  3. /opt/gitlab 安装目录
  4. /var/opt/gitlab 数据目录,重要,代码位置
  5. /var/log/gitlab 日志目录

2. 服务的启动、停止和汉化

1. 启动和停止

1
2
3
4
5
6
7
8
9
10
11
12
# 启动服务
root@gitlab:~/11# gitlab-ctl start
# 停止服务
root@gitlab:~/11# gitlab-ctl stop
# 重启服务
root@gitlab:~/11# gitlab-ctl restart
# 查看服务运行状态
root@gitlab:~/11# gitlab-ctl status
# 查看各个组件的日志
root@gitlab:~/11# gitlab-ctl tail nginx
# 修改配置文件后需要执行让其生效
root@gitlab:~# gitlab-ctl reconfigure

2. 汉化

汉化项目地址

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 查看gitlab的版本号
root@gitlab:~# cat /opt/gitlab/version-manifest.txt

#下载汉化包
root@gitlab:~# wget https://gitlab.com/xhang/gitlab/-/archive/v11.11.8-zh/gitlab-v11.11.8-zh.zip

# 停止gitlab
root@gitlab:~# gitlab-ctl stop

# 备份原数据
root@gitlab:~# cp -rp /opt/gitlab/embedded/service/gitlab-rails /opt/gitlab-rails.bak

# 解压汉化包
root@gitlab:~# tar -xvf gitlab-v11.11.8-zh-.tar.gz

# 汉化
root@gitlab:~# cp -rf gitlab-v11.11.8-zh/* /opt/gitlab/embedded/service/gitlab-rails/

# 重新读取配置文件
root@gitlab:~# gitlab-ctl reconfigure

#启动gitlab
root@gitlab:~# gitlab-ctl start

3. 服务的升级和降级

暂无

4. 服务数据的备份和恢复

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
step1:停止gitlab的相关服务,但是不能全部关掉
root@gitlab:~/trad# gitlab-ctl stop unicorn
root@gitlab:~/trad# gitlab-ctl stop sidekiq

step2:手动备份测试
root@gitlab:~/trad# gitlab-rake gitlab:backup:create
备份的目录:/var/opt/gitlab/backups
备份文件名称:1603287165_2020_10_21_11.11.8_gitlab_backup.tar 时间戳_备份日期_备份版本_itlab_backup.tar

step3:启动gitlab
root@gitlab:~/trad# gitlab-ctl start

step4:gitlab备份数据恢复
先停止gitlab的unicorn和sidekiq服务
root@gitlab:~/trad# gitlab-rake gitlab:backup:restore BACKUP=1603287433_2020_10_21_11.11.8
# 恢复只需要指定到版本号
# 需要输入yes确认
# 启动关闭的服务
root@gitlab:~/trad# gitlab-ctl start

5. 服务的高可用和扩展

暂无

6. 服务的dockerfile和k8s.yml

暂无

7. 基本使用

暂无

8. 经典案例

暂无

9. 服务存在的问题及其解决办法

python-gitlab
https://github.com/python-gitlab/python-gitlab
文档地址:
https://python-gitlab.readthedocs.io/en/v1.15.0/install.html

---------------- 谢谢光临 ----------------

本文标题:gitlab

文章作者:pxrux

发布时间:2020年10月18日 - 00:10

最后更新:2020年10月18日 - 00:10

原始链接:http://www.mykernel.cn/gitlab-install.html

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

0%