天天看点

gitlab搭建

安装基础包

     yum -y install curl policycoreutils openssh-server openssh-clients

启动sshd

systemctl enable sshd

systemctl start sshd

安装postfix

yum -y install postfix

systemctl enable postfix

systemctl start postfix

添加防火墙规则

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

systemctl reload firewalld

下载并安装软件包(软件包下载较慢)

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

yum install gitlab-ce

默认安装的是最新的gitlab-ce的包,如果需要特定的版本可以在官网去下载特定的版本 

地址:https://packages.gitlab.com/gitlab/gitlab-ce/

配置并启动gitlab

gitlab-ctl reconfigure

(执行上面的命令会报错

gitlab-ctl reconfigure 报错解决方法

gitlab搭建

解决方法:

是因为/etc/gitlab/gitlab.rb文件中的内容是:

external_url 'hostname'

将其修改为:

external_url='hostname'

即可,只需要在原来的配置项中添加个 ‘=’ 即可,为了避免域名引起的问题,也可以直接配置ip,如下所示:

external_url='192.168.1.49'。

默认账户密码是

Username: root

Password: 5iveL!fe

备份命令

gitlab-rake gitlab:backup:create

默认的备份目录为: /var/opt/gitlab/backups

备份文件名类似: 1393513186_gitlab_backup.tar 

备份目录的修改

vi /etc/gitlab/gitlab.rb

gitlab_rails['backup_path'] = '/mnt/gitlab_backups'

提示:gitlab数据的恢复或者迁移成功的前提——两台服务器的gitlab的版本必须相同,若不相同则可能迁移或者恢复失败

将备份文件放在gitlab的默认备份目录

比如/var/opt/gitlab/backups下的1458217074_gitlab_backup.tar

恢复或者还原

停服务

gitlab-ctl stop unicorn

gitlab-ctl stop sidekiq

恢复数据

gitlab-rake gitlab:backup:restore BACKUP=1458213020

BACKUP后面跟的是备份文件的时间戳,比如恢复备份文件1458217074_gitlab_backup.tar

gitlab-rake gitlab:backup:restore BACKUP=1458217074

回复完启动服务

gitlab-ctl start