GitLab私服搭建及使用实践

GitLab私服搭建及使用实践

一 、 环境

  1. CentOS 7
  2. 内存配置4G (官方要求2G , 但是2G 经常会出现502问题 )

二、 gitlab 私服搭建

  1. 安装依赖的openssh-server

    1. 执行: yum install curl policycoreutils openssh-server openssh-clients
    2. openssh-server的功能主要是作为一个服务运行在后台,如果这个服务开启,我们就可以用一些远程连接工具来连接centos。因为minimal版本自带openssh-server,所以XShell可以连上centos
    3. openssh-client的功能我觉得类似于XShell,可以作为一个客户端连接上openssh-server,但是Centos6.4的minimal版本不包括openssh-client,所以centos之前出现无法使用ssh登录的情况,centos可以使用如下命令安装客户端:

      安装wget
      yum -y install wget
      
      安装openssh-client
      yum install openssh-clients
      
  2. 打开http和ssh 访问
    1. systemctl enable sshd
    2. systemctl start sshd
  3. 安装 postfix
    1. 执行: yum install postfix
    2. 这是一个邮箱服务
  4. 开启邮箱服务访问:
    1. systemctl enable postfix
    2. systemctl start postfix
  5. 打开http 和ssh访问
    1. systemctl enable sshd
    2. systemctl start sshd
    3. systemctl enable postfix
    4. systemctl start postfix
    5. firewall-cmd –permanent –add-service=http
    6. systemctl reload firewalld
  6. 添加清华镜像地址 , 下载并安装gitlab

    1. /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
      
    2. 执行yum makecache
    3. yum install gitlab-ce
  7. 配置并启动gitlab
    1. gitlab-ctl reconfigure

三、 gitlab使用

  1. 输入服务区IP地址并登陆
    1. 首次登陆时 , 需要设置密码 , 用户名默认为root
  2. 常用的gitlab命令:
    1. 重新加载配置并启动:
      1. sudo gitlab-ctl reconfigure
    2. 重启gitlab
      1. sudo gitlab-ctl restart
    3. 查看gitlab运行状态:
      1. sudo gitlab-ctl status
    4. 停止gitlab服务:
      1. sudo gitlab-ctl stop
    5. 查看gitlab运行日志:
      1. sudo gitlab-ctl tail
    6. 停止相关数据连接服务:
      1. gitlab-ctl stop unicorn
      2. gitlab-ctl stop sidekiq
  3. 创建新项目
    1. 登录gitlab之后 , 点击导航条右侧的“+” 就可以进入创建项目的页面
    2. 按照要求填写项目名称 , 项目可见性等信息 。

四、 遇到的问题与解决

  1. 访问gitlab时出现502
    1. 端口被占用
    2. 主机内存不足 (最好使用4G内存的主机)

原地址: https://blog.csdn.net/ouyang_peng/article/details/72903221

猜你喜欢

转载自blog.csdn.net/chou_out_man/article/details/80664524