Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

centos7搭建gitlab #20

Open
iralance opened this issue Jul 21, 2017 · 0 comments
Open

centos7搭建gitlab #20

iralance opened this issue Jul 21, 2017 · 0 comments

Comments

@iralance
Copy link
Owner

iralance commented Jul 21, 2017

内存建议2G以上,避免出现502的问题的问题

安装

  1. 安装配置依赖项
sudo yum install curl policycoreutils openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld

启动postfix出错解决办法

修改 /etc/postfix/main.cf的设置  
inet_protocols = ipv4  
inet_interfaces = all  

2.下载
方式1. 更新yum源
使用清华大学 TUNA 镜像源
vim /etc/yum.repos.d/gitlab-ce.repo

[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key

更新本地 YUM 缓存

sudo yum makecache

安装 GitLab 社区版

sudo yum install gitlab-ce #(自动安装最新版)
sudo yum install gitlab-ce-8.8.4-ce.0.el6 #(安装指定版本)

方式2. 手动下载安装脚本

curl -LJO  https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-9.3.8-ce.0.el7.x86_64.rpm
rpm -i gitlab-ce-9.3.8-ce.0.el7.x86_64.rpm

3.修改配置

vim /etc/gitlab/gitlab.rb
将`external_url = 'http://git.example.com'`修改为自己的IP地址:`http://xxx.xx.xxx.xx`,
# 然后执行下面的命令,对GitLab进行编译。

4.启动GitLab

sudo gitlab-ctl reconfigure

5.登录GitLab

确保防火墙http能访问80端口,用户名密码
Username: root 
Password: 5iveL!fe

第一次登陆后需要修改密码

运维

启动所有 gitlab 组件:
sudo gitlab-ctl start

停止所有 gitlab 组件:
sudo gitlab-ctl stop

重启所有 gitlab 组件:
sudo gitlab-ctl restart

查看服务状态
sudo gitlab-ctl status

启动服务
sudo gitlab-ctl reconfigure

Gitlab 创建备份

使用Gitlab一键安装包安装Gitlab非常简单, 同样的备份恢复与迁移也非常简单,用一条命令即可创建完整的Gitlab备份:

gitlab-rake gitlab:backup:create
以上命令将在/var/opt/gitlab/backups目录下创建一个名称类似为xxxxxxxx_gitlab_backup.tar的压缩包, 这个压缩包就是Gitlab整个的完整部分, 其中开头的xxxxxx是备份创建的时间戳。

Gitlab 修改备份文件默认目录

修改/etc/gitlab/gitlab.rb来修改默认存放备份文件的目录:

gitlab_rails['backup_path'] = '/mnt/backups'
修改后使用gitlab-ctl reconfigure命令重载配置文件。

备份

0 2 * * * /usr/bin/gitlab-rake gitlab:backup:create
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create
恢复

首先进入备份 gitlab 的目录,这个目录是配置文件中的 gitlab_rails['backup_path'] ,默认为 /var/opt/gitlab/backups 。

然后停止 unicorn 和 sidekiq ,保证数据库没有新的连接,不会有写数据情况。

停止相关数据连接服务
ok: down: unicorn: 0s, normally up
gitlab-ctl stop unicorn
ok: down: sidekiq: 0s, normally up
gitlab-ctl stop sidekiq

从xxxxx编号备份中恢复
然后恢复数据,1406691018为备份文件的时间戳
gitlab-rake gitlab:backup:restore BACKUP=xxxxxx

小技巧

  1. 注册发送验证邮件
    git1
    2.限制注册邮件白名单
    git5
    git3
    git4

相关链接

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant