gitlab部署

gitlab部署

gitlab部署

安装方式介绍:https://docs.gitlab.com/ee/install/README.html

  • 配置gitlab仓库,用包管理器直接安装,(会自动安装所有依赖组件,官方推荐)
  • helm chart安装,for k8s平台
  • docker方式
  • 从头逐步安装各个组件

此处采用官方推荐的方式,仓库安装

安装依赖

参考文档;https://about.gitlab.com/install/#centos-7

[root@gitlab ~]# yum install -y curl policycoreutils openssh-server openssh-client postfix

配置gitlab的仓库

这里采用清华大学的仓库源,配置仓库地址

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

sudo yum makecache
sudo yum install gitlab-ce

直接安装



[root@gitlab ~]# yum list all |grep gitlab
gitlab-ce.x86_64                         13.6.1-ce.0.el7               gitlab-ce
python2-gitlab.noarch                    1.3.0-3.el7.1                 epel     
[root@gitlab ~]# yum install -y gitlab-ce
Installed:
  gitlab-ce.x86_64 0:13.6.1-ce.0.el7                                                                                                                                                        

Dependency Installed:
  audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7    libcgroup.x86_64 0:0.41-21.el7 libsemanage-python.x86_64 0:2.5-14.el7 policycoreutils-python.x86_64 0:2.5-34.el7
  python-IPy.noarch 0:0.75-6.el7         setools-libs.x86_64 0:3.3.8-4.el7

Dependency Updated:
  audit.x86_64 0:2.8.5-4.el7                                                                 audit-libs.x86_64 0:2.8.5-4.el7                                                                

Complete!

修改配置文件

修改配置文件中,external_url地址,为自己部署主机的ip;

[root@gitlab ~]# vim /etc/gitlab/gitlab.rb 
...
#external_url 'http://gitlab.example.com'
external_url 'http://192.168.80.102'

reconfigure使得配置重新生效;

[root@gitlab ~]# gitlab-ctl reconfigure
...
Running handlers:
Running handlers complete
Chef Infra Client finished, 207/1184 resources updated in 01 minutes 53 seconds

Deprecations:
* sidekiq_cluster['experimental_queue_selector'] has been deprecated since 13.6 and will be removed in 14.0. The experimental_queue_selector option is now called queue_selector.


Notes:
It seems you haven't specified an initial root password while configuring the GitLab instance.
On your first visit to  your GitLab instance, you will be presented with a screen to set a
password for the default admin account with username `root`.


遇到的问题,google查得,可能为vm内存不足导致,加大到3g后可以,最低要求2g
Errno::ENOMEM: Cannot allocate memory - fork(2) gitlab

重启gitlab

[root@gitlab ~]# gitlab-ctl restart
ok: run: alertmanager: (pid 7457) 1s
ok: run: gitaly: (pid 7467) 0s
ok: run: gitlab-exporter: (pid 7479) 1s
ok: run: gitlab-workhorse: (pid 7483) 0s
ok: run: grafana: (pid 7504) 0s
ok: run: logrotate: (pid 7519) 1s
ok: run: nginx: (pid 7527) 0s
ok: run: node-exporter: (pid 7537) 1s
ok: run: postgres-exporter: (pid 7542) 0s
ok: run: postgresql: (pid 7551) 1s
ok: run: prometheus: (pid 7560) 0s
ok: run: puma: (pid 7646) 0s
ok: run: redis: (pid 7652) 0s
ok: run: redis-exporter: (pid 7660) 1s
ok: run: sidekiq: (pid 7667) 0s

查看gitlab组件

