gitlab简介配置和参数修改

一、Gitlab基本简介

GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,可通过Web界面进行访问公开的或者私人项目,非常适合在团队内部使用。

在gitlab中有三个版本,分别是CE(社区版)、EE(企业版)、OM(RPM包完整版,里面包括nginx、redis等其它软件,比较大)。这里的编译安装版,是指CE版的源码安装,官网https://docs.gitlab.com/。

二、Gitlab(Github)与git

Gitlab和Git是两回事。Git是版本控制系统,Github是在线的基于Git的代码托管服务

Gitlab提供的功能

代码托管服务

访问权限控制

问题跟踪,bug的记录和讨论

代码审查,可以查看、评论代码

社区版基于 MIT License开源完全免费

Gitlab Community Edition 镜像使用帮助文档:https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/

三、Gitlab安装

1、环境要求

#CPU

1核心的CPU,基本上可以满足需求,大概支撑100个左右的用户,不过在运行GitLab网站的同时,还需要运行多个worker以及后台job,显得有点捉襟见肘了。

两核心的CPU是推荐的配置,大概能支撑500个用户.

4核心的CPU能支撑 2,000 个用户.

8核心的CPU能支撑 5,000 个用户

#memory

你需要至少4GB的可寻址内存(RAM交换)来安装和使用GitLab!操作系统和任何其他正在运行的应用程序也将使用内存,因此请记住,在运行GitLab之前,您至少需要4GB的可用空间。使用更少的内存GitLab将在重新配置运行期间给出奇怪的错误,并在使用过程中发生500个错误.

1GBRAM + 3GB of swap is the absolute minimum but we strongly adviseagainst this amount of memory. See the unicorn worker section belowfor more advice.

2GBRAM + 2GB swap supports up to 100 users but it will be very slow

4GBRAM isthe recommended memory size for all installations and supportsup to 100 users

#Database 

PostgreSQL ,MySQL/MariaDB

强烈推荐使用PostgreSQL而不是MySQL/ MariaDB,因为GitLab的所有功能都不能与MySQL/ MariaDB一起使用。例如,MySQL没有正确的功能来以有效的方式支持嵌套组.

运行数据库的服务器应至少有5-10 GB的可用存储空间,尽管具体要求取决于GitLab安装的大小

#Node exporter

节点导出器允许您测量各种机器资源,如内存,磁盘和CPU利用率。默认端口9100

2、安装

1) 关闭selinux和相关基本配置

#下面的命令实现永久关闭SELinux(/etc/selinux/config)需要重启系统之后生效
第7行 SELINUX=permissive
#下面的命令实现临时关闭SELinux
[root@git ~]# getenforce     #查看selinux状态
[root@git ~]# setenforce 0/1  #切换selinux状态
#永久修改下主机名,需要重启系统之后生效
Redhat7中修改
[root@noede1 ~]# vi /etc/hostname
gitlab.server.com
#添加域名
[root@git ~]#cat /etc/hosts
192.168.201.131   gitlab.server.com
2) 关闭防火墙
Redhat6
[root@git yum.repos.d]# iptables -F              #临时关闭
[root@git yum.repos.d]# service iptables stop    #关闭防火墙服务
[root@git yum.repos.d]# chkconfig iptables off   #禁用防火墙
[root@git yum.repos.d]# chkconfig iptables --list

Redhat7
systemctl stop firewalld.service
也可以这样:systemctl enable sshd
      systemctl start sshd
      firewall-cmd -permanet -add-service=http
      systemctl reload firewalld

3)gitlab有两种安装方式,一种yum安装,一种rpm安装

yum安装

 
[root@git yum.repos.d]# vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key
如果想要在centos6系列上安装,只需把el7修改成el6

更新本地yum缓存
yum makecache
 Gitlab安装方式
