CentOS7下源码方式安装gitlab

环境描述

操作系统: centos7

redis: >=2.8

mysql >=5.5.14

git >=2.7.4

架构设计

一台gitlab服务器 gitlab-master

一台gitlab数据备份 gitlab-backup

一台数据库主库 data-master

一台数据库从库 data-slave

升级yum源与安装依赖 ++所有的机器都需要的安装步骤++

安装mysql+redis ++数据库服务器需要的安装步骤++

data-master data-slave 安装mysql+redis

升级yum源与安装依赖

yum -y update
yum -y groupinstall "Development Tools"
yum install -y cmake python-docutils libarchive python-pillow libwebp zlib zlib-devel libyaml libyaml-devel openssl-devel openssl libffi libffi-devel curl curl-devel openssh-server libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel logrotate python-docutils perl-devel vim
reboot

++所有的机器都需要的安装步骤++


安装mysql+redis

安装数据库服务器.安装gitlab会用到.

也可以把所有的软件都安装到一台机器.

备份的时候可以把备份包上传到其他服务器上.

因为我们把mysql与redis分开分别安装到data-masterdata-slave

两台安装步骤一模一样

安装redis
rpm -i https://mirrors.tuna.tsinghua.edu.cn/epel//epel-release-latest-7.noarch.rpm
sudo yum install redis
systemctl enable redis
systemctl start redis

安装完后

需要将配置文件/etc/redis.conf

bind 127.0.0.1注释掉或者改成gitlab的ip地址

安装mysql
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server mysql-community-client
systemctl enable mysqld
systemctl start mysqld
创建gitlab需要的表结构
CREATE USER 'git'@'%' IDENTIFIED BY 'git';
CREATE USER 'git'@'localhost' IDENTIFIED BY 'git';
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'@'%';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER, LOCK TABLES, REFERENCES ON `gitlabhq_production`.* TO 'git'@'localhost';

创建完成可以gitlab服务器上

在命令行中用git账号访问mysql数据库测试是否可用

++数据库服务器需要的安装步骤++


安装mysql依赖包

rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-client mysql-community-devel

安装nodejs

rpm -i https://mirrors.tuna.tsinghua.edu.cn/epel//epel-release-latest-7.noarch.rpm
yum -y install nodejs

安装git

yum install asciidoc xmlto texinfo docbook2X perl-devel
cd /usr/bin
ln -s db2x_docbook2texi docbook2x-texi
cd /tmp
curl --remote-name --progress https://www.kernel.org/pub/software/scm/git/git-2.7.4.tar.gz
tar -xzf git-2.7.4.tar.gz
cd git-2.7.4/
./configure --with-curl=/usr/include/curl
make prefix=/usr install install-doc install-html install-info
make install

安装邮件服务器

yum install postfix
systemctl enable postfix
systemctl start postfix

安装ruby2.3

mkdir /tmp/ruby && cd /tmp/ruby
curl --remote-name --progress https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz
tar xzf ruby-2.3.1.tar.gz
cd ruby-2.3.1
./configure --disable-install-rdoc
make && make install

设置环境变量

vim /etc/bashrc
最后一行添加
export PATH="$PATH:/usr/local/bin"
关闭selinux
vim /etc/sysconfig/selinux
最后重启机器
reboot

安装 Bundler Gem:

gem install bundler --no-ri --no-rdoc

安装go语言

mkdir /tmp/go && cd /tmp/go
curl --remote-name --progress https://storage.googleapis.com/golang/go1.5.3.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.5.3.linux-amd64.tar.gz
ln -sf /usr/local/go/bin/{go,godoc,gofmt} /usr/bin

添加git账号

adduser -s /bin/false -m -d /home/git git

下载gitlab源码包

cd /home/git/gitlab
8-9目前可以汉化的最高版本
git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 8-9-stable gitlab

配置gitlab

chown -R git:git /home/git/gitlab/
cd /home/git/gitlab
切换到git账号
sudo su git
生成配置文件
cp config/gitlab.yml.example config/gitlab.yml 生成secret文件
cp config/secrets.yml.example config/secrets.yml
chmod 0600 config/secrets.yml
chown -R git log/
chown -R git tmp/
chmod -R u+rwX,go-w log/
chmod -R u+rwX tmp/
chmod -R u+rwX tmp/pids/
chmod -R u+rwX tmp/sockets/
mkdir public/uploads/
chmod 0700 public/uploads
chmod -R u+rwX builds/
生成unicorn文件
cp config/unicorn.rb.example config/unicorn.rb cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
git config --global core.autocrlf input
git config --global gc.auto 0
git config --global repack.writeBitmaps true
cp config/resque.yml.example config/resque.yml
更改redis链接地址
vim config/resque.yml
production: redis://172.16.24.127:6379 连接mysql 取消注释host 更改password为git
cp config/database.yml.mysql config/database.yml
vim config/database.yml

安装Gems

bundle config mirror.https://rubygems.org https://gems.ruby-china.org
bundle install --deployment --without development test postgres aws kerberos -V

