一、安装Gitlab
1、选择适合的版本:mirrors.tuna.tsinghua.edu.cn/gitlab-ce/y…
2、下载
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-14.6.0-ce.0.el7.x86_64.rpm
3、安装
rpm -i gitlab-ce-14.6.0-ce.0.el7.x86_64.rpm
安装的时候如果出现异常
警告:gitlab-ce-14.6.0-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
错误:依赖检测失败:
policycoreutils-python 被 gitlab-ce-14.6.0-ce.0.el7.x86_64 需要
缺少安装服务,运行下面的命令再安装:
yum install policycoreutils-python -y
- 修改IP端口
vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.181.115:6789'
git_data_dirs({
"default" => {
"path" => "/data"
}
})
修改gitlab默认存放地址
4、重置Gitlab
gitlab-ctl reconfigure
提示密码存放位置
5、默认重置后就会启动
gitlab-ctl start
二、gitlab 修改默认的仓库存储目录及数据迁移
Gitlab默然安装时,默认的仓库存储路径在 /var/opt/gitlab/git-data目录下,仓库存储在子目录repositories里面,可以通过修改/etc/gitlab/gitlab.rb文件中git_data_dirs参数来自定义父目录
自定义git仓库的存储路径并使其生效
注:/data/gitlab/git-data 是我新创建的存储目录,目标路径及其子路径不能为软连接
在没有数据的情况下
gitlab-ctl stop (停止GitLab服务,防止用户写入数据)
gitlab-ctl reconfigure (使其修改配置生效)
如果默认存储路劲下/var/opt/gitlab/git-data 目录下已经存在仓库数据下进行数据迁移
gitlab-ctl stop (数据迁移前,停止服务,防止用户写入数据)
rsync -av /var/opt/gitlab/git-data/repositories /data/gitlab/git-data/ (执行仓库数据迁移,正常情况应该有下面这个子目录)
gitlab-ctl reconfigure ( 使其配置生效)
gitlab-ctl start(开启服务,验证一下是否能通过web访问)
GitLab常用命令
命令 | 用途 |
---|---|
gitlab-ctl status | 查看gitlab组件状态 |
gitlab-ctl start | 启动全部服务 |
gitlab-ctl restart | 重启全部服务 |
gitlab-ctl stop | 停止全部服务 |
gitlab-ctl reconfigure | 使配置文件生效(一般修改完/etc/gitlab/gitlab.rb,需要执行此命令) |
gitlab-ctl show-config | 验证配置文件 |
gitlab-ctl uninstall | 删除gitlab(保留数据) |
gitlab-ctl cleanse | 删除所有数据,从新开始 |
gitlab-ctl tail | 查看服务的日志 |