【12.25】代码管理平台 gitlab

為{幸葍}努か 提交于 2019-12-26 09:54:07

22.14/22.15 安装gitlab

gitlab 官网 https://about.gitlab.com/gitlab-com/
官方安装文档:https://about.gitlab.com/install/#centos-7
要求服务器内存不少于2g,否则会卡死
1、创建 gitlab 的安装源

[root@arslinux-01 ~]# vim /etc/yum.repos.d/gitlab.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1

2、安装 gitlab

[root@arslinux-01 ~]# yum install -y gitlab-ce

3、自动配置 gitlab

[root@arslinux-01 ~]# gitlab-ctl reconfigure
[root@arslinux-01 ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 192.168.194.130:27017   0.0.0.0:*               LISTEN      7504/mongod         
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN      7504/mongod         
tcp        0      0 127.0.0.1:9100          0.0.0.0:*               LISTEN      14204/node_exporter 
tcp        0      0 127.0.0.1:9229          0.0.0.0:*               LISTEN      14189/gitlab-workho 
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 127.0.0.1:9168          0.0.0.0:*               LISTEN      14222/puma 3.12.0 ( 
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      12872/unicorn maste 
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      12951/nginx: master 
tcp        0      0 0.0.0.0:20048           0.0.0.0:*               LISTEN      7332/rpc.mountd     
tcp        0      0 0.0.0.0:37361           0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:8082          0.0.0.0:*               LISTEN      12888/sidekiq 5.2.7 
tcp        0      0 127.0.0.1:9236          0.0.0.0:*               LISTEN      14209/gitaly        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      7242/sshd           
tcp        0      0 127.0.0.1:3000          0.0.0.0:*               LISTEN      15042/grafana-serve 
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      7675/master         
tcp        0      0 0.0.0.0:8060            0.0.0.0:*               LISTEN      12951/nginx: master 
tcp        0      0 0.0.0.0:35038           0.0.0.0:*               LISTEN      7265/rpc.statd      
tcp        0      0 127.0.0.1:9121          0.0.0.0:*               LISTEN      14233/redis_exporte 
tcp        0      0 0.0.0.0:2049            0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:9090          0.0.0.0:*               LISTEN      14240/prometheus    
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      7256/zabbix_agentd  
tcp        0      0 127.0.0.1:9187          0.0.0.0:*               LISTEN      14284/postgres_expo 
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      7330/zabbix_server  
tcp        0      0 127.0.0.1:9093          0.0.0.0:*               LISTEN      14275/alertmanager  
tcp6       0      0 :::3306                 :::*                    LISTEN      7579/mysqld         
tcp6       0      0 :::33836                :::*                    LISTEN      -                   
tcp6       0      0 :::53101                :::*                    LISTEN      7265/rpc.statd      
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 ::1:9168                :::*                    LISTEN      14222/puma 3.12.0 ( 
tcp6       0      0 :::20048                :::*                    LISTEN      7332/rpc.mountd     
tcp6       0      0 :::22                   :::*                    LISTEN      7242/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      7675/master         
tcp6       0      0 :::2049                 :::*                    LISTEN      -                   
tcp6       0      0 :::10050                :::*                    LISTEN      7256/zabbix_agentd  
tcp6       0      0 :::10051                :::*                    LISTEN      7330/zabbix_server  
tcp6       0      0 :::10052                :::*                    LISTEN      7264/java           
tcp6       0      0 :::9094                 :::*                    LISTEN      14275/alertmanager 

4、关闭 gitlab,可以看到 gitlab 相关服务

[root@arslinux-01 ~]# gitlab-ctl stop
ok: down: alertmanager: 0s, normally up
ok: down: gitaly: 0s, normally up
ok: down: gitlab-monitor: 0s, normally up
ok: down: gitlab-workhorse: 1s, normally up
ok: down: grafana: 0s, normally up
ok: down: logrotate: 1s, normally up
ok: down: nginx: 0s, normally up
ok: down: node-exporter: 0s, normally up
ok: down: postgres-exporter: 1s, normally up
ok: down: postgresql: 0s, normally up
ok: down: prometheus: 1s, normally up
ok: down: redis: 0s, normally up
ok: down: redis-exporter: 1s, normally up
ok: down: sidekiq: 0s, normally up
ok: down: unicorn: 1s, normally up

5、停止本地之前安装的 nginx 服务,redis-server

[root@arslinux-01 ~]# /etc/init.d/nginx stop
Stopping nginx (via systemctl):                            [  确定  ]
[root@arslinux-01 ~]# chkconfig nginx off
[root@arslinux-01 ~]# killall redis-server
6、启动 gitlab(gitlab-ctl stop/restart/start/status)
[root@arslinux-01 ~]# gitlab-ctl start
ok: run: alertmanager: (pid 15894) 1s
ok: run: gitaly: (pid 15905) 0s
ok: run: gitlab-monitor: (pid 15923) 1s
ok: run: gitlab-workhorse: (pid 15925) 0s
ok: run: grafana: (pid 15932) 1s
ok: run: logrotate: (pid 15938) 0s
ok: run: nginx: (pid 15946) 1s
ok: run: node-exporter: (pid 15951) 0s
ok: run: postgres-exporter: (pid 15955) 1s
ok: run: postgresql: (pid 15960) 0s
ok: run: prometheus: (pid 15962) 1s
ok: run: redis: (pid 15976) 0s
ok: run: redis-exporter: (pid 15981) 1s
ok: run: sidekiq: (pid 15986) 0s
ok: run: unicorn: (pid 15992) 0s

7、网页访问 gitlab,只要输入 ip 地址即可
如果出现 502 错误,那么请检查内存是否过小,一般不小于 4G
在这里插入图片描述
在这里插入图片描述

22.16 使用gitlab

gitlab常用命令:https://www.cnyunwei.cc/archives/1204
进入 gitlab,先创建组,再创建项目
1、创建组:
在这里插入图片描述
2、创建项目:
在这里插入图片描述
和 github 一样,需要添加 ssh key,才可以和 gitlab 通信
在这里插入图片描述
3、设置 ssh key
右上角头像——setting——SSH Keys
在这里插入图片描述
4、创建用户
顶部中间扳手图标(Admin Area)——New user
在这里插入图片描述
在这里插入图片描述
5、进入用户编辑,可以设定用户密码
在这里插入图片描述
在这里插入图片描述
6、退出,用新建的用户名密码登录,首次登录需要修改密码,可以设成和原来一样的密码,然后就可以创建项目了
在这里插入图片描述

22.17 gitlab备份和恢复

  • gitlab 备份
[root@arslinux-01 ~]# gitlab-rake gitlab:backup:create
  • 备份的文件默认会放到 /var/opt/gitlab/backups/ 下
[root@arslinux-01 ~]# ls /var/opt/gitlab/backups/
1564299157_2019_07_28_12.1.1_gitlab_backup.tar
[root@arslinux-01 ~]# du -sh /var/opt/gitlab/backups/1564299157_2019_07_28_12.1.1_gitlab_backup.tar 
132K	/var/opt/gitlab/backups/1564299157_2019_07_28_12.1.1_gitlab_backup.tar
  • gitlab 恢复
    1)暂停 unicorn、sidekiq 服务
[root@arslinux-01 ~]# gitlab-ctl stop unicorn ; gitlab-ctl stop sidekiq

2)恢复 gitlab-rake gitlab:backup:restore BACKUP=xxxxx (这里是一个编号,即备份文件的前缀)

[root@arslinux-01 ~]# gitlab-rake gitlab:backup:restore BACKUP=1564299157_2019_07_28_12.1.1
  • 再启动服务 gitlab-ctl start

扩展内容:
同学分享的svn文档 http://note.youdao.com/noteshare?id=1bb87a28a2973ae5722bf765882c2d8f

svn 多仓库管理 http://elim.iteye.com/blog/1171108

svn+ssh http://www.linuxfly.org/post/450/

svn清除保存的用户名和密码 http://holy2010.blog.51cto.com/1086044/645944

svn命令详解 http://blog.sina.com.cn/s/blog_963453200101eiuq.html

svn的钩子 http://coolnull.com/1716.html

gitlab修改端口 http://blog.csdn.net/arybd/article/details/54635295

修改主机名 http://www.mamicode.com/info-detail-1316828.html

第三方邮件http://blog.csdn.net/liuruiqun/article/details/50000213

server ssh 端口并不是22 http://www.cnblogs.com/limx/p/5709101.html http://www.linuxidc.com/Linux/2017-02/141043.htm

应该修改 /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
“# If you use non-standard ssh port you need to specify it”
ssh_port: xxxxx

gitlab的钩子相关配置http://fighter.blog.51cto.com/1318618/1670667

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!