[root@gitlab ~]# gitlab-ctl status
run: alertmanager: (pid 7457) 18s; run: log: (pid 6674) 341s
run: gitaly: (pid 7467) 17s; run: log: (pid 5012) 1266s
run: gitlab-exporter: (pid 7479) 17s; run: log: (pid 6593) 359s
run: gitlab-workhorse: (pid 7483) 16s; run: log: (pid 5353) 1182s
run: grafana: (pid 7504) 16s; run: log: (pid 6838) 287s
run: logrotate: (pid 7519) 16s; run: log: (pid 6526) 369s
run: nginx: (pid 7527) 15s; run: log: (pid 5377) 1177s
run: node-exporter: (pid 7537) 15s; run: log: (pid 6564) 365s
run: postgres-exporter: (pid 7542) 14s; run: log: (pid 6710) 335s
run: postgresql: (pid 7551) 14s; run: log: (pid 5142) 1258s
run: prometheus: (pid 7560) 13s; run: log: (pid 6645) 347s
run: puma: (pid 7646) 12s; run: log: (pid 5313) 1194s
run: redis: (pid 7652) 13s; run: log: (pid 4973) 1273s
run: redis-exporter: (pid 7660) 13s; run: log: (pid 6617) 354s
run: sidekiq: (pid 7667) 9s; run: log: (pid 5339) 1187s

浏览器登陆

访问的地址,external_url为浏览器里访问的地址;第一次访问,会提示修改管理员密码,**管理员账户,默认为root;**非linux系统的root!

修改后,用root登陆即可;

image-20201204175258551

查看版本

[root@gitlab ~]# gitlab-rake gitlab:env:info

System information
System:		
Current User:	git
Using RVM:	no
Ruby Version:	2.7.2p137
Gem Version:	3.1.4
Bundler Version:2.1.4
Rake Version:	13.0.1
Redis Version:	5.0.9
Git Version:	2.29.0
Sidekiq Version:5.2.9
Go Version:	unknown

GitLab information
Version:	13.6.1
Revision:	1b6a590b197
Directory:	/opt/gitlab/embedded/service/gitlab-rails
为13.6版本

关闭自动注册

​ 首次登陆会提示open registration问题,如下图示:

image-20201204175805325

​ 下图示:默认的设置,用户通过访问注册url,可以自行注册用户,不安全,应该关闭;将默认选中的2项,取消,点击保存即可;

image-20201204180019185

关闭前:有注册选项,register now;

image-20201206125721722

关闭后:无注册选项;

image-20201206125943167

配置smtp服务

  1. 登陆自己的qq或163邮箱,开启smtp服务,会生成一个授权码,假设为aaa;

  2. 配置本地gitlab的配置文件;

    [root@gitlab ~]# vim /etc/gitlab/gitlab.rb
       
    external_url 'http://本地私有gitlab的url' 
    gitlab_rails['smtp_enable'] = true  
    gitlab_rails['smtp_address'] = "smtp.163.com"  
    gitlab_rails['smtp_port'] = 25  
    gitlab_rails['smtp_user_name'] = "你注册的公网邮箱"  
    gitlab_rails['smtp_password'] = "开启smtp服务时给的授权码"  
    gitlab_rails['smtp_domain'] = "163.com"  
    gitlab_rails['smtp_authentication'] = :login  
    gitlab_rails['smtp_enable_starttls_auto'] = true  
    gitlab_rails['gitlab_email_from'] = "你注册的公网邮箱"  
    user["git_user_email"] = "你注册的公网邮箱"  
       
    # smpt-port不同的邮箱服务商不同,网易163是25
    
  3. 重新生成配置、重启gitlab

    [root@gitlab ~]# gitlab-ctl reconfigure
    [root@gitlab ~]# gitlab-ctl restart
    
  4. 之后,本地的gitlab就可以借助公网的邮箱服务,发送互联网邮件;

创建普通用户测试邮箱

1、管理员创建普通用户,邮箱填写为公网可达,或公司内部私网可达邮箱地址;

image-20201206132758755

2、此时普通用户,假设为申请了账户的开发人员,通过公网或私网邮箱地址收到了账户创建通知,之后需要点击连接改自己的密码,然后就可以进行登陆;

更改密码会也会收到邮件通知;

image-20201206132350717

image-20201206132330909

updatedupdated2020-12-072020-12-07
加载评论