gitlab服务器搭建教程

----2016年终总结 三
大量参考以上两篇文档,整理并实际操作的总结

目录:

1.原料

2.基础环境

3.数据库安装

4.Gitlab相关安装

5.恢复及备份

1 原料

CentOS 6 kvm虚拟机一台

root用户权限

2 基础环境

以root用户登陆

2.1 更新epel源

wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://mirrors.tuna.tsinghua.edu.cn/epel/RPM-GPG-KEY-EPEL-6
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
rpm -Uvh http://mirrors.ustc.edu.cn/epel/epel-release-latest-6.noarch.rpm

2.2 更新epel源

yum groupinstall "Development tools"
yum install libicu-devel cmake nodejs

2.3 git

要求版本:git >=2.7.4

yum install git

2.4 ruby环境

要求版本:ruby >=2.1

yum remove ruby
mkdir /tmp/ruby && cd /tmp/ruby
curl -O --progress http://mirrors.ustc.edu.cn/ruby/2.1/ruby-2.1.6.tar.gz
tar xzf ruby-2.1.8.tar.gz cd ruby-2.1.8
./configure
make && make install
gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
gem install bundler --no-ri
sudo -u git -H bundle config mirror.https://rubygems.org https://gems.ruby-china.org/

2.5 go

要求版本:未知

mkdir /tmp/go && cd /tmp/go
curl -O --progress http://www.golangtc.com/static/go/1.6/go1.6.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.6.linux-amd64.tar.gz
sudo ln -sf /usr/local/go/bin/{go,godoc,gofmt} /usr/local/bin/
go version

2.6 用户

adduser -c 'Gitlab' -s /bin/bash git
vim /etc/sudoers #添加git用户添加sudo权限,添加免密sudo
groupadd redis && useradd -g redis redis -s /sbin/nologin #添加redis用户
sudo usermod -aG redis git #git用户添加到redis组

3 数据库安装

3.1 MySQL

这里使用MySQL数据库。

要求版本:MySQL >= 5.5.14

3.1.1 安装
rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm
yum install mysql mysql-server
service mysqld start
3.1.2 初始化

连接数据库,执行:

CREATE USER 'git'@'localhost' IDENTIFIED BY '$password'; #新建密码
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER, LOCK TABLES, REFERENCES ON `gitlabhq_production`.* TO 'git'@'localhost';
quit;
echo 'max_allowed_packet=500M' >> /etc/my.cnf
service mysqld restart

3.2 Redis

要求版本:Redis >=2.8

3.2.1 安装
mkdir /tmp/redis && cd /tmp/redis
curl -O --progress http://download.redis.io/releases/redis-3.2.5.tar.gz
tar xzf redis-3.2.5.tar.gz
cd redis-3.2.5
make
cd src
make install
mkdir -p /etc/redis
cp redis.conf /etc/redis
3.1.2 初始化
cp /etc/redis/redis.conf /etc/redis/redis.conf.orig
sed 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf
echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis/redis.conf
sed -i 's/daemonize no/daemonize yes/g' /etc/redis/redis.conf
mkdir /var/run/redis
sudo chown redis:redis /var/run/redis
sudo chmod 755 /var/run/redis
if [ -d /etc/tmpfiles.d ]; then
echo 'd /var/run/redis 0755 redis redis 10d -' | sudo tee -a /etc/tmpfiles.d/redis.conf
fi
curl -L http://packages.gitlab.cc/install/init-script/redis/cenots6/redis-server -o /etc/init.d/redis-server
chmod +x /etc/init.d/redis-server
service redis-server start
chkconfig redis-server on

4 Gitlab相关安装

4.1 Gitlab-CE

要求版本-无

选择版本-8.9.6

