安装gitlab

2.1 方式一:下载gitlab-ce的rpm包

将对应版本的gitlab-ce下载到本地后,直接yum安装即可

 
# 要先将这个rpm包下载到本地
yum install -y gitlab-ce-13.6.1-ce.0.el7.x86_64.rpm

2.2 方式二:配置yum源

在 /etc/yum.repos.d/ 下新建 gitlab-ce.repo,写入如下内容:

 
[gitlab-ce]
name=gitlab-ce
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
Repo_gpgcheck=0
Enabled=1
Gpgkey=https://packages.gitlab.com/gpg.key

然后创建cache,再直接安装gitlab-ce

 
yum makecache  # 这一步会创建大量的数据

# 直接安装最新版
yum install -y gitlab-ce 

# 如果要安装指定的版本,在后面填上版本号即可
yum install -y  gitlab-ce-13.6.1

# 如果安装时出现gpgkey验证错误,只需在安装时明确指明不进行gpgkey验证
yum install gitlab-ce -y --nogpgcheck

2.3 gitlab的配置

配置文件位置  /etc/gitlab/gitlab.rb

 
[root@centos7 test]# vim /etc/gitlab/gitlab.rb

[root@centos7 test]# grep "^[a-Z]" /etc/gitlab/gitlab.rb

external_url 'http://42.192.51.99:9091' # 这里一定要加上http://

 nginx['listen_port'] = 9091 # 配置邮件服务

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "82955503@qq.com"
gitlab_rails['smtp_password'] = "frumknxschkbcacd"
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_pool'] = false

 gitlab_rails['gitlab_email_from'] = '82955503@qq.com'

 user['git_user_email'] =        "82955503@qq.com"

修改好配置文件后,要使用 gitlab-ctl reconfigure 命令重载一下配置文件,否则不生效。

 
gitlab-ctl reconfigure # 重载配置文件

报错:

execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8] (postgresql::enable line 49) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
STDOUT: The files belonging to this database system will be owned by user "gitlab-psql".
This user must also own the server process.
STDERR: initdb: error: invalid locale settings; check LANG and LC_* environment variables
---- End output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
Ran /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 returned 1
这是由于系统编码问题造成的,解决方法如下:
export LC_ALL=en_US.UTF-8 
export LANG=en_US.UTF-8 
export LANGUAGE=en_US.UTF-8
$ source ~/.bashrc

然后

gitlab-ctl reconfigure # 重载配置文件
gitlab-ctl start

端口是通了,但打开http://42.192.51.99:9091,报502错误

原因是8080端口被java占用,需要/etc/gitlab/gitlab.rb加上

  puma['port'] = 8101

然后

gitlab-ctl reconfigure # 重载配置文件
gitlab-ctl restart

 初始root密码在:/etc/gitlab/initial_root_password

2.4 gitlab占用系统资源过高的优化

我的电脑是腾讯云的4核8G,装上gitlab后,在页面上操作几下后就几乎卡死,cpu不高但内存吃紧。

然后gitlab.rb修改了以下配置:

 puma['worker_processes'] = 4 
puma['per_worker_max_memory_mb'] = 300
  sidekiq['max_concurrency'] = 25
postgresql['shared_buffers'] = "256MB"
  postgresql['max_worker_processes'] = 8
 prometheus_monitoring['enable'] = false

2.5 gitlab基本操作

gitlab-ctl start         # 启动所有 gitlab 组件
gitlab-ctl stop          # 停止所有 gitlab 组件
gitlab-ctl restart       # 重启所有 gitlab 组件
gitlab-ctl status        # 查看服务状态

gitlab-ctl reconfigure   # 启动服务
gitlab-ctl show-config   # 验证配置文件

gitlab-ctl tail          # 查看日志

gitlab-rake gitlab:check SANITIZE=true --trace    # 检查gitlab

 vim /etc/gitlab/gitlab.rb # 修改默认的配置文件

 

喜欢艺术的码农
原文地址:https://www.cnblogs.com/zjhgx/p/15731486.html