安装GitLab Shell

bundle exec rake gitlab:shell:install REDIS_URL=redis://redis的ip地址:端口 RAILS_ENV=production SKIP_STORAGE_VALIDATION=true
确认一下redis地址正确性
vim /home/git/gitlab-shell/config.yml

安装gitlab-workhorse

cd /home/git
git clone https://gitlab.com/gitlab-org/gitlab-workhorse.git
cd gitlab-workhorse
git checkout v0.8.4
make

初始化数据库与高级功能

只需在git-master服务器上执行一次 gitlab-backup无需再次执行该命令.

cd /home/git/gitlab
bundle exec rake gitlab:setup RAILS_ENV=production
# Type 'yes' to create the database tables.
输入yes
# When done you see 'Administrator account created:'
表示初始化成功
exit

安装启动脚本

sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
sudo chkconfig gitlab on
安装logrotate
sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

检测应用状态 编译 Assets

su git
bundle exec rake gitlab:env:info RAILS_ENV=production
bundle exec rake assets:precompile RAILS_ENV=production
exit

启动GitLab

servicce gitlab start

安装nginx

sudo yum install -y nginx
sudo cp lib/support/nginx/gitlab /etc/nginx/conf.d/gitlab.conf
将端口改成8088
sudo vim /etc/nginx/nginx.conf
vim /etc/nginx/conf.d/default.conf
sudo nginx -t
更改selinux
sudo vim /etc/sysconfig/selinux sudo service nginx restart
sudo chmod 775 /home/git
vim /etc/group
git组添加nginx

最后检测

su git
bundle exec rake gitlab:check RAILS_ENV=production

备份与恢复

备份恢复
bundle exec rake gitlab:backup:create RAILS_ENV=production SKIP=uploads,db
bundle exec rake gitlab:backup:restore RAILS_ENV=production BACKUP=timestamp_of_backup

备份时候默认是备份数据库的 不需要时候添加参数SKIP=db

备份会在gitlab/tmp目录下 以时间戳为前缀生成压缩包 恢复同样需要放置在tmp目录下

恢复时候BACKUP=timestamp_of_backup timestamp_of_backup表示是时间前缀 默认恢复最新一次的备份

ldap认证

修改 config/gitlab.yml

ldap设置
enabled: true
host: '172.16.24.55'
port: 389
uid: 'cn' #需要去ldap服务器上看一下uid是什么 可能是uid 可能是cn
method: 'tls' # "tls" or "ssl" or "plain"
bind_dn: 'cn=Manager,dc=xkdx,dc=com'
password: ''
base: 'ou=People,dc=xkdx,dc=com'

发送邮件

修改 config/gitlab.yml

两种方式

一种是使用系统的postfix

一种是使用smtp服务器发送

默认是使用第一种配置比较简单

先说明第一种方式的配置

首先

echo "Test mail from postfix" | mail -s "Test Postfix" bravelib@163.com

然后查看邮件的发件人需要用到 我这边的是root@xkdx.cn

接着 修改 config/gitlab.yml

## Email settings
# Uncomment and set to false if you need to disable email sending from GitLab (default: true)
email_enabled: true
# Email address used in the "From" field in mails sent by GitLab
email_from: root@xkdx.cn #上边163邮箱收到的邮件的发件人地址
email_display_name: GitLabMaster #显示的收件人昵称
email_reply_to:

怎么测试我们配置的内容成功了呢

每次修改配置文件需要重启gitlab程序

service gitlab restart

监控日志文件

