gitlab
https://about.gitlab.com/downloads/#centos6

yum install curl openssh-server postfix cronie
service postfix start
chkconfig postfix on
lokkit -s http -s ssh
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-8.9.8-ce.0.el6.x86_64.rpm
rpm -i gitlab-ce-XXX.rpm
gitlab-ctl reconfigure


默认账号
Username: root
Password: 5iveL!fe


gitlab + ldap

在/etc/gitlab/gitlab.rb 追加ldap配置 
# For omnibus packages
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-EOS # remember to close this block with 'EOS' below
main: # 'main' is the GitLab 'provider ID' of this LDAP server
  label: 'LDAP'
  host: 'ldap_server_IP'
  port: 389
  uid: 'uid'
  method: 'plain' # "tls" or "ssl" or "plain"
  allow_username_or_email_login: true
  bind_dn: 'cn=xxx,dc=xxx,dc=com'
  password: 'PASSWPRD'
  active_directory: false
  base: 'ou=xxx,dc=xxx,dc=com'
  user_filter: ''
EOS
使配置生效

#gitlab-ctl reconfigure
至此gitlab 安装集成ldap完成


ldap登陆报错日志位置 /var/log/gitlab/gitlab-rails/production.log

gitlab服务启动关闭及重启

gitlab-ctl start|stop|restart
需要注意的是修改过/etc/gitlab/gitlab.rb 后 需要执行 

#gitlab-ctl reconfigure
ps 这个命令会执行chef将/etc/gitlab/gitlab.rb添加的参数加入 /var/opt/gitlab/gitlab-rails/etc/gitlab.yml

---------------------------

Gitlab 汉化及维护

由于服务对象是广大师生,为了降低新手上手的难度,所有进行汉化也是非常有必要的。好在国内有人已经进行了这方面的工作,我们
只需要共享其成果即可(欢迎向原项目提交高质量翻译)。

首先确认版本:

sudo cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
并确认当前汉化版本的 VERSION 是否相同,当前最新的汉化版本为 8.6 。
如果安装版本小于当前汉化版本,请先升级。如果安装版本大于当前汉化版本,请在本项目中提交新的 issue。
如果版本相同,首先在本地 clone 仓库。

# GitLab.com 仓库
git clone https://gitlab.com/larryli/gitlab.git

# 或 Coding.net 镜像
git clone https://git.coding.net/larryli/gitlab.git
根据我的测试, Coding.net 的镜像不完整,clone 之后无法 checkout
然后比较汉化分支和原分支,导出 patch 用的 diff 文件。

# 8.1 版本的汉化补丁
git diff origin/8-6-stable..8-6-zh > ../8.6.diff
然后上传 8.6.diff 文件到服务器。

# 停止 gitlab
sudo gitlab-ctl stop
sudo patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < 8.6.diff
确定没有 .rej 文件,重启 GitLab 即可。

sudo gitlab-ctl start
如果汉化中出现问题,请重新安装 GitLab(注意备份数据)。

Gitlab 运维

管理
sudo gitlab-ctl start   # 启动所有 gitlab 组件
sudo gitlab-ctl stop   # 停止所有 gitlab 组件
sudo gitlab-ctl restart  # 重启所有 gitlab 组件
备份

备份GitLab repositories and GitLab metadata
在 crontab 中加入如下命令:

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

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

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

sudo gitlab-ctl stop unicorn
# ok: down: unicorn: 0s, normally up
sudo gitlab-ctl stop sidekiq
# ok: down: sidekiq: 0s, normally up
然后恢复数据,1406691018为备份文件的时间戳

gitlab-rake gitlab:backup:restore BACKUP=1406691018
修改数据存储地址

默认情况下,gitlab 将数据存储在/var/opt/gitlab/git-data目录下,受限于分区情况&方便管理,我们需要将数据迁移到别的目录下。

无需数据迁移
如果还没有投入使用,则可以直接在配置文件中添加:

git_data_dir "/path/to/git-data"
然后执行:

sudo gitlab-ctl reconfigure
就可以生效了。

进行数据迁移
如果已经有数据了,则需要进行迁移。

首先需要暂停服务,避免用户在迁移期间读写数据:

sudo gitlab-ctl stop
然后使用rsync数据进行迁移:

注意前一个地址不需要/,后一个地址需要/,且只需要迁移repositories目录即可
sudo rsync -av /var/opt/gitlab/git-data/repositories /path/to/git-data/
然后运行配置工具以更新并重启服务:

官网文档是先更新配置再启动服务,但我在使用中发现先更新配置会提示无法连接上服务器,出现这种问题时可以先启动服务再更新配置。
sudo gitlab-ctl reconfigure
sudo gitlab-ctl start
最后不要忘了在网页端确认数据的地址是否正确。

关于权限问题
在使用中,我一开始创建了一个gitlabhq用户并创建了一个文件夹,然后修改地址,服务正常启动后提示500。
后来使用root账户在/home下直接创建文件夹解决了这个问题。
如果有遇到类似问题的,可以尝试用root创建目录。
监听IPv6

教育网拥有得天独厚的IPv6资源,所以为我们的gitlab服务添加IPv6支持很有必要。

修改/etc/gitlab/gitlab.rb文件中的:

# nginx['listen_addresses'] = ['*']
为

nginx['listen_addresses'] = ['*', '[::]']
然后执行

sudo gitlab-ctl reconfigure
然后就可以通过IPv6访问了。

results matching ""

    No results matching ""