Gitlab--安装及汉化

摘要:
GitLab具有与Github类似的功能,可以浏览源代码、管理缺陷和评论。差异:1。GitHub需要付费才能使用私有仓库。GitLab可以在其上创建一个私有的免费仓库。但对于开源项目,GitHub仍然是代码托管的首选。
简介

gitlab是一个利用 Ruby on Rails 开发的开源应用程序,实现一个自托管的Git 项目仓库,可通过Web界面迚行访问公开的戒者私人项目。
Ruby on Rails 是一个可以使你开发、部署、维护 web 应用程序变得简单的框架。
GitLab 拥有与Github 类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,
它非常易于浏览提交过的版本并提供一个文件历史库。它还提供一个代码片段收集功能可以轻松实现代码
复用,便于日后有需要的时候迚行查找。
GitLab 中文网:https://www.gitlab.cc/installation/#centos-7

gitlab和github的区别

Gitlab--安装及汉化第1张

相同点: 二者都是基于web 的Git 仓库,在很大程度上GitLab 是仿照GitHub 来做的,它们都提供了分享开源项目的平台,为开发团队提供了存储、分享、发布和合作开发项目的中心化于存储的场所。
不同点:
1、GitHub 如果要使用私有仓库,是需要付费的。GitLab 可以在上面创建私人的免费仓库。
2、GitLab 让开发团队对他们的代码仓库拥有更多的控制,相比于GitHub,它有不少的特色:
     允许免费设置仓库权限;
     允许用户选择分享一个project 的部分代码;
     允许用户设置project 的获取权限,进一步的提升安全性;
     可以设置获取到团队整体的改进进度;通过innersourcing 让不在权限范围内的人访问不到该资源。
总结:从代码私有性方面来看,有时公司并不希望员工获取到全部的代码,这个时候GitLab 无疑是更好的选择。但对于开源项目而言,GitHub 依然是代码托管的首选。

git 相关概念:
git 是一种版本控制系统,是一个命令,是一种工具
gitlib 是用于实现git 功能的开发库
github 是一个基于git 实现的在线代码托管仓库,包含一个网站界面,向亏联网开放
gitlab 是一个基于git 实现的在线代码仓库托管软件,一般用亍在企业内部网络搭建git 私服
注: gitlab-ce 社区版 ; gitlab-ee 是企业版,收费

安装

温馨提示:
本次gitlab的环境是:
操作系统:centos7
主机名:gitlab
IP: 192.168.192.131
内存: 8G(这里要重要的提示一下,内存最少4G,不然会出现访问超时的错误,譬如:502)
防火墙: 关闭状态(这里可以开,可以不开,下面有开防火墙的设置方法)

gitlab rpm安装包百度云下载:https://pan.baidu.com/s/1a57PWAvCQcxMBI2qwfyR2g

gitlab 汉化包百度云下载:https://pan.baidu.com/s/1DVZXrfH08JRYNuBw6zvLJQ

百度云链接永久有效,如果链接失效可以联系我

安装依赖

安装依赖包:

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

这里安装了postfix,主要的原因是因为我们要使用gitlab的发邮件的功能,先启动一下postfix
[root@gitlab ~]# 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@gitlab ~]# 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 Fri 2019-01-04 15:38:30 CST; 17s ago
  Process: 10951 ExecStart=/usr/sbin/postfix start (code=exited, status=1/FAILURE)
  Process: 10948 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
  Process: 10943 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=75)

Jan 04 15:38:28 gitlab systemd[1]: Starting Postfix Mail Transport Agent...
Jan 04 15:38:28 gitlab aliasesdb[10943]: /usr/sbin/postconf: fatal: parameter inet_interfaces: no local interface found for ::1
Jan 04 15:38:29 gitlab aliasesdb[10943]: newaliases: fatal: parameter inet_interfaces: no local interface found for ::1
Jan 04 15:38:29 gitlab postfix[10951]: fatal: parameter inet_interfaces: no local interface found for ::1
Jan 04 15:38:30 gitlab systemd[1]: postfix.service: control process exited, code=exited status=1
Jan 04 15:38:30 gitlab systemd[1]: Failed to start Postfix Mail Transport Agent.
Jan 04 15:38:30 gitlab systemd[1]: Unit postfix.service entered failed state.
Jan 04 15:38:30 gitlab systemd[1]: postfix.service failed.

