设为首页 收藏本站
查看: 669|回复: 0

[经验分享] Gitlab完整安装部署文档20160526-www

[复制链接]

尚未签到

发表于 2018-9-19 09:43:34 | 显示全部楼层 |阅读模式
  转载地址:http://www.zhangluya.com/?p=193
  Gitlab完整安装部署文档20160526
  1:基础环境说明:
  System: CentOS_6.7_64
  Redis : 3.2
  MySQL : 5.6
  IP    : 10.10.0.25
  参考地址:https://github.com/gitlabhq/gitlab-recipes/tree/master/install/centos
  ubuntu 安装文档:http://docs.gitlab.com/ce/install/installation.html#using-https
  http://hdu104.com/401
  一:Add EPEL repository
  wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txt
  rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
  rpm -qa gpg*
  rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
  二:Add PUIAS Computational repository
  wget -O /etc/yum.repos.d/PUIAS_6_computational.repo https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/install/centos/PUIAS_6_computational.repo
  wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-puias http://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias
  rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias
  rpm -qa gpg*
  yum repolist
  yum-config-manager –enable epel –enable PUIAS_6_computational
  三:install the required tools for GitLab
  yum -y update
  yum -y groupinstall ‘Development Tools’
  yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel \
  expat-devel db4-devel byacc sqlite-devel libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt \
  libxslt-devel libicu libicu-devel system-config-firewall-tui redis sudo wget crontabs logwatch logrotate perl-Time-HiRes \
  git cmake libcom_err-devel.i686 libcom_err-devel.x86_64 nodejs
  yum-config-manager –enable rhel-6-server-optional-rpms
  yum -y install vim-enhanced
  update-alternatives –set editor /usr/bin/vim.basic
  yum -y install python-docutils
  四:安装git
  yum -y install postfix
  yum -y remove git
  yum install zlib-devel perl-CPAN gettext curl-devel expat-devel gettext-devel openssl-devel -y
  mkdir /tmp/git && cd /tmp/git
  curl –progress https://www.kernel.org/pub/software/scm/git/git-2.8.2.tar.gz|tar xz
  cd git-2.8.2/
  ./configure
  make
  make prefix=/usr/local install
  cd ..
  五:安装:Ruby
  yum remove ruby
  mkdir /tmp/ruby && cd /tmp/ruby
  #wget https://pkgs.api.huahuacaocao.net/gitlab/ruby-2.2.3.tar.gz
  wget http://10.10.0.4:81/gitlab/ruby-2.2.3.tar.gz
  tar zvfx ruby-2.2.3.tar.gz
  cd ruby-2.2.3
  ./configure –disable-install-rdoc
  make
  make prefix=/usr/local install
  cd ..
  修改本地源为taobao源:
  gem sources –add https://ruby.taobao.org/ –remove https://rubygems.org/
  gem install bundler –no-doc
  ruby -v
  六:添加用户
  adduser –system –shell /bin/bash –comment ‘GitLab’ –create-home –home-dir /home/git/ git
  vi /etc/sudoers +86
  #———————————————————————-
  #将如下:
  Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin
  #修改为
  Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
  #———————————————————————-
  七:配置MySQL
  安装略:IP地址 10.10.0.4

  CREATE USER ‘git’@’10.10.%’>  SET storage_engine=INNODB;
  CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
  GRANT SELECT,LOCK TABLES,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER ON `gitlabhq_production`.* TO ‘git’@’10.10.%’;
  八:配置Redis
  略:
  127.0.0.1:6379
  九:下载gitlab-ce 最新代码
  cd /home/git
  sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git
  mv gitlab-ce-master gitlab
  配置gitlab
  cd /home/git/gitlab
  sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
  vim config/gitlab.yml
  #======================================================================================
  #修改462行 git bin_path 为:
  bin_path: /usr/local/bin/git
  #修改30-35行gitlab为https
  gitlab:
  host: gitlab.api.hhcc.net
  port: 443
  https: true
  #修改70-72行邮箱信息
  email_from: admin@hhcc.net
  email_display_name: GitLab
  email_reply_to: admin@hhcc.net
  #======================================================================================
  chown -R git log/
  chown -R git tmp/
  chmod -R u+rwX log/
  chmod -R u+rwX tmp/
  sudo -u git -H 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/
  chmod -R u+rwX  public/uploads
  sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
  #视情况修改worker_processes 数量
  sudo -u git -H editor config/unicorn.rb
  sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
  #Configure Git global settings for git user, useful when editing via web
  #Edit user.email according to what is set in gitlab.yml
  sudo -u git -H git config –global user.name “admin”
  sudo -u git -H git config –global user.email “admin@hhcc.net”
  sudo -u git -H git config –global core.autocrlf input
  #Configure Redis
  sudo -u git -H cp config/resque.yml.example config/resque.yml
  vim config/resque.yml #以下方式任选其一
  #———————————–
  production: redis://127.0.0.1:6379
  #production: unix:/dev/shm/redis.sock
  #———————————–
  #Configure MySQL
  sudo -u git cp config/database.yml.mysql config/database.yml
  sudo -u git -H editor config/database.yml
  sudo -u git -H chmod o-rwx config/database.yml
  #——————————————–
  production:
  adapter: mysql2
  encoding: utf8
  collation: utf8_general_ci
  reconnect: false
  database: gitlabhq_production
  pool: 10
  username: git
  password: “xxxxxx”
  host: 10.10.0.4
  #——————————————–
  #Install Gems
  cd /home/git/gitlab
  #修改默认的源为taobao源
  vim Gemfile
  #————————————
  #source “https://rubygems.org”
  source “https://ruby.taobao.org”
  #————————————
  yum install -y mysql-devel
  gem install mysql2 -v ‘0.3.20’
  gem install rdoc-data; rdoc-data –install
  sudo -u git -H bundle install –deployment –without development test postgres aws
  #Install GitLab shell
  #sudo -u git -H bundle exec rake gitlab:shell:install[v2.1.0] REDIS_URL=redis://127.0.0.1:6379 RAILS_ENV=production
  sudo -u git -H bundle exec rake gitlab:shell:install REDIS_URL=redis://127.0.0.1:6379 RAILS_ENV=production
  vim /home/git/gitlab-shell/config.yml
  #—————————————————–
  user: git
  gitlab_url: https://gitlab.api.hhcc.net/
  http_settings:
  #注意以下行 默认为false
  self_signed_cert: true
  repos_path: “/home/git/repositories/”
  auth_file: “/home/git/.ssh/authorized_keys”
  redis:
  bin: “/usr/bin/redis-cli”
  namespace: resque:gitlab
  host: 127.0.0.1
  port: 6379
  log_level: INFO
  audit_usernames: false
  #—————————————————–
  #Ensure the correct SELinux contexts are set
  restorecon -Rv /home/git/.ssh
  #Initialize Database and Activate Advanced Features
  #设置密码(任选其一)
  #第一次登陆设置
  sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
  #默认设置
  sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=xxxxxx
  #成功会有如下提示:
  #== Seed from /home/git/gitlab/db/fixtures/production/001_admin.rb
  #Administrator account created:
  #
  #login:    root
  #password: xxxxxx
  #Install Init Script
  #wget -O /etc/init.d/gitlab https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/sysvinit/centos/gitlab-unicorn
  #chmod +x /etc/init.d/gitlab
  #chkconfig –add gitlab
  #chkconfig gitlab on
  #echo “/etc/init.d/gitlab start” >> /etc/rc.local
  cp lib/support/init.d/gitlab /etc/init.d/gitlab
  cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
  #Set up logrotate
  cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
  #Check Application Status
  sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
  #Compile assets
  sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
  Start your GitLab instance
  #修改gitlab端口可远程访问
  vim gitlab/config/unicorn.rb +42
  #—————————-
  listen “0.0.0.0:8081”, :tcp_nopush => true
  #—————————-
  安装workhorse:
  curl -O --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/local/bin/
  rm -rf go1.5.3.linux-amd64.tar.gz
  cd /home/git
  sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-workhorse.git
  cd gitlab-workhorse
  sudo -u git -H make
  #start gitlab
  /etc/init.d/gitlab start
  #配置Nginx https支持:
  参考文档:https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md#using-https
  nginx 配置文件路径:
  cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
  vim gitlab.api.hhcc.net.conf
  #———————————————————————————
  upstream gitlab {
  server unix:/home/git/gitlab/tmp/sockets/gitlab.socket fail_timeout=0;
  }
  upstream gitlab-workhorse {
  #server unix:/home/git/gitlab/gitlab-workhorse/socket;
  server  unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket;
  }
  server {
  listen 0.0.0.0:80;
  server_name gitlab.api.hhcc.net;
  server_tokens off;
  return 301 https://$http_host$request_uri;
  access_log  /data/logs/nginx/gitlab_access.log;
  error_log   /data/logs/nginx/gitlab_error.log;
  }
  server {
  listen 0.0.0.0:443 ssl;
  server_name gitlab.api.hhcc.net;
  server_tokens off;
  root /home/gitlab/public;
  client_max_body_size 20m;
  access_log /data/logs/nginx/gitlab_access.log;
  error_log /data/logs/nginx/gitlab_error.log;
  ssl on;
  ssl_certificate      /usr/local/nginx-1.8.1/conf/key/api.crt;
  ssl_certificate_key  /usr/local/nginx-1.8.1/conf/key/api.key;

  #GitLab needs backwards compatible ciphers to retain compatibility with Java>  ssl_ciphers “ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4”;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_prefer_server_ciphers on;
  ssl_session_cache shared:SSL:10m;
  ssl_session_timeout 5m;
  location / {
  try_files $uri $uri/index.html $uri.html @gitlab;
  }
  location /uploads/ {
  proxy_read_timeout 300;
  proxy_connect_timeout 300;
  proxy_redirect off;
  proxy_set_header Host $http_host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  #proxy_set_header X-Forwarded-Proto $scheme;
  proxy_set_header    X-Forwarded-Ssl     on;
  proxy_set_header    X-Forwarded-Proto   https;
  proxy_set_header X-Frame-Options SAMEORIGIN;
  proxy_pass http://gitlab;
  }
  location @gitlab {
  proxy_read_timeout 300;
  proxy_connect_timeout 300;
  proxy_redirect off;
  proxy_set_header Host $http_host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  #proxy_set_header X-Forwarded-Proto $scheme;
  proxy_set_header    X-Forwarded-Ssl     on;
  proxy_set_header    X-Forwarded-Proto   https;
  proxy_set_header X-Frame-Options SAMEORIGIN;
  proxy_pass http://gitlab;
  }
  location ~ ^/[\w\.-]+/[\w\.-]+/gitlab-lfs/objects {
  client_max_body_size 0;
  error_page 418 = @gitlab-workhorse;
  return 418;
  }
  location ~ ^/[\w\.-]+/[\w\.-]+/(info/refs|git-upload-pack|git-receive-pack)$ {
  client_max_body_size 0;
  error_page 418 = @gitlab-workhorse;
  return 418;
  }
  location ~ ^/[\w\.-]+/[\w\.-]+/repository/archive {
  client_max_body_size 0;
  error_page 418 = @gitlab-workhorse;
  return 418;
  }
  location ~ ^/api/v3/projects/.*/repository/archive {
  client_max_body_size 0;
  error_page 418 = @gitlab-workhorse;
  return 418;
  }
  location ~ ^/[\w\.-]+/[\w\.-]+/builds/download {
  client_max_body_size 0;
  error_page 418 = @gitlab-workhorse;
  return 418;
  }
  location ~ /ci/api/v1/builds/[0-9]+/artifacts {
  client_max_body_size 0;
  error_page 418 = @gitlab-workhorse;
  return 418;
  }
  location @gitlab-workhorse {
  proxy_read_timeout 300;
  proxy_connect_timeout 300;
  proxy_redirect off;
  proxy_buffering off;
  proxy_set_header Host $http_host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  #proxy_set_header X-Forwarded-Proto $scheme;
  proxy_set_header    X-Forwarded-Ssl     on;
  proxy_set_header    X-Forwarded-Proto   https;
  proxy_pass http://gitlab-workhorse;
  }
  location ~ ^/(assets)/ {
  root /home/git/gitlab/public;
  gzip_static on;
  expires max;
  add_header Cache-Control public;
  }
  error_page 502 /502.html;
  }
  #———————————————————————————
  转载地址:http://www.zhangluya.com/?p=193
  配置邮件报警:
  一:
  vim /home/git/gitlab/config/initializers/smtp_settings.rb
  #———————————————————————————
  [root@bj-6-gitlab-01 gitlab]# cat config/initializers/smtp_settings.rb
  # To enable smtp email delivery for your GitLab instance do the following:
  # 1. Rename this file to smtp_settings.rb
  # 2. Edit settings inside this file
  # 3. Restart GitLab instance
  #
  # For full list of options and their values see http://api.rubyonrails.org/classes/ActionMailer/Base.html
  #
  # If you change this file in a Merge Request, please also create a Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests
  if Rails.env.production?
  Rails.application.config.action_mailer.delivery_method = :smtp
  ActionMailer::Base.smtp_settings = {
  #address: “smtp.exmail.qq.com”,
  address: “pop.exmail.qq.com”,
  port: 25,
  user_name: “admin@hhcc.net”,
  password: “xxxxxx”,
  domain: “pop.exmail.qq.com”,
  authentication: :login,
  #enable_starttls_auto: true,
  enable_starttls_auto: false,
  openssl_verify_mode: ‘peer’ # See ActionMailer documentation for other possible options
  }
  end
  #———————————————————————————
  2:
  cd /home/git/gitlab
  sudo -u git -H vim config/gitlab.yml
  将默认邮箱修改为自己的邮箱
  #关闭注册功能
  gitlab关闭注册:去掉 Sign-up enabled 的对勾
  Admin–>settings –> Sign-in Restrictions
  Sign-upenbaled  关闭注册功能
  Sign-inenbaled  关闭注册登录功能
  问题1:error: RPC failed; result=22, HTTP code = 411
  该问题是由于客户端设置的http_post_buffer大小不足导致的,解决方法如下:
  git config –global https.postBuffer 524288000
  git config –global http.postBuffer 524288000
  问题二:在web端删除项目后重建 提示已存在
  可能是由于缓存的原因 稍等2分钟再重建即可
  问题三:不能上传大于10M的文件
  需要后台修改
  问题四:gitlab备份目录地址修改
  转载地址:http://www.zhangluya.com/?p=193
  vi /home/git/gitlab/config/gitlab.yml
  #—————————————-
  backup:
  path: “tmp/backups”
  #—————————————-
  问题五:环境检查
  sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
  问题六:清除缓存
  sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production
  问题七:备份恢复
  备份:
  cd /home/git/gitlab
  bundle exec rake gitlab:backup:create RAILS_ENV=production
  恢复:
  bundle exec rake gitlab:backup:restore RAILS_ENV=production BACKUP=111
  #这里需填写想恢复文件时间戳
  BACKUP=111
  问题七:
  zhangluyadeMacBook-Pro:~ zhangluya$ git clone git@gitlab.api.hhcc.net:php/mall.api.hhcc.net.git
  Cloning into ‘mall.api.hhcc.net’…
  GitLab: Failed to authorize your Git request: internal API unreachable
  fatal: Could not read from remote repository.
  Please make sure you have the correct access rights
  and the repository exists
  内部错误 设置下本地域名绑定即可:
  [root@bj-6-gitlab-01 ~]# cat /etc/hosts
  10.10.0.25 gitlab.api.hhcc.net
  问题八:雷哥提交
  解决办法:主要看以下三点
  1:
  vim config/unicorn.rb
  #———————-
  timeout 300 #默认为60 修改为300
  #———————-
  2:修改nginx  client_max_body_size 2000M;
  问题集锦:
  https://github.com/gitlabhq/gitlabhq/issues/4437


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-594099-1-1.html 上篇帖子: docker-gitlab 下篇帖子: GitLab遇到ssh修改了默认端口解决方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表