centos7.6 x64 安装Gitlab
参考官网
https://about.gitlab.com/install/#centos-7     https://docs.gitlab.com/omnibus/settings/smtp.html
安装前:

[root@localhost ~]# free -m

1,环境要求:最低2G内存,建议内存4G,大概支持100人左右使用,一下为最新环境centos7.6 x64和gitlab 10.8版本

先检查一下依赖:sshd

[root@localhost soft]# rpm -qa|grep openssh-server
openssh-server-7.4p1-11.el7.x86_64
[root@localhost soft]# ps -e|grep sshd
  1107 ?        00:00:00 sshd
 12585 ?        00:00:00 sshd
 12590 ?        00:00:00 sshd

如果你没有,那么:

sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld

如没安装防火墙(如果已经安装了防火墙并且已经在运行状态,则可直接进行第b步)

yum install firewalld systemd -y

若出现“完毕!”的字样,则表示安装成功

a.开启防火墙,安装命令:service firewalld  start

群晖 Gitlab 群晖gitlab需要多大内存_gitlab

b.添加http服务到firewalld,pemmanent表示永久生效,若不加--permanent系统下次启动后就会失效。

sudo firewall-cmd --permanent --add-service=http

群晖 Gitlab 群晖gitlab需要多大内存_gitlab_02

c.重启防火墙,安装命令:sudo systemctl reload firewalld

 

再检查一下postfix 邮件服务 用于发送邮件通知,如果有其他的解决方案,可以不用安装,跳过此步

[root@localhost soft]# rpm -qa|grep postfix
postfix-2.10.1-6.el7.x86_64
[root@localhost soft]# ps -e|grep postfix

如果你没有,那么如下:

sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

注意:执行
>sudo systemctl start postfix
Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details.
问题出现在网络设置,ipv6网段,
方法一
vim /etc/hosts     //注释掉下面一行
#::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
方法二
vim打开/etc/postfix/main.cf,修改如下两项,修改之前可以先备份下
vim /etc/postfix/main.cf
#修改
inet_interfaces = localhost 为 inet_interfaces = all 
inet_protocols = all 为 inet_protocols = ipv4

[root ~]# systemctl start postfix
[root ~]# 
[root ~]# systemctl enable postfix
[root ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-03-11 21:56:19 CST; 26s ago
 Main PID: 14341 (master)
   CGroup: /system.slice/postfix.service
           ├─14341 /usr/libexec/postfix/master -w
           ├─14342 pickup -l -t unix -u
           └─14343 qmgr -l -t unix -u

Mar 11 21:56:18 zxl-git-server systemd[1]: Starting Postfix Mail Transport Agent...
Mar 11 21:56:19 zxl-git-server postfix/master[14341]: daemon started -- version 2.10.1, configuration /etc/postfix
Mar 11 21:56:19 zxl-git-server systemd[1]: Started Postfix Mail Transport Agent.

以上表 postfix 安装成功

也可直接:

sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
#以下2步可跳过
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld

2.下载安装Gitlab包

下载最新rpm  https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/?C=M&O=D
mkdir /usr/local/gitlab
cd /usr/local/gitlab/
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.8.1-ce.0.el7.x86_64.rpm

也可使用国内YUM源:

vim /etc/yum.repos.d/gitlab-ce.repo

复制下面文本:

[gitlab-ce]

name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1

  yum 安装:

      1,yum makecache

      2,yum install gitlab-ce -y

# 安装
 rpm -ivh gitlab-ce-11.8.1-ce.0.el7.x86_64.rpm
 gitlab安装完成后,需要设置一个访问地址(或域名),打开/etc/gitlab/gitlab.rb,将默认的external_url = 'http://git.example.com'修改为自己的IP地址:http://xxx.xx.xxx.xx
 ]# vim /etc/gitlab/gitlab.rb
 external_url 'http://47.104.x.x:8080' # 默认8080
 unicorn['port'] = 8080# 配置STMP邮件发送服务 
 #下面的两个邮箱要一致 
 gitlab_rails['gitlab_email_enabled'] = true
 gitlab_rails['gitlab_email_from'] = 'admin@163.com'
 gitlab_rails['gitlab_email_display_name'] = 'admin'
 gitlab_rails['gitlab_email_reply_to'] = 'noreply@163.com'
  
 gitlab_rails['smtp_enable'] = true
 gitlab_rails['smtp_address'] = "smtp.163.com"
 gitlab_rails['smtp_port'] = 25
 gitlab_rails['smtp_user_name'] = "admin@163.com"
 gitlab_rails['smtp_password'] = "密码"
 gitlab_rails['smtp_domain'] = "163.com"
 gitlab_rails['smtp_authentication'] = "login"
 修改完成后:wq保存退出,执行以下命令,让配置生效
 [root@test32 gitlab]# gitlab-ctl reconfigureQA:找不到文件 /var/opt/gitlab/postgresql/.s.PGSQL.5432
