GitLab安装及使用

GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的Web服务。

安装GitLab

  1. 下载GitLab的rpm文件

    版本信息:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

     #下载对应的rpm文件
     wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-9.5.2-ce.0.el7.x86_64.rpm
    
  2. rpm方式安装

     #rpm方式安装gitlab
     rpm -hvi gitlab-ce-9.5.2-ce.0.el7.x86_64.rpm
    

    在这里插入图片描述

  3. 修改GitLab端口,配置文件在/etc/gitlab/目录下的gitlab.rb文件

     #修改配置文件,将external_url 'http://iZm5ef38095rhuzz3nhcfnZ',改成本机的ip和访问gitlab的端口
    #时区改成中国 gitlab_rails['time_zone'] = 'Asia/Shanghai'
     vi /etc/gitlab/gitlab.rb
    
  4. 生成配置

    #加载配置文件,时间有点久需要等一会,如果一直卡住不动退出Ctrl+C,先执行:systemctl restart gitlab-runsvdir
    gitlab-ctl reconfigure
    
  5. 重启GitLab,确保配置的端口已开放

    #重启
    gitlab-ctl restart
    
  6. 访问配置的端口,默认用户root,第一次强制设置密码

    在这里插入图片描述

GitLab命令

  • 查看服务状态

    gitlab-ctl status
    
  • 启动GitLab

    gitlab-ctl start
    
  • 停止

    gitlab-ctl stop
    
  • 重启

    gitlab-ctl restart
    
  • 生成配置并启动服务

    gitlab-ctl reconfigure
    
  • 查看版本

    cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
    
  • 实时查看日志

    gitlab-ctl tail
    

卸载GitLab

  1. 停止GitLab

     #停止GitLab
     gitlab stop
    
  2. 卸载GitLab

    #卸载GitLab
    rpm -e gitlab-ce
    
  3. 查看GitLab相关进程

    [root@iZm5ef38095rhuzz3nhcfnZ ~]# ps -ef|grep gitlab
    root     16681     1  0 3月29 ?       00:00:00 runsvdir -P /opt/gitlab/service log: ...........................................................................................................................................................................................................................................................................................................................................................................................................
    root     16683 16682  0 3月29 ?       00:00:00 svlogd -tt /var/log/gitlab/redis
    root     17613 17612  0 3月29 ?       00:00:00 svlogd -tt /var/log/gitlab/postgresql
    root     18528 18527  0 3月29 ?       00:00:00 svlogd -tt /var/log/gitlab/unicorn
    root     18667 18664  0 3月29 ?       00:00:00 svlogd -tt /var/log/gitlab/sidekiq
    root     18776 18775  0 3月29 ?       00:00:00 svlogd -tt /var/log/gitlab/gitaly
    root     18884 16681  0 3月29 ?       00:00:00 runsv gitlab-workhorse
    root     18885 18884  0 3月29 ?       00:00:00 svlogd -tt /var/log/gitlab/gitlab-workhorse
    root     19027 19026  0 3月29 ?       00:00:00 svlogd -tt /var/log/gitlab/nginx
    root     19138 19137  0 3月29 ?       00:00:00 svlogd -tt /var/log/gitlab/logrotate
    root     19255 19254  0 3月29 ?       00:00:00 svlogd -tt /var/log/gitlab/node-exporter
    root     19379 16681  0 3月29 ?       00:00:00 runsv gitlab-monitor
    root     19380 19379  0 3月29 ?       00:00:00 svlogd -tt /var/log/gitlab/gitlab-monitor
    root     19480 19479  0 3月29 ?       00:00:00 svlogd -tt /var/log/gitlab/redis-exporter
    root     19594 19590  0 3月29 ?       00:00:00 svlogd -tt /var/log/gitlab/prometheus
    root     19767 19766  0 3月29 ?       00:00:00 svlogd -tt /var/log/gitlab/postgres-exporter
    root     31698 12459  0 10:59 pts/0    00:00:00 grep --color=auto gitlab
    
  4. 杀掉一堆点(…)的进程

    [root@iZm5ef38095rhuzz3nhcfnZ ~]# kill -9 16681
    [root@iZm5ef38095rhuzz3nhcfnZ ~]# ps -ef|grep gitlab
    root     31890 12459  0 11:02 pts/0    00:00:00 grep --color=auto gitlab
    
  5. 查找GitLab相关的目录删掉(删想删的)

    #查找
    find / -name gitlab
    #查找到直接强制删除
    find / -name gitlab | xargs rm -rf
    

上传代码测试

  1. 添加本地git的公钥

    在这里插入图片描述

  2. 创建空项目

在这里插入图片描述

  1. 本地git上传

    $ git init
    $ git add .
    $ git commit -m '提交'
    $ git remote add origin http://118.190.201.101:81/root/project_test.git
    $ git push origin master
    Username for 'http://118.190.201.101:81': root
    Enumerating objects: 11, done.
    Counting objects: 100% (11/11), done.
    Delta compression using up to 4 threads
    Compressing objects: 100% (10/10), done.
    Writing objects: 100% (11/11), 3.55 KiB | 1.77 MiB/s, done.
    Total 11 (delta 0), reused 0 (delta 0)
    To http://118.190.201.101:81/root/project_test.git
     * [new branch]      master -> master
    
    

在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值