Centos 部署gitlab
- 更新系统和安装依赖
yum -y install curl vim policycoreutils python3-policycoreutils
安装邮件和允许自启动
yum -y install postfix
Systemctl enable postfix && systemctl start postfix
- 添加gitlab ce 源
curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash
yum install gitlab-ce #安装gitlab-ce
- gitlab配置和更改root密码
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION # 查看版本号
修改配置 vim /etc/gitlab/gitlab.rb
改为 external_url ‘http://ip’
修改完成后报存退出执行 gitlab-ctl reconfigure
- 常用命令集合
启动 gitlab-ctl start
查看状态 gitlab-ctl status
停止 gitlab-ctl stop
重启 gitlab-ctl restart
- 设置用户密码
gitlab-rails console -e porduction
User = User.where(id:1).first
User.password = ‘12345678’
User.password_confirmation = ‘12345678’
User.save!
- 服务器重启gitlab服务启动不了
执行 systemctl -t target 如果系统正常的话,所有任务应该是loaded active active,如果存在inactive dead选型,意味着有些服务出错了。
执行 systemctl list-jobs 如果存在某个任务是running,则是该任务堵塞了其他所有服务。
此时就可以利用 systemctl stop 服务名 停止该服务,重启gitlab即可
- Gitlab备份
备份时需要保持gitlab处于正常运行状态,直接执行gitlab-rake gitlab:backup:create进行备份
默认会备份到/var/opt/gitlab/backups 目录下
可以通过/etc/gitlab/gitlab.rb配置文件来修改默认存放备份文件的目录gitlab_rails['backup_path'] ="/var/opt/gitlab/backups"
gitlab_rails['backup_keep_time'] = 604800
#以秒为单位 备份过期时间
添加到任务计划每天备份crontab -e
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create