yum install -y curl policycoreutils-python openssh-server openssh-clients
yum install –y gitlab-ce
###也可以指定版本号 例如:yum install –y gilab-ce-10.3.3
rpm包安装(此处采用RPM包安装)
优点:安装过程简单,安装速度快。采用rpm包安装方式,安装的软件包便于管理。
缺点:数据库默认采用PostgreSQL,服务器默认采用Nginx,不容易定制
可以单独下载rpm包http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/ rpm -ivh gitlab-ce-8.8.0-ce.0.el6.x86_64.rpm rpm 安装Gitlab的默认位置在/opt下
4)  修改配置文件,GitLab默认会占用8080809090端口,很不巧,Jenkins默认也会使用8080端口,所以,这一步操作将会修改GitLab的默认端口为110001100111002,如果你还是希望使用默认端口的话,可以跳过这一步
vim  /etc/gitlab/gitlab.rb
external_url='http://gitlab.server.com'
external_ur=‘修改成自己的ip或者域名’
external_url 'http://<你的服务器地址或域名>:11000'

  # unicorn['port'] = 8080 ----> unicorn['port'] = 11001
  #prometheus['listen_address'] = 'localhost:9090' ---> prometheus['listen_address'] = 'localhost:11002'
本次配置中在/etc/hosts定义了域名为gitlab.service.com
#修改配置文件之后,需要重新启动配置文件使之生效。
gitlab-ctl reconfigure
6)  启动Gitlab服务
#启动服务
# gitlab-ctl start
#停止服务
# gitlab-ctl stop
#重启服务
# gitlab-ctl restart
#状态
#gitlab-ctl status
#监控
#gitlab-ctl  tailunicorn 监控unicorn日志
#gitlab-ctl  tail
7)  登陆gitlab
访问地址http://ip
由于第一次登陆,需要设置密码(这里的密码是管理员密码,管理员账号是root)
8)  Gitlab命令使用
start                启动所有服务
stop                关闭所有服务
restart            重启所有服务
status             查看所有服务状态
tail               查看日志信息
service-list        列举所有启动服务
graceful-kill      平稳停止一个服务
reconfigure       修改配置文件后需要重新加载
show-config            查看所有服务配置文件信息
uninstall           卸载这个软件
cleanse          删除gitlab数据
Gitlab配置详解
gitlab配置文件    /etc/gitlab/gitlab.rb
unicorn配置文件       /var/opt/gitlab/gitlab-rails/etc/unicorn.rb
nginx配置文件    /var/opt/gitlab/nginx/conf/gitlab-http.conf
gitlab仓库默认位置    /var/opt/gitlab/git-data/repositories

四、卸载Gitlab

停止gitlab
Gitlab-ctl stop

查看Gitlab 安装包
rpm –qa | grep gitlab

删除gitlab
rpm –e gitlab-ce

查看gitlab 进程
ps aux | grep gitlab

杀掉所有gitlab 进程
Kill –9  进程号

删除所有包含gitlab文件
find / -name | grep gitlab rm -rf

五、中文版安装

#Yum 安装gitlab10.3.3
yum -y localinstall https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.3.3-ce.0.el7.x86_64.rpm

 vim /etc/gitlab/gitlab.rb

 gitlab-ctl reconfigure  
# 清空缓存
gitlab-rake cache:clear RAILS_ENV=production
#从新启动gitlab
gitlab-ctl restart
#查看gitlab版本
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
#克隆 GitLab.com 仓库
git clone https://gitlab.com/xhang/gitlab.git
cd gitlab/
#查看对应的汉化版本号
git tag
#对比不同,这里比较的是tag,v9.2.6为英文原版,v9.2.6-zh为汉化版本。diff结果是汉化补丁。
git diff v10.3.3..v10.3.3-zh > /tmp/10.3.3.diff
#停止gitlab
gitlab-ctl stop

#应用汉化补丁
cd /opt/gitlab/embedded/service/gitlab-rails
git apply /tmp/10.3.3.diff
gitlab-ctl start
gitlab-ctl reconfigure
gitlab-ctl start

转载于:https://www.cnblogs.com/fengzhongzhuzu/p/9203706.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值