Centos 部署Gitlab

1、准备工作

1)注意注意注意!需要4G+内存

并不是说4G以下就无法安装....但是会容易出现无法预知的问题,比如出现502页面

2)安装所需要的依赖包

yum -y install policycoreutils-python openssh-server openssh-clients postfix

3)开启postfix

[root@VM_0_5_centos ~]# systemctl enable postfix && 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.
[root@VM_0_5_centos ~]# systemctl status postfix.service
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2019-05-07 23:30:09 CST; 16s ago
  Process: 27469 ExecStart=/usr/sbin/postfix start (code=exited, status=1/FAILURE)
  Process: 27466 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
  Process: 27463 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=75)

May 07 23:30:07 VM_0_5_centos systemd[1]: Starting Postfix Mail Transport Agent...
May 07 23:30:07 VM_0_5_centos aliasesdb[27463]: /usr/sbin/postconf: fatal: parameter inet_interfaces: no local inter...r ::1
May 07 23:30:08 VM_0_5_centos aliasesdb[27463]: newaliases: fatal: parameter inet_interfaces: no local interface fou...r ::1
May 07 23:30:08 VM_0_5_centos postfix[27469]: fatal: parameter inet_interfaces: no local interface found for ::1
May 07 23:30:09 VM_0_5_centos systemd[1]: postfix.service: control process exited, code=exited status=1
May 07 23:30:09 VM_0_5_centos systemd[1]: Failed to start Postfix Mail Transport Agent.
May 07 23:30:09 VM_0_5_centos systemd[1]: Unit postfix.service entered failed state.
May 07 23:30:09 VM_0_5_centos systemd[1]: postfix.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

2、下载安装包

访问 中文镜像站点查看最新的镜像版本,我选的是11.10.4

[root@VM_0_5_centos ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.10.4-ce.0.el7.x86_64.rpm
--2019-05-07 23:23:24--  https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.10.4-ce.0.el7.x86_64.rpm
Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 619044408 (590M) [application/x-redhat-package-manager]
Saving to: ‘gitlab-ce-11.10.4-ce.0.el7.x86_64.rpm’

100%[==================================================================================>] 619,044,408 10.4MB/s   in 61s

2019-05-07 23:24:48 (9.62 MB/s) - ‘gitlab-ce-11.10.4-ce.0.el7.x86_64.rpm’ saved [619044408/619044408]

3、安装

[root@VM_0_5_centos ~]# rpm -ivh gitlab-ce-11.10.4-ce.0.el7.x86_64.rpm
warning: gitlab-ce-11.10.4-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:gitlab-ce-11.10.4-ce.0.el7       ################################# [100%]
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.



     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/


Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

4、配置

1)端口

vim /etc/gitlab/gitlab.rb
// external_url -> "http://gitlab.example.com"
// 改为自己的服务器 "http://ip:端口"

2)刷新应用配置(这一步需要比较长的时间执行)

gitlab-ctl reconfigure

3)重启

[root@VM_0_5_centos ~]# gitlab-ctl restart
ok: run: alertmanager: (pid 32598) 0s
ok: run: gitaly: (pid 32607) 1s
ok: run: gitlab-monitor: (pid 32626) 0s
ok: run: gitlab-workhorse: (pid 32631) 0s
ok: run: logrotate: (pid 32640) 1s
ok: run: nginx: (pid 32648) 0s
ok: run: node-exporter: (pid 32653) 1s
ok: run: postgres-exporter: (pid 32667) 0s
ok: run: postgresql: (pid 32681) 1s
ok: run: prometheus: (pid 32688) 0s
ok: run: redis: (pid 32702) 0s
ok: run: redis-exporter: (pid 32708) 0s
ok: run: sidekiq: (pid 341) 0s
ok: run: unicorn: (pid 373) 0s

4)第一次访问,设置密码

image.png

5、问题

1)访问站点出现502

image.png

第一次访问或者低内存情况下会出现,或是其他原因,比如文件权限、端口占用

2)Nginx冲突

A)懒人方法,重命名nginx进程,参考 【记一次 gitlab 与老的 nginx 冲突处理

  • 复制一份 gitlib 下的 nginx
mv /opt/gitlab/embedded/sbin/nginx /opt/gitlab/embedded/sbin/nginx2
  • 修改启动脚本
vi /opt/gitlab/sv/nginx/run
  • 修改如下内容:
exec chpst -P /opt/gitlab/embedded/sbin/nginx -p /var/opt/gitlab/nginx
// 改为
exec chpst -P /opt/gitlab/embedded/sbin/nginx2 -p /var/opt/gitlab/nginx

reboot之后即可,但是如果执行gitlab-ctl reconfigure,该配置会被还原,切记不要随意reconfigure

B)使用非绑定的Nginx(兼容本机Nginx)

  • 具体参考官网教程,Using a non-bundled web-server,以下只列出操作步骤
  • 打开vi /etc/gitlab/gitlab.rb,也可以通过ftp打开文件编辑
  • 停止使用绑定的Nginx服务
nginx['enable'] = false
  • 设置web-server user用户名,这里我nginx使用的是LNMP,用户名为www,具体应以自己服务器配置而定
web_server['external_users'] = ['www']
  • 将本机IP添加到gitlab的信任列表中
gitlab_rails['trusted_proxies'] = [ '127.0.0.1' ]
  • 设置gitlab的监听端口,以8181端口为例,即访问使用的端口
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181" 
  • 重载配置
gitlab-ctl reconfigure
gitlab-ctl restart

要注意的是,我配置过懒人方法,所以导致进程中有多个nginx,所以此时restart之后无法访问,还是需要reboot下,可以配置、使用nginx转发,就可以通过域名访问部署好的gitlab

3)汉化

补丁主页 ,目前最新的补丁是11.10.2,但是我安装的是11.10.4,但目前没有发现异常`;

  • 下载补丁
wget https://gitlab.com/xhang/gitlab/-/archive/11-10-stable-zh/gitlab-11-10-stable-zh.tar.gz
tar -zxf gitlab-11-10-stable-zh.tar.gz
cp -rp /opt/gitlab/embedded/service/gitlab-rails{,.bak_$(date +%F)}    
  • 覆盖源文件,这里需要使用/bin/cp -rf,进行强制覆盖,不然会需要一直确认是否覆盖
/bin/cp -rf gitlab-11-10-stable-zh/* /opt/gitlab/embedded/service/gitlab-rails/    
  • 刷新配置、重启
gitlab-ctl reconfigure
gitlab-ctl restart
  • 重启之后发现许多内容仍为英文,使用admin进入设置
    image.png

    选择Language简体中文,保存、刷新页面后,内容基本汉化

4)关闭注册功能

进入管理中心 - 设置 - 取消启用注册 - 保存

image.png

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 198,932评论 5 466
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 83,554评论 2 375
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 145,894评论 0 328
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,442评论 1 268
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,347评论 5 359
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 47,899评论 1 275
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,325评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,980评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,196评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,163评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,085评论 1 328
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,826评论 3 316
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,389评论 3 302
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,501评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,753评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,171评论 2 344
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 41,616评论 2 339