tail -f /home/git/gitlab/log/*.log

tail -f /var/log/maillog

然后测试我们的配置

bundle exec rails console production
查看发邮件的方法有sendmail 与smtp(第二种方法)
irb(main):016:0* ActionMailer::Base.delivery_method
=> :sendmail
显示邮件配置
irb(main):017:0> ActionMailer::Base.smtp_settings
=> {:address=>"localhost", :port=>25, :domain=>"localhost.localdomain", :user_name=>nil, :password=>nil, :authentication=>nil, :enable_starttls_auto=>true}
给自己邮箱发送测试文件
irb(main):018:0> Notify.test_email('bravelib@163.com', 'Hello World', 'This is a test message').deliver_now

第二种方式smtp邮件服务器发送

首先修改gitlab.yml的email_from

然后修改

/home/git/gitlab/config/environments/production.rb

config.action_mailer.delivery_method = :sendmail

改成smtp

config.action_mailer.delivery_method = :smtp

最后

cp /home/git/gitlab/config/initializers/smtp_settings.rb.sample /home/git/gitlab/config/initializers/smtp_settings.rb

这个也可用上边的测试方法测试

发邮件时候遇到的问题

很多时候日志只显示已插入到队列 但是邮件收不到

最后终于发现了一个管理页面

http://ip/admin/sidekiq

能显示任务队列的情况

虽然有时候也有邮件发送不成功 至少能看到结果与失败结果了

参考资料

https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md

http://docs.gitlab.com/ce/administration/troubleshooting/debug.html

http://wiki.jikexueyuan.com/project/rails-practice/Chapter_6/6.3.html

centos7下源码方式安装gitlab8.9+发送邮件+ldap的更多相关文章

  1. inux centos7下源码 tar安装5.7.26详解

    inux centos7下源码 tar安装5.7.26图文详解 官网地址 https://dev.mysql.com/downloads/mysql/ 1.卸载Linux系统上自带的mysql插件(o ...

  2. Centos6 系统下源码方式安装Mysql 记录

    在运维工作中经常部署各种运维环境,涉及mysql数据库的安装也是时常需要的.mysql数据库安装可以选择yum在线安装,但是这种安装的mysql一般是系统自带的,版本方面可能跟需求不太匹配. #### ...

  3. Centos7下源码编译安装python3.6

    测试环境: 操作步骤: 1. 下载Python源码包(python3.6.0) 官网下载地址:https://www.python.org/downloads/ 搜狐下载地址:http://mirro ...

  4. Centos7下源码编译安装与配置redis5.0

    1.下载redis5.0源码包 wget http://download.redis.io/releases/redis-5.0.5.tar.gz 2.检查是否安装过之前的历史版本 rpm -qa|g ...

  5. linux centos7下源码 tar安装mysql5.7.23(5.7以上均可试用)

    1.工具:mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz.centos7 2.解压后,将mysql-5.7.22-linux-glibc2.12-x86_64里面 ...

  6. ubuntu下源码方式安装php5.4

    一.安装前准备 下载php-5.4.13.tar.gz最新版本放到/user/src目录下 二.安装 因为在安装php过程中,会依赖安装很多库,为了不让你反复安装,建议按步骤操作 安装autoconf ...

  7. linux centos7下源码 tar安装mysql5.7.22或mysql5.7.20 图文详解

    之前用的rpm安装的每次安装都是最新的,,,导致每次版本不统一... 现在用tar包安装5.7.22和5.7.20一样的   5.7.20之后的和之前的版本还是有点不一样的 官网地址 https:// ...

  8. Centos7.X 源码编译安装subversion svn1.8.x

    说明:SVN(subversion)的运行方式有两种:一种是基于Apache的http.https网页访问形式:还有一种是基于svnserve的独立服务器模式.SVN的数据存储方式也有两种:一种是在B ...

  9. 源码方式安装 lrzsz 库

    我们都知道安装了lrzsz工具的linux系统环境: 在shell里可以非常方便的上传和下载linux里面的文件: 通常的安装方式: yum install lrzsz sudo apt-get in ...

随机推荐

  1. vue组件的一个总结

    用vue进行开发到目前为止也有将近一年的时间了,在项目技术选型的时候隔壁组选 react的时候我们坚持使用vue作为前端的开发框架.虽然两者思想上的差异不大,但是vue的语法在代码的可读性以及后期的维 ...

  2. HDU1573 X问题【一元线性同余方程组】

    题目链接: http://acm.hdu.edu.cn/showproblem.php? pid=1573 题目大意: 求在小于等于N的正整数中有多少个X满足:X mod a[0] = b[0], X ...

  3. poj--2031--Building a Space Station(prime)

    Building a Space Station Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6635   Accepte ...

  4. 认证与授权协议对比:OAuth2、OpenID、SMAL

    认证授权是目前大多数系统都必须要实现都功能,认证就是验证用户都身份,授权就是验证身份后对受限资源的访问控制.最开始是单个平台要做,后来在互联网时代到来,一个账户可登陆多个平台,然后是各种开放平台账户共 ...

  5. PCB MVC启动顺序与各层之间数据传递对象关系

    准备着手基于MVC模式写一套Web端流程指示查看,先着手开发WebAPI打通数据接口,后续可扩展手机端 这里将MVC基本关系整理如下: 一.MVC启动顺序 二.MVC各层之间数据传递对象关系

  6. sdut1269 走迷宫(dfs)

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1269 连着做了三个基本的dfs,终于弄懂了搜索 ...

  7. scws

    SCWS 是 Simple Chinese Word Segmentation 的首字母缩写(即:简易中文分词系统). 这是一套基于词频词典的机械式中文分词引擎,它能将一整段的中文文本基本正确地切分成 ...

  8. mysql 年龄计算(根据生日字段)

    mysql 年龄计算(根据生日字段) year( from_days( datediff( now( ), birthdate))) //获取年龄 now() 当前时间,精确到秒 datediff(b ...

  9. windows系统下nodejs安装、环境配置及删除NPM全局配置

    nodejs安装及设置NPM全局路径 删除NPM全局路径配置 一.nodejs安装及设置NPM全局路径 第一步:下载安装文件 下载nodejs,官网:http://nodejs.org/downloa ...

  10. CVTE面经

    神一般的面试经历.也算面了不少公司,没见过这种面试. 一面:三个同学对应一个面试官,同一个问题依次作答. 1.为什么投递这个岗位? 答:blablabla... 2.最难忘的成功项目? 答:blabl ...