GitLab私服搭建及使用实践
一 、 环境
- CentOS 7
- 内存配置4G (官方要求2G , 但是2G 经常会出现502问题 )
二、 gitlab 私服搭建
安装依赖的openssh-server
- 执行: yum install curl policycoreutils openssh-server openssh-clients
- openssh-server的功能主要是作为一个服务运行在后台,如果这个服务开启,我们就可以用一些远程连接工具来连接centos。因为minimal版本自带openssh-server,所以XShell可以连上centos
openssh-client的功能我觉得类似于XShell,可以作为一个客户端连接上openssh-server,但是Centos6.4的minimal版本不包括openssh-client,所以centos之前出现无法使用ssh登录的情况,centos可以使用如下命令安装客户端:
安装wget yum -y install wget 安装openssh-client yum install openssh-clients
- 打开http和ssh 访问
- systemctl enable sshd
- systemctl start sshd
- 安装 postfix
- 执行: yum install postfix
- 这是一个邮箱服务
- 开启邮箱服务访问:
- systemctl enable postfix
- systemctl start postfix
- 打开http 和ssh访问
- systemctl enable sshd
- systemctl start sshd
- systemctl enable postfix
- systemctl start postfix
- firewall-cmd –permanent –add-service=http
- systemctl reload firewalld
添加清华镜像地址 , 下载并安装gitlab
/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
- 执行yum makecache
- yum install gitlab-ce
- 配置并启动gitlab
- gitlab-ctl reconfigure
三、 gitlab使用
- 输入服务区IP地址并登陆
- 首次登陆时 , 需要设置密码 , 用户名默认为root
- 常用的gitlab命令:
- 重新加载配置并启动:
- sudo gitlab-ctl reconfigure
- 重启gitlab
- sudo gitlab-ctl restart
- 查看gitlab运行状态:
- sudo gitlab-ctl status
- 停止gitlab服务:
- sudo gitlab-ctl stop
- 查看gitlab运行日志:
- sudo gitlab-ctl tail
- 停止相关数据连接服务:
- gitlab-ctl stop unicorn
- gitlab-ctl stop sidekiq
- 重新加载配置并启动:
- 创建新项目
- 登录gitlab之后 , 点击导航条右侧的“+” 就可以进入创建项目的页面
- 按照要求填写项目名称 , 项目可见性等信息 。
四、 遇到的问题与解决
- 访问gitlab时出现502
- 端口被占用
- 主机内存不足 (最好使用4G内存的主机)
原地址: https://blog.csdn.net/ouyang_peng/article/details/72903221