本地部署Gitlab记录

一、准备工作

vps:Centos7 ,比较吃内存,建议内存不小于4G

安装包下载:https://about.gitlab.com/downloads/#centos7

安装环境:


yum install curl policycoreutils openssh-server openssh-clients postfix

启动服务:

systemctl start sshd        #一般都是已经启动的

systemctl start postfix


二、安装Gitlab-ce

下载安装包,推荐清华镜像站:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el9/gitlab-ce-16.9.0-ce.0.el9.x86_64.rpm

下载下来后安装:


rpm -ivh gitlab-ce-16.9.0-ce.0.el9.x86_64.rpm


三、配置端口

配置文件在/etc/gitlab/gitlab.rb,需要修改端口和配置邮件

GitLab默认会占用80、8080和9090端口,如果服务器上还有tomcat、Jenkins等其他服务,可能会遇到端口冲突。

找到关键字:external_url 'http://127.0.0.1'
将其内容改为:external_url 'http://<服务器地址或域名>:10000'

找到关键字:unicorn['port'] = 8080
将其内容改为:unicorn['port'] = 10001

找到关键字:prometheus['listen_address'] = 'localhost:9090'
将其内容改为:prometheus['listen_address'] = 'localhost:10002'


四、登录

输入网址:http://<服务器地址或域名>:10000 
首先设置管理员(root)密码:
然后注册账号(也可以直接使用root+上面设置的密码登录):
登录(这里用注册的普通用户登录):

五、修改邮箱设置

执行vim /etc/gitlab/gitlab.rb进入到配置文件,找到关键字Email Settings修改下面的参数:


### Email Settings 
gitlab_rails['gitlab_email_enabled'] = true 
gitlab_rails['gitlab_email_from'] = 'gitlab@http://<服务器地址或域名>' 
gitlab_rails['gitlab_email_display_name'] = 'GitLab' 
设置完成后,重配postfix,执行dpkg-reconfigure postfix 
也可以使用其他SMTP邮箱(略)

gitlab完成配置后,需要执行 gitlab-ctl reconfigure 命令使得配置生效

六、测试

图形界面创建项目

创建测试项目

推送ssh密钥

生成密钥
  •  ssh-keygen

  • cat ~/.ssh/id_rsa.pub 

上传密钥:


上传、下载

网页端(略)

命令行:

#克隆项目文件
git config --global user.name "lin"
git config --global user.email "123@admin.com"
git clone git@8.134.189.148:tian/test2.git  

#上传文件(test2是上面创建的测试项目)
cd test2
echo 1234567  >  README.md
git add README.md  #选择要上传的文件
git init   #初始化
git remote add origin git@8.134.189.148:tian/test2.git   #配置远端服务器
#如果远程服务器配置报错,因为之前已经配置过其他远程服务器。可以用命令清除掉
#git remote rm origin
git commit -m 'first commit'   #提交说明
git push -u origin master

常用的管理命令:

  1. gitlab-ctl start - 启动所有 GitLab 服务。
  2. gitlab-ctl stop - 停止所有 GitLab 服务。
  3. gitlab-ctl restart - 重启所有 GitLab 服务。
  4. gitlab-ctl reconfigure - 将 /etc/gitlab/gitlab.rb 中的更新应用到GitLab服务。
  5. gitlab-ctl status - 查看所有 GitLab 服务的状态。
  6. gitlab-ctl tail - 跟踪 GitLab服务的日志文件。
  7. gitlab-ctl reconfigure - 应用配置更改。
  8. gitlab-ctl check-config - 验证配置文件的有效性。
  9. gitlab-ctl upgrade - 进行GitLab升级。

 

评论

此博客中的热门博文

容器技术所涉及Linux内核关键技术

MySQL8.X安装&基本使用

部署ELK日志平台集群(Elasticsearch, Logstash, Kibana)实验记录