【1225】代码管理平台gitlab
22.14/22.15 安装gitlab
22.16 使用gitlab
22.17 gitlab备份和恢复
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
4、关闭 gitlab,可以看到 gitlab 相关服务
[root@arslinux-01 ~]# gitlab-ctl stop
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
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
1
备份的文件默认会放到 /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
1
2)恢复 gitlab-rake gitlab:backup:restore BACKUP=xxxxx (这里是一个编号,即备份文件的前缀)
[root@arslinux-01 ~]# gitlab-rake gitlab:backup:restore BACKUP=1564299157_2019_07_28_12.1.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