gitlab 安装、配置、清空、卸载、重装
20200702 自行搭建 git 服务器后,如何管理总是一个麻烦事,所以,还是要安装一个 gitlab
按照 gitlab 官网安装 ce 版,其实应该是很简单的事情,步骤也很少。
正常情况下,安装、配置、运行,再学习 gitlab 使用
没有想到我折腾了一大圈!来回卸载、重装、重新配置!几乎所有该出现的问题,全都遇见了一轮!
我的环境: virtualBox 虚拟机 ubuntu Server 1804
gitlab 官网
gitlab 官网
https://about.gitlab.com/install/#ubuntu
gitlab ce 版本安装步骤
gitlab ce 版本安装步骤
https://about.gitlab.com/install/#ubuntu?version=ce
清华大学开源软件镜像站
清华大学开源软件镜像站
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/
Gitlab Community Edition 镜像使用帮助
Gitlab Community Edition 镜像使用帮助
https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/
1、 安装
安装必要的依赖
sudo apt-get install -y curl openssh-server ca-certificates非必须 ( 如果开始学习或者后续需要使用邮箱开放注册的话,请安装 )
sudo apt-get install -y postfix设置安装包和 gitlab 软件源
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash按照前面镜像使用帮助,设置清华 gitlab ce 软件源
上一步 bash 完成之后。会增加一个 gitlab ce 的软件源,如下:$ cd /etc/apt/sources.list.d$ lsgitlab_gitlab-ce.list
$ vim gitlab_gitlab-ce.list
替换一下# this file was generated by packages.gitlab.com for# the repository at https://packages.gitlab.com/gitlab/gitlab-ce# by wzh 20200702# deb https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ bionic main# deb-src https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ bionic main# TsingHua deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu bionic maindeb-src https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu bionic main
开始安装 gitlab-ce
gitlab 使用 ruby 的 rails 框架开发,已经自带了 web 服务器
所以不需要提前准备一个域名网站,直接使用 ip + 端口方式即可
后续在配置 nginx 映射到这个 ip 和端口即可后期使用时,发现 clone 的时候, url 也总是 127.0.0.1,所以,最好使用实际的内网地址,例如:我的内网地址是 192.168.1.194
$ sudo EXTERNAL_URL=“http://192.168.1.194:8090” apt-get install gitlab-ce
不要像之前这样,写成 127.0.0.1
$ sudo EXTERNAL_URL=“http://127.0.0.1:8090” apt-get install gitlab-ce
Reading package lists... DoneBuilding dependency tree Reading state information... DoneThe following packages will be upgraded:gitlab-ce1 upgraded, 0 newly installed, 0 to remove and 121 not upgraded.Need to get 740 MB of archives.After this operation, 139 kB disk space will be freed.Get:1 https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu bionic/main amd64 gitlab-ce amd64 13.1.2-ce.0 [740 MB]...
安装过程比较漫长,即使换成了清华的源,也很慢!
配置生效并开始运行
sudo gitlab-ctl reconfigure && sudo gitlab-ctl start这个过程也比较慢!这个 gitlab 确实比较庞大,涵盖的东西很多!
gitlab-ctl start 也需要 root 权限,否则,会出现一大堆 warning测试、验证
sudo ufw enable 8090sudo ufw status
或者干脆 sudo ufw disable
$ curl 127.0.0.1:8090
应该看到的是<html><body>You are being <a href="http://127.0.0.1:8090/users/sign_in">redirected</a>.</body></html
浏览器测试一下
http://192.168.1.194:8090会自动重定向到以下 url
http://192.168.1.194:8090/users/password/edit?reset_password_token=oN-Fu-KZgSPS-9qd7rzV
如果顺利的到达这里,gitlab ce 就算 ok! 剩下就是学习使用了!
查看配置信息
$ sudo gitlab-ctl show-config
内容确实很多很多!Starting Chef Client, version 14.14.29 resolving cookbooks for run list: ["gitlab::show_config"] Synchronizing Cookbooks:- package (0.1.0)- redis (0.1.0)- postgresql (0.1.0)- monitoring (0.1.0)- registry (0.1.0)- mattermost (0.1.0)- consul (0.1.0)- gitaly (0.1.0)- praefect (0.1.0)- letsencrypt (0.1.0)- nginx (0.1.0)- runit (5.1.3)- acme (4.1.1)- crond (0.1.0)- gitlab (0.0.1) Installing Cookbook Gems: Compiling Cookbooks... ......
查看版本号
$ cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
13.1.2
以下内容可以不必观看
以下过程希望不再经历!
2、常用命令
安装的时候都已经设置好了!不折腾的话,这些命令基本上用不上!
*** 全都记住不太可能,直接 gitlab-ctl help 或者 gitlab-ctl -h ,就都看到了!***
以下命令都需要 sudo
查询 gitlab 服务
systemctl list-unit-files --type=service | grep gitlabgitlab-runsvdir.service enabled
查询 gitlab 服务状态
systemctl status gitlab-runsvdir.service设置开机启动
systemctl enable gitlab-runsvdir.service禁止开机自启动
systemctl disable gitlab-runsvdir.service启动/重启/停止 gilab 服务
gitlab-ctl start
gitlab-ctl restart
gitlab-ctl stop修改配置后,重新配置生效
gitlab-ctl reconfigure
一般连着使用
sudo gitlab-ctl reconfigure && sudo gitlab-ctl start查看 gitlab 配置
gitlab-ctl show-config卸载 gitlab
gitlab-ctl uninstall清空 gitlab 配置,推倒重来
gitlab-ctl cleanse查看 gitlab 日志
gitlab-ctl tail
3、 异常情况
关机或者 reboot 之后,再次测试
$ curl 127.0.0.1:8090 看到的不是以上一条语句了,而是一大段......<script>(function () {var goBack = document.querySelector('.js-go-back');if (history.length > 1) {goBack.style.display = 'inline';}})();</script></body></html>
浏览器打开 http://192.168.1.194:8090 ,立刻出现 502 !可恶之极!
502
Whoops, GitLab is taking too much time to respond.
- 后续来回折腾之后,发现自己掉坑底!
以上错误并非 gitlab 安装的不对,也不是 gitlab 出错了!
每次 reboot 之后, gitlab 服务启动需要花好长时间的!
本人反应比较快,直接就开始检查配置、服务状态…各种折腾!
4、 卸载、重装
查询 gitlab 安装包
$ dpkg --list |grep gitlabii gitlab-ce 13.0.1-ce.0 amd64 GitLab Community Edition (including NGINX, Postgres, Redis)rc gitlab-ee 13.0.1-ee.0 amd64 GitLab Enterprise Edition (including NGINX, Postgres, Redis)
$ ps -ef | grep gitlab
卸载 gitlab
sudo apt-get --purge remove gitlab-ce
Reading package lists... DoneBuilding dependency tree Reading state information... DoneThe following packages will be REMOVED:gitlab-ce*0 upgraded, 0 newly installed, 1 to remove and 121 not upgraded.After this operation, 1,947 MB disk space will be freed.Do you want to continue? [Y/n] y(Reading database ... 185411 files and directories currently installed.)Removing gitlab-ce (13.1.1-ce.0) ...(Reading database ... 113921 files and directories currently installed.)Purging configuration files for gitlab-ce (13.1.1-ce.0) ...dpkg: warning: while removing gitlab-ce, directory '/opt/gitlab/sv' not empty so not removeddpkg: warning: while removing gitlab-ce, directory '/opt/gitlab/service' not empty so not removeddpkg: warning: while removing gitlab-ce, directory '/opt/gitlab/init' not empty so not removeddpkg: warning: while removing gitlab-ce, directory '/opt/gitlab/etc' not empty so not removeddpkg: warning: while removing gitlab-ce, directory '/opt/gitlab/embedded/ssl/certs' not empty so not removeddpkg: warning: while removing gitlab-ce, directory '/opt/gitlab/embedded/service/gitlab-shell' not empty so not removeddpkg: warning: while removing gitlab-ce, directory '/opt/gitlab/embedded/service/gitlab-rails/public' not empty so not removeddpkg: warning: while removing gitlab-ce, directory '/opt/gitlab/embedded/service/gitlab-rails/config' not empty so not removeddpkg: warning: while removing gitlab-ce, directory '/opt/gitlab/embedded/cookbooks' not empty so not removeddpkg: warning: while removing gitlab-ce, directory '/opt/gitlab/embedded/bin' not empty so not removed
删除所有包含gitlab文件
sudo find / -name gitlab | xargs rm -rf
sudo find / -name gitlab | xargs sudo rm -rf确认一下
$ ps -ef | grep gitlab
$ dpkg --list |grep gitlab重新安装,步骤忽略
lock-frontend 错误
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
由于安装总是很慢,忍不住给他中断了几次!
然后,重新来过的时候,就看到了这个 lock-frontend !$ sudo cat /var/lib/dpkg/lock-frontend
内容是空的$ sudo rm /var/lib/dpkg/lock-frontend
直接删除后 , $ sudo apt update , 再来!
5、清空后再来
还没有学会 gitlab 操作的时候,总是会将配置和 注册用户搞得乱七八糟,这个时候就希望能重新 init !
Delete all gitlab data, and start from scratch.
清空 gitlab 配置,推倒重来
$ sudo gitlab-ctl cleanse******************************************************************** * * * * * * * * * * STOP AND READ * * * * * * * * * ********************************************************************This command will delete *all* local configuration, log, andvariable data associated with gitlab.You have 60 seconds to hit CTRL-C before configuration,logs, and local data for this application are permanentlydeleted.*******************************************************************......Your config files have been backed up to /root/gitlab-cleanse-2020-07-02T10:41.
重新运行、测试
sudo gitlab-ctl reconfigure && sudo gitlab-ctl start$ curl 127.0.0.1:8090
curl: (7) Failed to connect to 127.0.0.1 port 8090: Connection refused
直接就 refused !会不会是 配置 127.0.0.1:8090 也 clean 了?
$ cd /etc/gitlab/
$ lsgitlab-secrets.json trusted-certs
真的没有了啊!缺少了那个 gitlab.rb 配置文件!
以前是这样子的
gitlab.rb gitlab-secrets.json trusted-certs
所以,只好重新安装
sudo EXTERNAL_URL=“http://127.0.0.1:8090” apt-get install gitlab-ce
写这个博客的时候,注意到:cleanse 的最后一句提示
Your config files have been backed up to /root/gitlab-cleanse-2020-07-02T10:41.
但是, 有些 ubuntu 1804 在安装的时候,根本就没有设置过 root 密码,root 密码本身是随机生成的!
$ su
Password:
su: Authentication failure
所以,真的需要去找回那个备份的话,首先要去找回 root 密码!
好在我这个 ubuntu 1804 版本比较早,当时是有设置过 root 密码的
可以用来证明:确实将之前的 3 个文件都 backup 过去了!
$ su
Password: # whoami
root# cd /root
# lsgitlab-cleanse-2020-07-02T10:41# cd gitlab-cleanse-2020-07-02T10\:41/# lsgitlab.rb gitlab-secrets.json trusted-certs
6、查看、修改配置
查看版本号
$ cat /opt/gitlab/embedded/service/gitlab-rails/VERSION13.1.2
sudo vim gitlab.rb
目前可能需要修改的好像只有这一条
external_url ‘http://127.0.0.1:8090’后续学习使用 gitlab,这个看着不错!
使用 gitlab
https://www.cnblogs.com/zdqc/p/9666994.html#auto-id-5
这个很详细!
Gitlab快速部署及日常维护(社区版RPM包方式安装)
https://www.cnblogs.com/kevingrace/p/5985918.html
gitlab 安装、配置、清空、卸载、重装相关推荐
- docker下gitlab安装配置使用(完整版)
docker下gitlab安装配置使用(完整版) 22018.12.16 00:07:57字数 737阅读 17595 docker 安装gitlab以及使用 一.安装及配置 1.gitlab镜像拉取 ...
- Gitlab安装配置及简单问题处理
Git 是版本控制系统 Github 是在线的基于Git的代码托管服务 Gitlab 可以在上面创建免费的私人repo 建议(少走弯路) 1.Gitlab本身很容易安装,整个安装包也就300M,下载到 ...
- Linux环境中Visual Studio Code 安装配置及其卸载(详细教程)
两篇相关博文: 在VMware15中创建虚拟机安装ubuntu系统(超详细教程) Linux环境编译运行C/C++语言程序----配置gcc.g++(详细教程) 此篇分享我在linux环境下安装VS ...
- GitLab安装配置使用总结
代码管理一直用svn,Git的分支管理认为是最好的,尝试用用. 一.GitLab简介 GitLab 是一个用于仓库管理系统的开源项目.使用Git作为代码管理工具,并在此基础上搭建起来的web服务. 可 ...
- Caffe + Ubuntu 15.04/16.04 + CUDA 7.5/8.0 在服务器上安装配置及卸载重新安装(已测试可执行)
本文参考如下: caffe 安装所需的所有资源可在百度网盘下载 链接: http://pan.baidu.com/s/1jIRJ6mU 提取密码:xehi 在服务器上为每个子用户拷贝caffe 使用 ...
- GitLab 安装配置指南
为什么80%的码农都做不了架构师?>>> GitLab 在 CentOS 7系统上的安装配置指南 1.简单介绍 GitLab 是利用 Ruby on Rails 开发的一个开源 ...
- docker下gitlab安装配置使用
一.安装及配置 1.gitlab镜像拉取 # gitlab-ce为稳定版本,后面不填写版本则默认pull最新latest版本 $ docker pull gitlab/gitlab-ce 拉取镜像 2 ...
- GitLab安装配置附官方文档地址
建议直接跳到看后面附录的官方文档 目录 一.包下载 二.安装 三.配置 1. 地址配置 2. 邮件配置 常用的GitLab命令 附录:官方文档地址 一.包下载 wget --content-dispo ...
- mac brew安装,brew卸载重装
brew卸载重装 卸载 sudo rm -rf /usr/local/.git sudo rm -rf ~/Library/Caches/Homebrew sudo rm -rf /usr/local ...
- bitnamigitlab_Bitnami Gitlab 安装配置 step by step
获取一键安装包 https://bitnami.com/stack/gitlab 下载路径为 /home/mine/bitnami-gitlab-7.13.5-0-linux-x64-installe ...
最新文章
- 毛边效果 html,Html5 Canvas画线有毛边解决方法
- 三维ICP-SVD配准
- 使用EasyUI的插件前需要引入的文件
- 【推荐精读】从item-base到svd再到rbm,多种Collaborative Filtering(协同过滤算法)从原理到实现
- 智慧金融管理系统提供个性化的智能客户服务
- 三星手机android,个人评测 篇三:三星S10e还值得买吗——半年使用杂谈,最终篇...
- 红米Note8手机图纸-电路原理图+主板元件位号图
- IsKindOf的用法简介
- 【Python 基础教程】彻底解决python round函数的四舍五入不精确的问题
- python 拟合分布_stats模型中数据的Poisson分布拟合
- idea 启动参数设置
- 从页面获取form表单提交的数据
- 3.7 使用极坐标网格工具制作雷达扫描效果 [Illustrator CC教程]
- OpenCV - C++实战(05) — 颜色检测
- 元宇宙是什么?解密扎克伯格的“元宇宙梦”
- git中的配置文件(/etc/gitconfig,${HOME}/.gitconfig,.git/config)
- CentOS 7下ngrok服务器搭建
- mybatis多对一映射association详解
- 推荐5个免费好用的UI模板网站!
- 内存卡修复器,内存卡修复器下载