云服务器搭建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密钥

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

相关推荐
China_Yanhy3 小时前
转型AI运维工程师·Day 7:构建“数据飞轮” —— 每一句对话都是资产
运维·人工智能·状态模式
小哥不太逍遥3 小时前
Technical Report 2024
java·服务器·前端
wanhengidc4 小时前
私有云具体是指什么
服务器·网络·游戏·智能手机·云计算
A星空1234 小时前
三、Kconfig介绍以及制作menuconfig界面
linux·运维·服务器
爱上妖精的尾巴4 小时前
8-10 WPS JSA 正则表达式:贪婪匹配
服务器·前端·javascript·正则表达式·wps·jsa
安科士andxe4 小时前
实操指南|安科士1.25G CWDM SFP光模块选型、部署与运维全攻略
运维·数据库·5g
Elastic 中国社区官方博客6 小时前
易捷问数(NewmindExAI)平台解决 ES 升级后 AI 助手与 Attack Discovery 不正常问题
大数据·运维·数据库·人工智能·elasticsearch·搜索引擎·ai
末日汐7 小时前
TCP编程简单回显服务
服务器·网络·tcp/ip
姜行运8 小时前
【Linux】基础指令2
android·linux·服务器
比奇堡派星星8 小时前
sed命令
linux·运维·服务器·开发语言