云服务器搭建GitLab

经验总结:

1、配置需求:云服务器内存最低4G

2、内存4G的云服务器,在运行容器后,会遇到云服务器操作卡顿问题,这里有解决方案

转载:服务器搭建Gitlab卡顿解决办法-CSDN博客

3、云服务器的操作系统会影响容器化的gitlab环境搭建,若有问题,重新装操作系统,这里我选择的是ubuntu 20.04,曾经也选择过Centos 7,但是创建gitlab 容器后,发现网络问题。

4、云服务器需要配置安全组的入方向规则,添加相应的协议端口

5、网址访问突然报502,重启容器发现报错如下

复制代码
root@hecs-198528:~# docker restart gitlab
Error response from daemon: Cannot restart container gitlab: driver failed programming external connectivity on endpoint gitlab (042be20d8e5ebd6d0c71966020c46a46ec9a4adfb729a95a946cbb12a66738ce):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8888 -j DNAT --to-destination 172.17.0.2:80 ! -i docker0: iptables: No chain/target/match by that name.
 (exit status 1))

解决方法:重启docker 服务后,重启容器

复制代码
systemctl restart docker
 
docker start gitlab

详细操作步骤:

1、安装docker

复制代码
 apt install docker.io

2、下载gitlab docker 镜像

复制代码
docker pull gitlab/gitlab-ce

3、执行docker 命令

建议运行在默认80端口上,不然后面git clone项目代码有麻烦

复制代码
docker run --detach \
  --publish 8443:443 --publish 80:80 --publish 8822:22 \
  --name gitlab \
  --restart always \
  --volume /mydata/gitlab/config:/etc/gitlab \
  --volume /mydata/gitlab/logs:/var/log/gitlab \
  --volume /mydata/gitlab/data:/var/opt/gitlab \
  gitlab/gitlab-ce:latest

4、开启防火墙的指定端口

由于Gitlab运行在80端口上,所以我们需要开放该端口,注意千万不要直接关闭防火墙,否则Gitlab会无法启动。

开启80端口

复制代码
firewall-cmd --zone=public --add-port=80/tcp --permanent 

重启防火墙才能生效

复制代码
systemctl restart firewalld

查看已经开放的端口

复制代码
firewall-cmd --list-ports

5、配置云服务器的安全组入方向规则

6、浏览器访问

浏览器访问的网址是 ip:端口号,由于我配置的默认80端口,可以不加端口号,在网页上输入ip就可以了,正常访问是这样的

7、重置管理员密码

复制代码
# 进入容器
docker exec -it 容器id /bin/bash
# 查看管理员密码
cat /etc/gitlab/initial_root_password

找到密码后,我们就可以使用root管理员账号登录了

重置密码

8、中文设置

9、添加密钥

生成ssh-key,默认一路回车即可

复制代码
ssh-keygen

在~/.ssh/下会生成两个文件,id_rsa和id_rsa.pub

id_rsa是私钥

id_rsa.pub是公钥

添加ssh-key公钥到gitlab

登录gitlab,在右上角设置中找到SSH密钥

将刚才生成的公钥内容复制到密钥中,标题名字随意

相关推荐
wanhengidc2 小时前
网站服务器都有哪些作用?
运维·服务器·科技·智能手机·云计算
卓小帅的博客2 小时前
关于实现远程服务器使用本地网络的清晰简洁的教程
服务器·网络·vscode·连接超时
百***75743 小时前
linux上redis升级
linux·运维·redis
顾安r3 小时前
11.22 脚本打包APP 排错指南
linux·服务器·开发语言·前端·flask
小小编程能手4 小时前
Linux文件编程
linux·运维·服务器
木童6624 小时前
nginx安装步骤详解
linux·运维·服务器·网络·nginx
Coding_Doggy5 小时前
链盾shieldchain | 项目管理、DID操作、DID密钥更新消息定时提醒
java·服务器·前端
暴躁的菜鸡5 小时前
Ubuntu安装向日葵
linux·运维·ubuntu
wa的一声哭了5 小时前
Webase部署Webase-Web在合约IDE页面一直转圈
linux·运维·服务器·前端·python·区块链·ssh
Aufidius5 小时前
虚拟机ubuntu存储空间不够如何扩容(扩充根目录)
linux·运维·ubuntu