gitlab安装
- github是一个开放的代码管理平台,如果想只是一组人,一个群体私有使用需要收费;
- gitlab是一套软件,可自建在自己的服务器上,等于拥有了一个具有私有功能的github平台,可以一组人,一个群体私有的管理项目代码;
- group可以代表一个公司,里面可建项目,有人员,可把人员加到项目里;也可以有多个group;
- 需要内存4G或以上;
- 运行的服务器不建议跑其他服务;
- 官方安装方法如下;
[root@gitlab ~]# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash #下载yum库;
[root@gitlab ~]# EXTERNAL_URL="http://gitlab.yumeshoes.cn" yum install -y gitlab-ee #指定域名和yum安装;
[root@gitlab ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN 3113/grafana-server
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 2505/nginx: master
tcp 0 0 127.0.0.1:9121 0.0.0.0:* LISTEN 2986/redis_exporter
tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN 2999/prometheus
tcp 0 0 127.0.0.1:9187 0.0.0.0:* LISTEN 3104/postgres_expor
tcp 0 0 127.0.0.1:9093 0.0.0.0:* LISTEN 3093/alertmanager
tcp 0 0 127.0.0.1:9100 0.0.0.0:* LISTEN 2951/node_exporter
tcp 0 0 127.0.0.1:9229 0.0.0.0:* LISTEN 2943/gitlab-workhor
tcp 0 0 127.0.0.1:9168 0.0.0.0:* LISTEN 2975/puma 4.3.1.git
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 2447/unicorn master
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2505/nginx: master
tcp 0 0 127.0.0.1:8082 0.0.0.0:* LISTEN 2464/sidekiq 5.2.7
tcp 0 0 127.0.0.1:9236 0.0.0.0:* LISTEN 2962/gitaly
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1165/sshd
tcp6 0 0 :::9094 :::* LISTEN 3093/alertmanager
-
安装完成界面
-
登陆和修改密码
[root@gitlab ~]# ls /var/opt/gitlab/nginx/conf/ #配置文件;
gitlab-health.conf gitlab-http.conf nginx.conf nginx-status.conf
[root@gitlab ~]# vim /var/opt/gitlab/nginx/conf/gitlab-http.conf #虚拟主机配置文件,设置侦听端口和域名等;
-
新建组
-
创建项目
-
连接指引
-
命令行连接一个库,也是使用git命令,需要安装git
[root@draft ~]# git clone http://gitlab.yumeshoes.cn/tanylinux/gitlab3.git
正克隆到 'gitlab3'...
Username for 'http://gitlab.yumeshoes.cn': root
Password for 'http://root@gitlab.yumeshoes.cn':
warning: 您似乎克隆了一个空版本库。
[root@draft ~]# cd gitlab3/
[root@draft gitlab3]# ls
[root@draft gitlab3]#
-
上传ssh - 上传到当前帐号 - 使用ssh可clone帐号里的所有项目
-
Clone with SSH
[root@draft ~]# git clone git@gitlab.yumeshoes.cn:tanylinux/gitlab1.git
正克隆到 'gitlab1'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
接收对象中: 100% (3/3), done.
[root@draft ~]# ls gitlab1
README.md
-
左上角图标进入admin,可新增用户,可看目前状态
-
新建user - 填写Account部分 - Create user
-
admin里进入一个项目,右上角可设置一个项目的成员;也可以设置一个组的成员;
-
点击创建用户后,可点右上角设置其密码
-
使用新用户登陆,修改初始密码
-
在此用户身份下,可创建自己的组和项目,新建一个项目
- 新用户帐号下有两个项目,可在自己电脑上按github的操作连接,改动后上传到gitlab服务端
gitlab备份与恢复
- 服务运行中可备份
[root@gitlab ~]# gitlab-rake gitlab:backup:create
2019-12-26 13:54:20 +0800 -- Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
2019-12-26 13:54:21 +0800 -- done
2019-12-26 13:54:21 +0800 -- Dumping repositories ...
* tanylinux/gitlab1 (@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b) ... [DONE]
[SKIPPED] Wiki
* tanylinux/gitlab2 (@hashed/d4/73/d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35) ... [DONE]
[SKIPPED] Wiki
* tanylinux/gitlab3 (@hashed/4e/07/4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce) ... [SKIPPED]
[SKIPPED] Wiki
* e1/p1 (@hashed/4b/22/4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a) ... [SKIPPED]
[SKIPPED] Wiki
2019-12-26 13:54:22 +0800 -- done
2019-12-26 13:54:22 +0800 -- Dumping uploads ...
2019-12-26 13:54:22 +0800 -- done
2019-12-26 13:54:22 +0800 -- Dumping builds ...
2019-12-26 13:54:22 +0800 -- done
2019-12-26 13:54:22 +0800 -- Dumping artifacts ...
2019-12-26 13:54:22 +0800 -- done
2019-12-26 13:54:22 +0800 -- Dumping pages ...
2019-12-26 13:54:22 +0800 -- done
2019-12-26 13:54:22 +0800 -- Dumping lfs objects ...
2019-12-26 13:54:22 +0800 -- done
2019-12-26 13:54:22 +0800 -- Dumping container registry images ...
2019-12-26 13:54:22 +0800 -- [DISABLED]
Creating backup archive: 1577339662_2019_12_26_12.6.0-ee_gitlab_backup.tar ... done
Uploading backup archive to remote storage ... skipped
Deleting tmp directories ... done
done
done
done
done
done
done
done
Deleting old backups ... skipping
Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data
and are not included in this backup. You will need these files to restore a backup.
Please back them up manually.
Backup task is done.
[root@gitlab ~]# ls /var/opt/gitlab/backups/
1577339662_2019_12_26_12.6.0-ee_gitlab_backup.tar
- 恢复
[root@gitlab ~]# gitlab-ctl stop unicorn ; gitlab-ctl stop sidekiq
ok: down: unicorn: 1s, normally up
ok: down: sidekiq: 0s, normally up
[root@gitlab ~]# gitlab-rake gitlab:backup:restore BACKUP=1577339662_2019_12_26_12.6.0-ee #最后的字符串为备份文件名除去gitlab_backup.tar;
Unpacking backup ... done
Before restoring the database, we will remove all existing
tables to avoid future upgrade problems. Be aware that if you have
custom tables in the GitLab database these tables and all data will be
removed.
Do you want to continue (yes/no)? yes
...
gitlab修改默认端口
- https://blog.csdn.net/arybd/article/details/54635295
工序也不少
GitLab 修改主机名配置
- http://www.mamicode.com/info-detail-1316828.html
安装时想好域名就没这么麻烦,但是有变化时还是要做的;
GitLab 使用163邮箱发送邮件
- https://blog.csdn.net/liuruiqun/article/details/50000213
发邮件还需要稳定,邮箱还会检查客户端,可能担心是群发的机器,发信密度高可能就发不出
ssh-server服务在修改了端口的情况下,怎么git clone 代码
- https://www.cnblogs.com/limx/p/5709101.html
- ssh端口号码修改?
/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 WEB Hooks 配置
- https://blog.51cto.com/fighter/1670667
这里说明比上面清楚,挺有意思可以分解学习,php不会啊