可能是执行的时候没有权限创建
sudo chmod 755 /var/opt/gitlab/postgresql/
然后 启动Gitlab
 # gitlab-ctl start
 ok: run: gitaly: (pid 6638) 186s
 ok: run: gitlab-monitor: (pid 6656) 186s
 ok: run: gitlab-workhorse: (pid 6659) 186s
 ok: run: logrotate: (pid 6703) 185s
 ok: run: nginx: (pid 6709) 185s
 ok: run: node-exporter: (pid 6715) 184s
 ok: run: postgres-exporter: (pid 6720) 184s
 ok: run: postgresql: (pid 7324) 44s
 ok: run: prometheus: (pid 6752) 171s
 ok: run: redis: (pid 6761) 171s
 ok: run: redis-exporter: (pid 6765) 170s
 ok: run: sidekiq: (pid 7299) 45s
 ok: run: unicorn: (pid 7476) 18s
 启动完成后,在浏览器输入http://47.104.x.x:8080,就是gitlab的登录首页了,如果出现502页面,需修改默认的8080端口第一次登录使用的用户名和密码为 root 和 5iveL!fe。
当访问http://ip:xx/xx 出现502 则查看端口是否被占用
netstat -tnpl
 其他解答(官方)sudo gitlab-ctl restart sidekiq 
 sudo gitlab-ctl hup unicorn如果是用的阿里云专有网络,安全组:入向须配置端口放行
另外:测试邮箱
 [root@test32 gitlab]# gitlab-rails console
 GitLab: 11.7.5 (c5b5b18)
 GitLab Shell: 8.4.4
 postgresql: 9.6.11
 -------------------------------------------------------------------------------------
 Loading production environment (Rails 5.0.7.1)
 irb(main):003:0> Notify.test_email('自己的能收邮件的邮箱@qq.com', 'Message Subject', 'Message Body').deliver_now
 然后输出一大串日志,成功的话能看出来,而且能收到邮件, 然后去网页试试忘记密码输入邮箱会收到一个重置密码的邮件对GitLab进行重配置 (这一步也是启动 GitLab)
gitlab-ctl reconfigureGitLab常用命令
sudo gitlab-ctl start                    # 启动所有 gitlab 组件;
 sudo gitlab-ctl stop                    # 停止所有 gitlab 组件;
 sudo gitlab-ctl restart                # 重启所有 gitlab 组件;
 sudo gitlab-ctl status                 # 查看服务状态;
 sudo gitlab-ctl reconfigure         # 启动服务;
 sudo vim /etc/gitlab/gitlab.rb      # 修改默认的配置文件;
 gitlab-rake gitlab:check SANITIZE=true --trace    # 检查gitlab;
 sudo gitlab-ctl tail                        # 查看日志;
 -------------------------------------------------------------------完全卸载GitLab
 一、停止gitlab
     sudo gitlab-ctl stop
 二、卸载gitlab(这块注意了,看看是gitlab-ce版本还是gitlab-ee版本,别写错误了)
     sudo rpm -e gitlab-ce三、查看gitlab进程
    ps -ef|grep gitlab
      杀掉第一个守护进程(runsvdir -P /opt/gitlab/service log)
      kill -9 4473
      再次查看gitlab进程是否存在四、删除gitlab文件
        find / -name *gitlab*|xargs rm -rf      删除所有包含gitlab的文件及目录
        find / -name gitlab |xargs rm -rf 
        删除gitlab-ctl uninstall时自动在root下备份的配置文件(ls /root/gitlab* 看看有没有,有也删除)

通过以上几步就可以彻底卸载gitlab