su - git
cd /home/git/
sudo -u git -H git clone https://git.oschina.net/qiai365/gitlab-ce.git -b 8-9-stable gitlab
cd /home/git/gitlab/
git checkout v8.9.6
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
sudo -u git -H vim config/gitlab.yml #修改host配置项为本机IP
sudo -u git -H vim config/secrets.yml
sudo -u git -H chmod 0600 config/secrets.yml
sudo chown -R git log/
sudo chown -R git tmp/
sudo chmod -R u+rwX,go-w log/
sudo chmod -R u+rwX tmp/
sudo chmod -R u+rwX tmp/pids/
sudo chmod -R u+rwX tmp/sockets/
sudo -u git -H mkdir public/uploads/
sudo chmod 0700 public/uploads
sudo chmod -R u+rwX builds/
sudo chmod -R u+rwX shared/artifacts/
sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
sudo -u git -H vim config/unicorn.rb #修改worker数量为cpu核心数
sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
sudo -u git -H git config --global core.autocrlf input
sudo -u git -H git config --global gc.auto 0
sudo -u git -H cp config/resque.yml.example config/resque.yml #如果redis的sock在其它位置,则修改
sudo -u git cp config/database.yml.mysql config/database.yml
sudo -u git -H vim config/database.yml #修改production环境的socket为mysql的sock文件,通常在/var/lib/mysql/mysql.sock。确认MySQL的用户、密码、库名等配置
sudo -u git -H chmod o-rwx config/database.yml

4.2 Gems

sudo -u git -H bundle install --deployment --without development test postgres aws kerberos -jn #n为cpu数目 提升安装速度
#如果前面严格按照步骤执行,通常是不会遇到问题的。如果有异常自行排查~~

4.3 Gitlab-shell

sudo -u git -H sed -i 's/https:\/\/gitlab.com\/gitlab-org\/gitlab-shell.git/https:\/\/git.oschina.net\/qiai365\/gitlab-shell.git/g' /home/git/gitlab/lib/tasks/gitlab/shell.rake
sudo -u git -H bundle exec rake gitlab:shell:install REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production #如果安装成功,会有一系列ok提示
sudo -u git -H vim /home/git/gitlab-shell/config.yml #确认一下配置

4.4 Gitlab-workhorse

要求版本-无

选择版本-0.7.5

cd /home/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-workhorse.git
cd gitlab-workhorse
sudo -u git -H git checkout v0.7.5
sudo -u git -H make

4.5 Gitlab初始化数据库

cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production #中途需要输入yes

4.6 安装Gitlab执行脚本

sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
sudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
chkconfig gitlab on #设置gitlab开机启动 推荐

4.7 安装logrotate

sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

4.8 检查环境配置

sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production

4.9 生成Gitlab前端资源

sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production

4.10 安装、配置Nginx

sudo yum install nginx
sudo vim /etc/nginx/nginx.conf #配置80端口到8080端口到proxy_pass
sudo service nginx restart

4.11 启动gitlab

sudo service gitlab start

4.12 最后确认

sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
#根据上述命令产生的检查结果和推荐命令,执行并再次检查

5 恢复及备份

5.1 在备份机上恢复备份

su - git
cd /home/git/gitlab
sudo -u git -H vim config/gitlab.yml #确认backup path配置,确保备份的包在该目录下存在、或移动至该位置。备份的包为$时间戳_gitlab_backup.tar
sudo -u git -H vim config/secrets.yml
sudo vim /etc/my.cnf #确保该配置文件添加了 max_allowed_packet=500M 配置
sudo -u git -H bundle exec rake gitlab:backup:restore BACKUP=$时间戳 RAILS_ENV=production #执行恢复备份 中途需要输入yes确认
 

