Chinaunix首页 | 论坛 | 博客
  • 博客访问: 161815
  • 博文数量: 51
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 471
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-11 10:24
文章分类

全部博文(51)

文章存档

2018年(3)

2017年(22)

2016年(9)

2015年(17)

我的朋友

分类: 系统运维

2015-05-27 15:06:34

gitlab安装

参考

1、环境依赖
git version>1.7.10
ruby version>1.9
MySQL version >5.5.14 
redis 
nginx

机器需要外网

2、安装
2.1、安装git
yum install git
git --version查看版本号
git version 1.8.2.1 
2.2、安装ruby
该机器需要有外网
mkdir /opt/apps && cd /opt/apps
curl -L --progress  | tar xz
cd ruby-2.1.5
./configure --disable-install-rdoc
make
sudo make install
安装gem
gem install bundler --no-ri --no-rdoc

2.3、安装mysql

mysql --version

可以找相应的rpm包安装,确保版本大于5.5.14
2.4、安装redis
yum install redis
useradd -s /sbin/nologin -M redis
2.5、安装nginx
yum install nginx

2.6、数据库相应操作
mysql操作
mysql设置密码(sohutest)
mysql -uroot -p

>CREATE USER 'git'@'localhost' IDENTIFIED BY '$password';
>SET storage_engine=INNODB;
>CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON `gitlabhq_production`.* TO 'git'@'localhost';
>quit
测试连通性
mysql -u git -p -D gitlabhq_production

redis操作
mkdir /var/run/redis
chown redis:redis /var/run/redis
chmod 755 /var/run/redis
启动redis

2.7、安装gitlab
git clone  -b 7-6-stable gitlab

cd /opt/git/gitlab
cp config/gitlab.yml.example config/gitlab.yml

chown -R git log/
chown -R git tmp/
chmod -R u+rwX,go-w log/
chmod -R u+rwX tmp/

mkdir /home/git/gitlab-satellites
chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites

chmod -R u+rwX tmp/pids/
chmod -R u+rwX tmp/sockets/
cp config/unicorn.rb.example config/unicorn.rb
cp config/initializers/rack_attack.rb.example
cp config/initializers/rack_attack.rb

cp config/resque.yml.example config/resque.yml
修改unicorn.rb、resque.yml
具体参数参考官网推荐

配置gitlab DB的设置
git cp config/database.yml.mysql config/database.yml
修改database.yml为自己的参数
bundle install --deployment --without development test postgres aws
安装gitlab shell
bundle exec rake gitlab:shell:install[v2.4.1] REDIS_URL= RAILS_ENV=production

初始化数据库
bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=yourpassword

使gitlab为本地服务
cp lib/support/init.d/gitlab /etc/init.d/gitlab
cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

检查应用环境
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
bundle exec rake assets:precompile RAILS_ENV=production
启动 gitlab服务
/etc/init.d/gitlab restart

配置nginx
复制lib/support/nginx/gitlab的vhost下
启动nginx
servier nginx restart


2.8、检查所有配置状态
bundle exec rake gitlab:check RAILS_ENV=production
2.9、默认密码,登陆
root
5iveL!fe

3、gitlab添加ldap
host: ''
port: 389
uid: 'sAMAccountName'
method: 'plain' # "tls" or "ssl" or "plain"
bind_dn: 'xxx@'
password: 'xxx'
base: 'dc=sohu-inc,dc=com'

Notes:

1、ruby gem源使用淘宝的

gem sources --remove 
gem sources -a 
gem sources -l

2、连接ldap,base域用

3、root用户权限root/sohutest

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

gitlab的流程分析

1、gitlab的角色权限

主要权限

guest 创建issue、写评论
reporter 增加下载代码
developer 发出merge请求,创建分支,推送代码,打tag,管理标签
master 添加team成员,push代码到保护分支,开启和禁用分支保护,修改移除tag,创建、修改项目
owner 移除项目

2、gitlab创建项目是指定组,默认组内成员是可以看到项目的,组外看不到项目。

加入组内的
guest 没有看代码的权限

reporter 有下载和看代码的权限 可以fork一份代码了

fork后的仓库只有用户自己有权限,登陆root后在fork用户的仓库添加运维人员为master

3、通过控制项目数量,控制项目创建 ,具体修改/opt/git/gitlab/config/gitlab.yml 中default_projects_limit: 0参数

阅读(1450) | 评论(0) | 转发(0) |
0

上一篇:git 使用简介

下一篇:redis配置优化

给主人留下些什么吧!~~