在启动的时候出现了上面的报错,原因是因为: /etc/postfix/main.cf 中的 inet_interfaces = localhost 把这一个参数改为: inet_interfaces = all
[root@gitlab ~]# vim /etc/postfix/main.cf
原参数:
inet_interfaces = localhost
改为:
inet_interfaces = all
保存,然后在重启
[root@gitlab ~]# systemctl start postfix

yum安装

yum 安装gitlab:

使用这种方式安装的gitlab永远都是最新版的,也会比较慢
[root@gitlab ~]# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
[root@gitlab ~]# yum -y install gitlab-ce

rpm安装

rpm 安装gitlab:

这里采用了 清华大学开源软件镜像站 下载并安装(速度快),使用的是gitlab-ce-11.6.1的版本

下载gitlab安装包
这里采用了 清华大学开源软件镜像站(https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/) 下载并安装(速度快),使用的是gitlab-ce-11.6.1的版本

下载gitlab安装包(没有wget命令请自行使用yum -y install wget 安装)
[root@gitlab ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.6.1-ce.0.el7.x86_64.rpm

安装gitlab
[root@gitlab ~]# rpm -ivh gitlab-ce-11.6.1-ce.0.el7.x86_64.rpm 

这里说一下rpm安装gitlab安装后的目录和文件的作用:
/opt/gitlab/                # gitlab的程序安装目录
/etc/gitlab/gitlab.rb       # gitlab的配置文件
/var/opt/gitlab             # gitlab目录数据目录
/var/opt/gitlab/git-data    # 存放仓库数据
/var/log/gitlab/            # 日志地址
/var/opt/gitlab/            # 各服务地址

gitlab管理命令

gitlab‐ctl reconfigure      # 更改配置文件后需重新配置
gitlab‐ctl status           # 查看目前gitlab所有服务运维状态
gitlab‐ctl stop             # 停止gitlab服务
gitlab‐ctl stop nginx       # 单独停止某个服务
gitlab‐ctl tail             # 查看所有服务的日志
配置

gitlab配置

安装完成后,修改gitlab的配置文件(在/etc/gitlab/gitlab.rb)

更改URL地址为本地IP地址:
原参数:
external_url 'http://gitlab.example.com'
改为:
external_url 'http://192.168.192.131'

配置gitlab并启动(配置完成会自动启动)
[root@gitlab ~]# gitlab-ctl reconfigure

查看启动状态:
[root@gitlab ~]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      11178/master        
tcp        0      0 0.0.0.0:8060            0.0.0.0:*               LISTEN      15433/nginx: master 
tcp        0      0 127.0.0.1:9121          0.0.0.0:*               LISTEN      15622/redis_exporte 
tcp        0      0 127.0.0.1:9090          0.0.0.0:*               LISTEN      15472/prometheus    
tcp        0      0 127.0.0.1:9187          0.0.0.0:*               LISTEN      15450/postgres_expo 
tcp        0      0 127.0.0.1:9093          0.0.0.0:*               LISTEN      15284/alertmanager  
tcp        0      0 127.0.0.1:9100          0.0.0.0:*               LISTEN      15442/node_exporter 
tcp        0      0 127.0.0.1:9229          0.0.0.0:*               LISTEN      15339/gitlab-workho 
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      15738/unicorn maste 
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      15433/nginx: master 
tcp        0      0 127.0.0.1:9168          0.0.0.0:*               LISTEN      15329/puma 3.12.0 ( 
tcp        0      0 127.0.0.1:8082          0.0.0.0:*               LISTEN      15706/sidekiq 5.2.3 
tcp        0      0 127.0.0.1:9236          0.0.0.0:*               LISTEN      15302/gitaly        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1005/sshd           
tcp6       0      0 :::25                   :::*                    LISTEN      11178/master        
tcp6       0      0 :::9094                 :::*                    LISTEN      15284/alertmanager  
tcp6       0      0 :::22                   :::*                    LISTEN      1005/sshd           
udp        0      0 127.0.0.1:323           0.0.0.0:*                           690/chronyd         
udp        0      0 0.0.0.0:56458           0.0.0.0:*                           11209/local         
udp        0      0 0.0.0.0:68              0.0.0.0:*                           759/dhclient        
udp6       0      0 ::1:323                 :::*                                690/chronyd         
udp6       0      0 :::9094                 :::*                                15284/alertmanager  

看到一堆服务,但是那个是gitlab相关的呢,使用下面命令查看:
[root@gitlab ~]# gitlab-ctl status
run: alertmanager: (pid 15284) 2231s; run: log: (pid 13802) 2409s
run: gitaly: (pid 15302) 2231s; run: log: (pid 13583) 2413s
run: gitlab-monitor: (pid 15329) 2230s; run: log: (pid 13703) 2412s
run: gitlab-workhorse: (pid 15339) 2230s; run: log: (pid 13526) 2415s
run: logrotate: (pid 15354) 2230s; run: log: (pid 13543) 2414s
run: nginx: (pid 15433) 2229s; run: log: (pid 13534) 2415s
run: node-exporter: (pid 15442) 2229s; run: log: (pid 13606) 2412s
run: postgres-exporter: (pid 15450) 2228s; run: log: (pid 13824) 2408s
run: postgresql: (pid 15460) 2228s; run: log: (pid 13485) 2417s
run: prometheus: (pid 15472) 2228s; run: log: (pid 13769) 2409s
run: redis: (pid 15485) 2227s; run: log: (pid 13477) 2417s
run: redis-exporter: (pid 15622) 2227s; run: log: (pid 13729) 2411s
run: sidekiq: (pid 15706) 2202s; run: log: (pid 13503) 2416s
run: unicorn: (pid 15719) 2201s; run: log: (pid 13494) 2417s

上面发现配置个gitlab竟然启动了一堆的东西,什么鬼。。。。
其实这些启动的都是gitlab服务需要的组件服务

Gitlab的服务有很多的组件构成的,如:
nginx:              静态web服务器
gitlab‐workhorse:   轻量级的反向代理服务器
logrotate:         日志文件管理工具
postgresql:        数据库
redis:             缓存数据库
sidekiq:           用于在后台执行队列任务(异步执行),(Ruby)
unicorn:           An HTTP server for Rack applications,GitLab Rails应用是托管在这个服务器上面的。(RubyWeb Server,主要使用Ruby编写)

 防火墙设置

防火墙设置(防火墙也会引起502的错误)
关闭防火墙:
[root@gitlab ~]# systemctl stop firewalld.service
[root@gitlab ~]# iptables -F

设置防火墙:
[root@gitlab ~]# firewall-cmd --permanent --add-service=http
[root@gitlab ~]# systemctl reload firewalld
测试

使用浏览器访问服务器IP(http://192.168.192.131)

Gitlab--安装及汉化第2张

出现上面的web界面说明安装成功了

但是竟然是英文的,对英文好的朋友当然最喜欢了,可是我这英语呆很苦恼呀,还好有汉化的方法,预知汉化如何,请看下面,哈哈。。。。。。

汉化

说明:gitlab中文社区版的项目,v7-v8.8是由Larry Li发起的"GitLab 中文社区版项目"(https://gitlab.com/larryli/gitlab)
    从 v8.9之后,@xhang开始继续该汉化项目(https://gitlab.com/xhang/gitlab)

具体汉化方式:

1) 停止gitlab服务
[root@gitlab ~]# gitlab-ctl stop

2) 安装git命令(有的可以不在次安装)
[root@gitlab ~]# yum -y install git

3) git clone 汉化包并打补丁
[root@gitlab ~]# git clone https://gitlab.com/xhang/gitlab.git

这里下载的速度会出现很慢的情况,下面提供了百度云盘的下载
百度云下载地址: https://pan.baidu.com/s/1DVZXrfH08JRYNuBw6zvLJQ (永久有效,如果链接失效可以联系我)
在百度云上下载后,上传到服务器上然后解压在执行下面的命令

[root@gitlab ~]# cd gitlab

# 比较汉化标签和原标签,导出 patch 用的 diff 文件到/root下 
[root@gitlab gitlab]# git diff v11.5.6 v11.5.6-zh > ../11.5.6-zh.diff

# 将11.5.6-zh.diff作为补丁更新到gitlab中 
# 这里需要用到patch命令,需要安装一下
[root@gitlab gitlab]# yum -y install patch
[root@gitlab gitlab]# patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < /root/11.5.6-zh.diff

温馨提示: 这里回车后,会提示是否要覆盖文件,一路回车就行

# 启动gitlab
[root@gitlab ~]# gitlab-ctl start

温馨提示: 启动后稍等1-2分钟在访问web,不然会出现502的错误

502错误如下图:

Gitlab--安装及汉化第3张

查看是否汉化成功了:

Gitlab--安装及汉化第4张

免责声明:文章转载自《Gitlab--安装及汉化》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇双token刷新、续期,access_token和refresh_token实效如何设置学习HTML5获取地理位置定位信息--(通过百度地图API,google地图API的两种方式)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

OneCloud记录

配置信息 S805, 1G RAM, 8G ROM, USB2.0 * 2, 1GB LAN, SD Cardreader S805参数: 32-bit, ARMv7-A, Cortex-A5, 1.5GHz 4核. 这个不是64位的CPU. 原生玩客云刷机的步骤 因为玩客云原生系统uboot无法输入命令,且启动后TTL终端需要用户登录, 所以需要先将带u...

Systemd日志管理服务:Journald以及重要配置选项

Journald是systemd引入的用于收集和存储日志数据的系统服务。它试图使系统管理员可以在越来越多的日志消息中更轻松地找到有趣且相关的信息。为了实现此目标,日记中的主要更改之一是用为日志消息优化的特殊文件格式替换简单的纯文本日志文件。这种文件格式使系统管理员可以更有效地访问相关消息。它还为单个系统带来了数据库驱动的集中日志记录实现的某些功能。 概览s...

Linux 下使用acme.sh生成Let's Encrypt泛域名免费证书

一、需求场景 自从数年前苹果开始强制要求所有IOS所有应用必须全部使用 https,以及google、baidu、bing 这三大搜索引擎开始大规模支持 https,https 已经成为现在保障网站完全的最基础需求,大量的供应商开始出现,并提供证书服务,但是对于一些非盈利性质的网站或博客站长,或公司测试环境也想使用https认证时,并不想在这上面投入太多的...

Kubernetes 多集群在开源项目 KubeSphere 的应用

Kubernetes 多集群使用场景 随着容器的普及和 Kubernetes 的日渐成熟,企业内部运行多个 Kubernetes 集群已变得颇为常见。概括起来,多个集群的使用场景主要有以下几种。 多集群使用场景 高可用 可以将业务负载分布在多个集群上,使用一个全局的 VIP 或者 DNS 域名将请求发送到对应的后端集群,当一个集群发生故障无法处理请求时,将...

log4cpp 配置 与 使用

1. 基本概念 categories 日志的层级体系 appenders 日志打印到什么地方,可以是文件,也可以是终端 layouts 日志输出格式,定义类似于printf中的输出方式。有三种,后面都有例子,这三种分别是:basic,simple,pattern priority 日志的级别,所有的级别有:EMERG、FATAL、ALERT、CRIT、ER...

25 个 Linux 下最炫酷又强大的命令行神器

众所周知,我们在 Linux 下大多数时候是使用命令行来处理任务的。这样不但操作起来效率比较高,而且界面也比较炫酷。下面,我们就给大家推荐一些不但炫酷又好用的 Linux 命令行神器。 1. exa exa 是一个用来替代 ls 的工具, exa 相比于 ls 增加了很多新的特性,比如:支持不同文件类型可以用不同颜色来展示、exa 比 ls 速度更快一些...