gitlab服务器搭建教程的更多相关文章

  1. ubuntu gitlab服务器搭建

    gitlab服务器搭建 1.安装依赖包 sudo apt-get install curl openssh-server ca-certificates postfix 执行完成后,出现邮件配置,选择 ...

  2. gitLab服务器搭建+ rundeck自动化部署

    git服务器搭建 https://blog.csdn.net/gx_1_11_real/article/details/79406427 rundeck   部署 https://blog.csdn. ...

  3. 8.gitlab服务器搭建(基于centos7)

    gitlab服务硬件要求 建议服务器最低配置:2核 2G以上内存(不包含2GB,2GB内存运行的时候内存直接爆掉) 官网给出的推荐配置:4核 4GB内存 支持500个用户,8核 8GB内存 支持100 ...

  4. GitLab服务器搭建及配置

    一.服务器环境 操作系统:CentOS release 6.5 (Final) GitLab版本: GitLab-shell:2.0.1 Ruby version: ruby 2.1.2p95 (20 ...

  5. linux下FTP服务器搭建教程1

    你买了个主机就像是买了块地皮,搭建FTP就像是盖房子,我在地皮上建房子,然后创建的用户就像是钥匙,我给谁钥匙(权限),谁就可以到我家去玩,去放东西,拿东西. 虽然我们买不起现实的房子,但是我们可以买互 ...

  6. gitlab服务器搭建

    当然喜欢英文的可以参考官方文档:https://about.gitlab.com/downloads/ 1.  根据自己的操作系统选择相应的安装方法,我这边是阿里云 centos 7的 sudo yu ...

  7. SVN服务器搭建教程

    常见的源代码管理工具 CVS 历史悠久,现在几乎没人使用 SVN 集中式版本控制的代表 CVS的接班人,速度比CVS快,功能比CVS强大 在国内使用率非常高(70%~90%) GIT 分布式源代码管理 ...

  8. Gitlab 服务器搭建

    一.官网地址 首页:https://about.gitlab.com/ 安装说明:https://about.gitlab.com/installation/ 二.安装命令摘录 实际问题:yum 安装 ...

  9. Gitlab服务器搭建(For fedora23)

    1. Install and configure the necessary dependencies sudo yum install curl policycoreutils openssh-se ...

随机推荐

  1. 自制ACL+DHCP实验(初版)

    (实验用gns模拟器) ACL 实验拓扑: 实验要求: 1.1.1.1→3.3.3.3 不通 11.11.11.11→3.3.3.3 通 2.2.2.2→3.3.3.3 通 实验步骤: 步骤一:基本配 ...

  2. 201521123091 《Java程序设计》第8周学习总结

    Java 第八周总结 第八周的作业. 目录 1.本章学习总结 2.Java Q&A 3.码云上代码提交记录及PTA实验总结 1.本章学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结集 ...

  3. 201521123018 《Java程序设计》第2周学习总结

    1. 本章学习总结 * String类 * Java数组Array的使用 2. 书面作业 Q1.(1) 使用Eclipse关联jdk源代码,并查看String对象的源代码(截图)? (2)分析Stri ...

  4. 201521123072《java程序设计》第十周学习总结

    201521123072<java程序设计>第十周学习总结 1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常与多线程相关内容. 2. 书面作业 本次PTA作业题集异 ...

  5. Java第十三周总结

    1. 本周学习总结 以你喜欢的方式(思维导图.OneNote或其他)归纳总结多网络相关内容. 2. 书面作业 1. 网络基础 1.1 比较ping www.baidu.com与ping cec.jmu ...

  6. 201521123009 《Java程序设计》第12周学习总结

    1. 本周学习总结 2. 书面作业 Q1:将Student对象(属性:int id, String name,int age,double grade)写入文件student.data.从文件读出显示 ...

  7. 201521123008《Java程序设计》第十三周学习总结

    1. 本周学习总结 2. 书面作业 1. 网络基础 1.1 比较ping www.baidu.com与ping cec.jmu.edu.cn,分析返回结果有何不同?为什么会有这样的不同? ping w ...

  8. PowerShell脚本—停止占用8080端口的进程

    $str = netstat -ano $list = $str.Split('\n') ; $i -lt $list.Length; $i++) { $item_list = [System.Tex ...

  9. C#参数详解

    参数 可选参数与命名参数 设计方法时,我们可以为部分参数设置默认值,在方法调用时就可以不提供该参数,使用其默认值.此外,调用方法时可以通过指定参数名的方式来传递参数.话不多说,请看以下示例: stat ...

  10. iOS开发之UITableView中计时器的几种实现方式(NSTimer、DispatchSource、CADisplayLink)

    最近工作比较忙,但是还是出来更新博客了.今天博客中所涉及的内容并不复杂,都是一些平时常见的一些问题,通过这篇博客算是对UITableView中使用定时器的几种方式进行总结.本篇博客会给出在TableV ...