saundy 发表于 2018-1-12 10:47:40

centos 安装giblab

  本文章转载自:http://www.cnblogs.com/fanjingfeng/p/6665597.html
  一, 服务器快速搭建gitlab方法
  可以参考gitlab中文社区 的教程
  centos7安装gitlab:https://www.gitlab.cc/downloads/#centos7
  centos6安装gitlab:https://www.gitlab.cc/downloads/#centos6
  如下方法按照官网来操作,手工安装过于麻烦。当前测试平台为小鸟云的三个月centos 7测试机.
  1. 安装配置依赖项
  如想使用Postfix来发送邮件,在安装期间请选择’Internet Site’. 您也可以用sendmai或者 配置SMTP服务 并 使用SMTP发送邮件. 在 Centos 6 和 7 系统上, 下面的命令将在系统防火墙里面开放HTTP和SSH端口.

https://common.cnblogs.com/images/copycode.gif  

sudo yum install curl policycoreutils openssh-server openssh-clients  
sudo systemctl enable sshd
  
sudo systemctl start sshd
  
sudo yum install postfix
  
sudo systemctl enable postfix
  
sudo systemctl start postfix
  
sudo firewall-cmd --permanent --add-service=http

  
sudo systemctl>  

https://common.cnblogs.com/images/copycode.gif
  这里可以自己yum 一个iptables做处理,一样的效果。 2. 添加GitLab仓库,并安装到服务器上
  

curl -sS http://packages.gitlab.cc/install/gitlab-ce/script.rpm.sh | sudo bash  
sudo yum install gitlab-ce
  

  如果你不习惯使用命令管道的安装方式, 你可以在这里下载 安装脚本 或者 手动下载您使用的系统相应的安装包(RPM/Deb) 然后安装
  

curl -LJO https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-XXX.rpm  
rpm -i gitlab-ce-XXX.rpm
  


3. 启动GitLab


[*]sudo gitlab-ctl reconfigure
  下边就可以访问了: https://images2017.cnblogs.com/blog/1227196/201709/1227196-20170925225639479-2019647171.jpg重置下密码。登录效果如下: https://images2017.cnblogs.com/blog/1227196/201709/1227196-20170925225720276-1504845812.jpg
  注意事项以及异常故障排查:
  1,按照该方式,我安装了一个确实没问题,只不过是英文版。没有经过汉化。
  2,默认安装登录需要重置root密码。可以自己单独设置一个复杂密码后登录。
  3,gitlab本身采用80端口,如安装前服务器有启用80,安装完访问会报错。需更改gitlab的默认端口。 修改vim /etc/gitlab/gitlab.rb: external_url ‘http://localhost:90’
  4,unicorn本身采用8080端口,如安装前服务器有启用8080,安装完访问会报错。需更改unicorn的默认端口。 修改 /etc/gitlab/gitlab.rb: unicorn[‘listen’] = ‘127.0.0.1’ unicorn[‘port’] = 3000
  5,每次重新配置,都需要执行sudo gitlab-ctl reconfigure使之生效。
  6,日志位置:/var/log/gitlab 可以进去查看访问日志以及报错日志等,供访问查看以及异常排查。 gitlab-ctl tail #查看所有日志 gitlab-ctl tail nginx/gitlab_access.log #查看nginx访问日志
  二,gitlab中文汉化 1,需要下载汉化包,我们这里直接到去git一个。如果没安装git的请自行yum或apt-get 一个git。比如我们现在到/usr/local/src,执行如下命令去git clone包:


[*]git clone https://github.com/larryli/gitlabhq.git
  2,停止当前gitlab


[*]gitlab-ctl stop
[*]\cp /usr/local/src/gitlabhq/* /opt/gitlab/embedded/service/gitlab-rails/ -rf
  其中有两个提示我们可以忽略: cp: cannot overwrite non-directory `/opt/gitlab/embedded/service/gitlab-rails/log’ with directory `./log’ cp: cannot overwrite non-directory `/opt/gitlab/embedded/service/gitlab-rails/tmp’ with directory `./tmp’ 好了,汉化完成,重新启动gitlab,汉化完成。
  三,日常管理
  gitlab-ctl start|stop|status|restart 比如查看状态:


[*]# gitlab-ctl status
[*]run: gitlab-workhorse: (pid 19922) 665s; run: log: (pid 19159) 725s
[*]run: logrotate: (pid 19179) 723s; run: log: (pid 19178) 723s
[*]run: nginx: (pid 19166) 724s; run: log: (pid 19165) 724s
[*]run: postgresql: (pid 19026) 760s; run: log: (pid 19025) 760s
[*]run: redis: (pid 18943) 766s; run: log: (pid 18942) 766s
[*]run: sidekiq: (pid 19149) 732s; run: log: (pid 19148) 732s
[*]run: unicorn: (pid 20257) 642s; run: log: (pid 19116) 734s

  四,启动日志
  Recipe: gitlab::redis-exporter
  * ruby_block action create

  - execute the ruby block>  Recipe: gitlab::prometheus
  * service action restart
  - restart service service
  * ruby_block action create

  - execute the ruby block>  Recipe: gitlab::postgres-exporter
  * service action restart
  - restart service service
  * ruby_block action create

  - execute the ruby block>  Running handlers:
  Running handlers complete
  Chef Client finished, 256/510 resources updated in 02 minutes 05 seconds
  gitlab Reconfigured!
  看到gitlab Reconfigured! 说明启动成功!
  要是一直卡到ruby_block action run 运行一下命令
  解决方案:
  1、按住CTRL+C强制结束;
  2、运行:sudo systemctl restart gitlab-runsvdir;
  3、再次执行:sudo gitlab-ctl reconfigure
  解决方案来源:https://gitlab.com/gitlab-org/omnibus-gitlab/issues/160
页: [1]
查看完整版本: centos 安装giblab