ubuntu18.04手工部署gitlab实现CICD(一)

首先我们需要安装gitlab,现在官网下载最新的gitlab安装包,我们这次选择的手工下载

https://packages.gitlab.com/gitlab/gitlab-ce

具体下载地址

wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/bionic/gitlab-ce_14.1.1-ce.0_amd64.deb/download.deb

然后我们进行安装和配置

sudo dpkg -i gitlab-ce_14.1.1-ce.0_amd64.deb

gitlab这样就安装好了,但是我们还需要简单配置一下

sudo vim /etc/gitlab/gitlab.rb

找到

external_url 'http://gitlab.example.com'
#修改为
external_url ' # 192.168.122.66是我本机IP

再运行以下命令是配置生效

sudo gitlab-ctl reconfigure

然后我们可以看看gitlab是否已经启动

sudo gitlab-ctl status
run: alertmanager: (pid 17521) 10s; run: log: (pid 17195) 80s
run: gitaly: (pid 17410) 12s; run: log: (pid 16619) 190s
run: gitlab-exporter: (pid 17418) 12s; run: log: (pid 17011) 100s
run: gitlab-workhorse: (pid 17385) 13s; run: log: (pid 16906) 117s
run: grafana: (pid 17540) 9s; run: log: (pid 17344) 29s
run: logrotate: (pid 16427) 205s; run: log: (pid 16438) 204s
run: nginx: (pid 16940) 113s; run: log: (pid 16973) 110s
run: node-exporter: (pid 17398) 13s; run: log: (pid 16997) 104s
run: postgres-exporter: (pid 17532) 9s; run: log: (pid 17222) 74s
run: postgresql: (pid 16654) 187s; run: log: (pid 16672) 186s
run: prometheus: (pid 17503) 11s; run: log: (pid 17154) 88s
run: puma: (pid 16844) 131s; run: log: (pid 16851) 130s
run: redis: (pid 16460) 199s; run: log: (pid 16481) 196s
run: redis-exporter: (pid 17420) 12s; run: log: (pid 17133) 92s
run: sidekiq: (pid 17315) 40s; run: log: (pid 16876) 122s

这样表示已经启动好了,们就可以访问gitlab的web地址了

http://192.168.122.66:7800

第一次进入不知道为什么不能跟以前一样直接重置密码了,那我们来通过命令修改下密码

cd /opt/gitlab/bin

进入控制台

sudo gitlab-rails console
u=User.all #查看所有用户
u=User.where(id:1).first #切换到指定用户
u.password='admin123' #重置密码
u.password_confirmation='admin123' #再次确认密码
u.save! #最后保存设置
quit #退出

2021-07-29_00-54.png

然后我们再去网页上面登陆试试
2021-07-29_00-59.png

看起来是没有问题了

gitlab常用命令如下

sudo gitlab-ctl stop #停止
sudo gitlab-ctl start #启动
sudo gitlab-ctl restar #重启
sudo gitlab-ctl status #查看状态
sudo gitlab-ctl reconfigure #重载配置
sudo gitlab-ctl tail #查看日志
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION #查看版本号

gitlab安装就到这里了,之前也做过centos版本的安装,可以看看之前的笔记https://sulao.cn/post/279.html,后面我们接着再安装gitlab-runner做做cicd的最佳实践

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://sulao.cn/post/796.html

我要评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。