GitLab EE 企业版
GitLab CE 社区版
gitlab跑起来将近需要6G的内存,我这里是8G内存。
[root@gitlab ~]# free -m
total used free shared buff/cache available
Mem: 7933 3411 245 165 4275 4059
Swap: 0 0 0
yum install gitlab-ce # 自动安装最新版
yum install gitlab-ce-x.x.x # 安装指定版本
#配置yum源
[root@GitLab ~]# vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=gitlab-ce
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
gpgcheck=0
Repo_gpgcheck=0
Enabled=1
Gpgkey=https://packages.gitlab.com/gpg.key
[root@GitLab ~]# yum -y install gitlab-ce
#设置gitlab访问地址
vim /etc/gitlab/gitlab.rb
external_url 'http://IP地址'
#启动服务
[root@GitLab ~]# gitlab-ctl reconfigure
可以自己下载rpm软件包
地址:gitlab/gitlab-ce - Packages · packages.gitlab.com
选择自己所需要的版本下载即可
[root@gitlab ~]# ls
anaconda-ks.cfg gitlab-ce-16.3.0-ce.0.el8.x86_64.rpm
[root@gitlab ~]# yum -y localinstall gitlab-ce-16.3.0-ce.0.el8.x86_64.rpm
#重载GitLab配置
[root@GitLab ~]# gitlab-ctl reconfigure
...
Running handlers:
Running handlers complete
Chef Client finished, 527/1423 resources updated in 02 minutes 05 seconds
gitlab Reconfigured!
[root@GitLab ~]#
#重启GitLab相关服务
[root@GitLab ~]# gitlab-ctl restart
ok: run: alertmanager: (pid 1975) 0s //报警服务
ok: run: gitaly: (pid 1986) 1s //Git后台服务
ok: run: gitlab-exporter: (pid 2014) 0s //Prometheus数据采集器
ok: run: gitlab-workhorse: (pid 2020) 1s //反向代理服务器
ok: run: grafana: (pid 2117) 0s //数据可视化服务
ok: run: logrotate: (pid 2129) 0s //日志文件管理服务
ok: run: nginx: (pid 2135) 1s //静态WEB服务
ok: run: node-exporter: (pid 2142) 0s //Prometheus数据采集器
ok: run: postgres-exporter: (pid 2148) 1s //Prometheus数据采集器
ok: run: postgresql: (pid 2159) 0s //数据库服务
ok: run: prometheus: (pid 2168) 0s //Prometheus监控服务
ok: run: redis: (pid 2178) 1s //缓存数据库服务
ok: run: redis-exporter: (pid 2183) 0s //Prometheus数据采集器
ok: run: sidekiq: (pid 2192) 0s //异步执行队列服务
ok: run: unicorn: (pid 2203) 0s //Rails托管WEB服务
[root@GitLab ~]#
#GitLab主机确认80端口被监听
[root@GitLab ~]# ss -anptul | grep :80
tcp LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=11166,fd=7),("nginx",pid=11165,fd=7),("nginx",pid=11164,fd=7))
[root@GitLab ~]#
http://192.168.88.10/
/etc/gitlab/initial_root_password
[root@gitlab ~]# cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
# 2. Password hasn't been changed manually, either via UI or via command line.
#
# If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
Password: cOwvdeyObLDMYKhP0djI0G3PyGm2DIIOZQfPyZHF68I=
# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
登录后展示GitLab仪表盘,此时页面为英文,可以通过用户偏好设置对页面进行汉化
修改完保存后刷新页面即可
然后设置自己的密码,重新登陆即可
设置密码
回到管理员账户,查看用户数量
查看最新的用户
用户创建成功 !!!
填写组名为devops,URL路径自动生成,群组描述信息选填,可见性级别选择公开,方便后续操作
向群组中添加组成员
组创建成功 !!!
点击右侧克隆按钮,弹框中提示项目地址
上方有SSH公钥设置提醒
下方有命令提示,可以参考命令关联客户端与服务器
#参考提示命令"推送已有Git仓库部分"
[root@Programer ~]# cd myproject/
[root@Programer myproject]# git remote -v #查看远程仓库关联信息
[root@Programer myproject]# git remote add origin [email protected]:develop/myproject.git #关联远程项目
[root@Programer myproject]# git remote -v #查看远程想看关联信息
origin [email protected]:develop/myproject.git (fetch)
origin [email protected]:develop/myproject.git (push)
配置免密登录
#设置免密登录
[root@localhost myproject]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:CR61sn5b2KvgcUb8QWioQDW2Fk/EMcP4RizylZMef+0 root@localhost
The key's randomart image is:
+---[RSA 3072]----+
| ..=**+. |
| ...o*@= o |
| .oo**++ .. |
| o.o+B.o. . |
| ..o S... |
| . . + .E |
| + = + |
| . * o . |
| . o.. |
+----[SHA256]-----+
[root@localhost myproject]# cd /root/.ssh/
[root@localhost .ssh]# ls
id_rsa id_rsa.pub
[root@localhost .ssh]# cat id_rsa.pub
复制内容
推送代码到远程仓库
[root@localhost myproject]# git push -u origin --all #推送本地仓库所有分支
The authenticity of host '192.168.88.10 (192.168.88.10)' can't be established.
ECDSA key fingerprint is SHA256:zyYH2If0hCtm/2CNkcPPNfK5zsJGNNezNdAO1MEyyTQ.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.88.10' (ECDSA) to the list of known hosts.
枚举对象: 6, 完成.
对象计数中: 100% (6/6), 完成.
压缩对象中: 100% (3/3), 完成.
写入对象中: 100% (6/6), 460 字节 | 460.00 KiB/s, 完成.
总共 6(差异 0),复用 0(差异 0),包复用 0
**********
#登录GitLab项目管理页面查看推送情况
确认分支推送情况
#Programer主机准备HIS代码
[root@Programer ~]# ls HIS.zip
HIS.zip
[root@Programer ~]# unzip HIS.zip #解压项目代码压缩包
[root@Programer ~]# ls HIS
HIS-BACKEND #HIS项目后端代码,SpringBoot框架编写
HIS-CONFIG #HIS项目后端程序运行配置文件
HIS-FONTEND #HIS项目前端代码(已编译)
HIS-FONTEND-DEPENDENCY #HIS项目前端代码编译依赖库(npm库)
HIS-FONTEND-SOURCECODE #HIS项目前端代码(未编译,VUE框架编写)
HIS-SQL #HIS项目数据库SQL文件
[root@Programer ~]#
#关联GitLab服务器HIS-BACKEND项目与Programer主机HIS-BACKEND代码
[root@Programer ~]# cd HIS/HIS-BACKEND/
[root@Programer HIS-BACKEND]# git init #初始化仓库
已初始化空的 Git 仓库于 /root/HIS/HIS-BACKEND/.git/
[root@Programer HIS-BACKEND]# git remote add origin [email protected]:develop/his-backend.git #关联本地与远程
[root@Programer HIS-BACKEND]# git remote -v
origin [email protected]:develop/his-backend.git (fetch)
origin [email protected]:develop/his-backend.git (push)
[root@Programer HIS-BACKEND]# git add ./ #添加代码到暂存区
[root@Programer HIS-BACKEND]# git commit -m "Init Backend Code" #提交本地版本库
[root@Programer HIS-BACKEND]# git tag v1 #创建v1标签
[root@Programer HIS-BACKEND]# git push -u origin --all #推送本地所有分支
枚举对象: 81, 完成.
对象计数中: 100% (81/81), 完成.
压缩对象中: 100% (81/81), 完成.
写入对象中: 100% (81/81), 2.91 MiB | 15.68 MiB/s, 完成.
总共 81(差异 16),复用 0(差异 0),包复用 0
remote:
remote: To create a merge request for master, visit:
remote: http://192.168.88.10/develop/his-backend/-/merge_requests/new?merge_request%5Bsource_branch%5D=master
remote:
To 192.168.88.10:develop/his-backend.git
* [new branch] master -> master
分支 'master' 设置为跟踪来自 'origin' 的远程分支 'master'。
[root@Programer HIS-BACKEND]# git push -u origin --tags #推送本地所有标签
总共 0(差异 0),复用 0(差异 0),包复用 0
To 192.168.88.10:develop/his-backend.git
* [new tag] v1 -> v1
[root@Programer HIS-BACKEND]#
后端代码提交成功 !!!
#关联GitLab服务器HIS-FONTEND项目与Programer主机HIS-FONTEND代码
[root@Programer HIS-BACKEND]# cd
[root@Programer ~]# cd HIS/HIS-FONTEND
[root@Programer HIS-FONTEND]# git init #初始化仓库
已初始化空的 Git 仓库于 /root/HIS/HIS-FONTEND/.git/
[root@Programer HIS-FONTEND]# git remote add origin [email protected]:develop/his-backend.git #关联本地与远程
[root@Programer HIS-FONTEND]# git remote -v
origin [email protected]:develop/his-backend.git (fetch)
origin [email protected]:develop/his-backend.git (push)
[root@Programer HIS-FONTEND]# git add ./ #添加文件到暂存区
[root@Programer HIS-FONTEND]# git commit -m "Init Fontend Code" #提交到本地版本库
[root@Programer HIS-FONTEND]# git push -u origin --all #推送所有分支
枚举对象: 81, 完成.
对象计数中: 100% (81/81), 完成.
压缩对象中: 100% (81/81), 完成.
写入对象中: 100% (81/81), 2.91 MiB | 15.28 MiB/s, 完成.
总共 81(差异 16),复用 0(差异 0),包复用 0
remote:
remote: To create a merge request for master, visit:
remote: http://192.168.88.10/develop/his-backend/-/merge_requests/new?merge_request%5Bsource_branch%5D=master
remote:
To 192.168.88.10:develop/his-backend.git
* [new branch] master -> master
分支 'master' 设置为跟踪来自 'origin' 的远程分支 'master'。
[root@Programer HIS-FONTEND]#
前端代码提交成功 !!!