centos7 gitlab服务器搭建

下载Github安装包(选择社区版本)

清华大学开源软件镜像站:

https://mirrors.tuna.tsinghua.edu.cn/

示例采用 gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm

配置依赖步骤

1)  安装防火墙

yum install firewalld systemd -y

2)  开启防火墙

service firewalld  start

3)  安装SSH协议

yum install -y curl policycoreutils-python openssh-server

4)  设置SSH服务开机自启动

systemctl enable sshd

5)  启动SSH服务

systemctl start sshd

6)  添加HTTP和HTTPS服务到firewalld

firewall-cmd --permanent --add-service=http

firewall-cmd --permanent --add-service=https

7)  重启防火墙

systemctl reload firewalld

8)  安装Postfix以发送通知邮件

yum install postfix

9)  将postfix服务设置成开机自启动

systemctl enable postfix

10) 启动postfix

systemctl start postfix

11) 安装vim编辑器

yum install vim -y

安装GitLab

1)  安装rpm包

rpm -ivh gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm

 

2)  修改配置文件

#编辑配置文件

vim  /etc/gitlab/gitlab.rb

#修改访问URL

#格式:external_url 'http://ip:端口'

external_url 'http://127.0.0.1:80'

#配置时区

gitlab_rails['time_zone'] = 'Asia/Shanghai'

#配置仓库地址

git_data_dirs({

   "default" => {

     "path" => "/data/git-data"

    }

})

#配置仓库备份地址

gitlab_rails['backup_path'] = "/data/gitlab/backups"

#配置仓库备份自动删除时间2天

gitlab_rails['backup_keep_time'] = 172800

 

3)  开放防火墙端口

# 开放80端口

firewall-cmd --zone=public --add-port=80/tcp --permanent 

# 重启防火墙

firewall-cmd --reload

# 验证防火墙端口

firewall-cmd --query-port=80/tcp

4)  重置Gitlab配置

gitlab-ctl reconfigure

5)  启动Gitlab

gitlab-ctl restart

 

gitlab 数据备份

方案一

远程NAS文件服务器或者 win共享文件夹

将文件地址挂载到gitlab服务器安装服务器 地址自己设置

通过linux 定时任务方式

命令 crontab -e 

# create gitlab backups
0 1 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create
# copy gitlab backups to data1
0 2 * * * find /data/gitlab/backups/ -mtime -1 -name "*_gitlab_backup.tar" | xargs cp -t /data1

# 删除备份文件个数保留历史2天的记录
0 2 * * * find /data1 -mtime 2 -name "*_gitlab_backup.tar" | xargs rm -rf

命令 service crond restart

 

常用命令

# 更新配置

gitlab-ctl reconfigure

# 启动gitlab

gitlab-ctl start 或者 gitlab-ctl restart

# 关闭gitlab

gitlab-ctl stop

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值