一、安装gitlab软件仓库
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
二、使用yum方式安装gitlab社区版
yum install curl openssh-server openssh-clients cronie policycoreutils-python git gitlab-ce -y
三、修改/etc/gitlab/gitlab.rb
external_url 'http://gitlab.yunweibang.com'
unicorn['listen'] = 'localhost'
unicorn['port'] = 30009
prometheus['enable'] = true
prometheus['listen_address'] = 'localhost:30010'
gitlab_rails['time_zone'] = 'Asia/Shanghai'
gitlab_rails['trusted_proxies'] = ['127.0.0.1']
gitlab_workhorse['enable'] = true
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:30008"
nginx['enable'] = false
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "xxxx@yunweibang.com"
gitlab_rails['smtp_password'] = "xxxxx"
gitlab_rails['smtp_domain'] = "exmail.qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = "xxxxx@yunweibang.com"
四、测试邮件是否可以正常发送
gitlab-rails console
irb(main):003:0> Notify.test_email('xxxxx@qq.com', '你好,测试一下', '我来自gitlab').deliver_now
五、使用自己的nginx,不用gitlab内置的nginx
配置文件可以参考:
https://blog.csdn.net/peterxiaoq/article/details/73330302
如果socket权限有问题,可以使用端口也ok
upstream gitlab {
server 127.0.0.1:30008;
}
Nginx、workhorse和unicorn之间的关系
六、常用命令
gitlab-ctl reconfigure 重新更新配置
gitlab-ctl restart 重启服务
gitlab-ctl tail 查看日志
七、登录页面
八、备份gitlab数据
备份命令:gitlab-rake gitlab:backup:create
会在/var/opt/gitlab/backups下生成一个带时间的tar文件
每天晚上定时备份,运行crontab -e,添加
0 1 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
注意:环境变量CRON=1的作用是如果没有任何错误发生时, 抑制备份脚本的所有进度输出
只保存最近7天的备份,编辑 /etc/gitlab/gitlab.rb 配置文件,找到gitlab_rails[‘backup_keep_time’],设置为你想要设置的值。
gitlab_rails['backup_keep_time'] = 604800
九、从备份文件中恢复gitlab,Gitlab的恢复操作会先将当前所有的数据清空,然后再根据备份数据进行恢复。
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-ctl status
查看一下unicorn和sidekiq是否已经down了,然后运行:
chmod 777 备份文件
gitlab-rake gitlab:backup:restore BACKUP=备份文件编号
比如:
gitlab-rake gitlab:backup:restore BACKUP=1539841224_2018_10_18_11.3.5.3
再次启动gitlab
gitlab-ctl restart
===完===
转载于:https://blog.51cto.com/zengestudy/2306914