GitLab安装使用

简介: GitLab安装使用

@toc

官方网站:https://about.gitlab.com/

安装所需最小配置:内存至少4G

文档:https://docs.gitlab.cn/jh/install/requirements.html

image-20230103192206771

1、在ssh下安装gitlab

官方文档:https://gitlab.cn/install/?version=ce

image-20230103192313826

1.1 安装依赖

yum install -y curl policycoreutils-python openssh-server perl

image-20230103192351312

systemctl enable sshd
systemctl start sshd

image-20230103192504964

1.2 配置镜像

curl -fsSL https://packages.gitlab.cn/repository/raw/scripts/setup.sh | /bin/bash

image-20230103192453965

1.3 开始安装

EXTERNAL_URL="http://192.168.159.50" yum install -y gitlab-jh
这里的192.168.159.50是我虚拟机的ip,开发中一般是服务器域名

这里1.2G,装起来可能会费点时间

image-20230103192616891

image-20230103193257216

出现上面狐狸的标志说明安装成功了。

1.4 gitlab常用命令

gitlab-ctl start                  # 启动所有 gitlab 组件;
gitlab-ctl stop                   # 停止所有 gitlab 组件;
gitlab-ctl restart                # 重启所有 gitlab 组件;
gitlab-ctl status                 # 查看服务状态;
gitlab-ctl reconfigure            # 启动服务;
vi /etc/gitlab/gitlab.rb         # 修改默认的配置文件;
gitlab-ctl tail                   # 查看日志;

启动试试:gitlab-ctl start

image-20230103193429362

浏览器访问:192.168.159.50,出现如下登录界面

image-20230103193548307

其实在安装的时候有个默认的用户名:root,密码在文件中

image-20230103194344890

进入该目录查看临时密码

image-20230103194442027

在界面中登录

image-20230103194517032

image-20230103194535623

语言修改成简体中文:

image-20230103194706295

当然,也可以修改刚才的密码,到这ssh方式安装就介绍完了。

2、在docker下安装gitlab

2.1 安装docker

2.1.1 更新yum源

yum update

2.1.2 安装依赖

yum install -y yum-utils device-mapper-persistent-data lvm2

2.1.3 添加镜像

//国外镜像
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
//阿里镜像
https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

image-20230103203037778

2.1.4 查看源中可用版本

yum list docker-ce --showduplicates | sort -r

image-20230103203018667

2.1.5 安装指定版本

yum install docker-ce-20.10.9-3.el7

image-20230103203131596

image-20230103203157232

2.1.6 配置开机启动项

systemctl start docker
systemctl enable docker

image-20230103203300454

可以看到,创建了一个软连接

2.2 使用容器安装gitlab

2.2.1 添加容器

docker run --detach \
  --hostname 192.168.159.50 \
  --publish 443:443 --publish 80:80 \
  --name gitlab \
  --restart always \
  --volume $GITLAB_HOME/config:/etc/gitlab:Z \
  --volume $GITLAB_HOME/logs:/var/log/gitlab:Z \
  --volume $GITLAB_HOME/data:/var/opt/gitlab:Z \
  --shm-size 256m \
  registry.gitlab.cn/omnibus/gitlab-jh:latest

image-20230103205546165

2.2.2 查看启动的容器

docker ps

image-20230103210833778

2.2.3 访问

http://192.168.159.50

当首次运行出现502错误的时候排查两个原因

  • 虚拟机内存至少需要4g
  • 稍微再等等刷新一下可能就好了

image-20230103211041930

2.2.4 进入容器并查看临时登录密码

docker exec -it gitlab /bin/bash
 cat /etc/gitlab/initial_root_password

image-20230103211227849

登录

image-20230103211401118

这里,ssh方式和docker方式的安装就介绍完了。
目录
相关文章
|
2月前
|
Linux 应用服务中间件 网络安全
linux安装Gitlab
linux安装Gitlab
121 0
|
2月前
|
缓存 数据安全/隐私保护 Docker
安装gitlab
安装gitlab
224 0
|
9月前
|
Prometheus 监控 Cloud Native
私有仓库Gitlab的安装与汉化
私有仓库Gitlab的安装与汉化
124 0
|
8月前
|
网络安全 开发工具 数据安全/隐私保护
Gitlab的安装
Gitlab的安装
98 0
|
2月前
|
网络协议 Linux 网络安全
GitLab安装和使用指南
GitLab安装和使用指南
94 0
|
2月前
|
Linux
linux安装gitlab
linux安装gitlab
46 0
|
网络协议 Unix 应用服务中间件
Gitlab安装配置及简单问题处理
Gitlab安装配置及简单问题处理
245 0
|
Linux 应用服务中间件 开发工具
|
应用服务中间件 nginx 开发工具
Gitlab安装配置及使用
gitlab是山寨版的github,它是开源的,你可以在自己的服务器上架设gitlab,用于团队私有项目的托管。gitlab支持树莓派2嵌入式设备,下面记录了在树莓派2上安装与配置gitlab的过程。
2756 0