一、安装部署gitlab-ee-15版本:

GitLab是Ruby开发的自托管的Git项目仓库,可通过Web界面访问公开的或者私人的项目。本教程介绍如何安装和使用GitLab。

1、从官网下载软件包,软件下载链接:

社区版ce

https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/企业版ee

https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/

[root@gitlab-service-01 ~]#wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/gitlab-ee-15.4.3-ee.0.el7.x86_64.rpm

Gitlab 主从搭建搭建_gitlab


2、修改主机名:

[root@localhost ~]# vim /etc/hosts

172.16.8.55 cnszof-vm-gitlab-am01

172.16.8.56 cnszof-vm-gitlab-am02

[root@localhost ~]# hostnamectl set-hostname cnszof-vm-gitlab-am01

[root@localhost ~]# exit (#退出后在进来就改好了)3、安装部署:

首先安装依赖包:

[root@gitlab-service-01 ~]# yum -y install curl openssh-server openssh-clients cronie policycoreutils-python postfix

[root@gitlab-service-01 ~]# systemctl enable postfix

执行以下命令,安装GitLab:

[root@gitlab-service-01 ~]# rpm -ivh gitlab-ce-15.4.4-ce.0.el7.x86_64.rpm

Gitlab 主从搭建搭建_初始化_02

4、初始化gitlab:

执行 ( 时间较长 打印很多日志 等待一会 )

[root@gitlab-service-01 ~]# gitlab-ctl reconfigure

最后一句出现 gitlab Reconfigured! 则初始化成功

Gitlab 主从搭建搭建_初始化_03

5、修改配置,url改为你的IP地址,如果你使用的是域名,也是在这里修改。
[root@gitlab-service-01 ~]# vim /etc/gitlab/gitlab.rb
external_url 'https:/gitlab.xxx.com.cn'
#external_url 'http://gitlab.example.com'

6、启停gitlab

[root@gitlab-service-01 ~]# gitlab-ctl start (#启动)

[root@gitlab-service-01 ~]# gitlab-ctl stop (#停止)

[root@gitlab-service-01 ~]# gitlab-ctl status (#状态)

[root@gitlab-service-01 ~]# gitlab-ctl restart (#重启)

Gitlab 主从搭建搭建_初始化_04

7、修改登录root密码:

gitlab15安装初始化后,默认账户名是root,密码存放在配置文件。

/etc/gitlab/initial_root_password

gitlab 在centerOS7中的配置目录在/etc/gitlab/

[root@gitlab-service-01 ~]# cat /etc/gitlab/initial_root_password

Gitlab 主从搭建搭建_gitlab_05

8、修改登录root的密码:
[root@gitlab-service-01 ~]# gitlab-rake "gitlab:password:reset[root]"
gV2LPudGoY9gb
密码需要输入2次,输入是不显示的哦。完成后,即可使用root账号登录

9、web登录:

浏览器输入:http://172.16.8.55/用户名:root

密码:gV2LPudGoY9gb

Gitlab 主从搭建搭建_初始化_06

二、gitlab仓库存储位置等修改方法

#!停掉 gitlabgitlab-ctl stop

1、gitlab的目录存储目录是 /var/opt/gitlab/git-data/

Gitlab 主从搭建搭建_初始化_07


2、创建新存储目录

mkdir -p /data/gitlab-data

3、修改配置文件(找到 git_data_dirs 参数对应的配置)
vim /etc/gitlab/gitlab.rb

git_data_dirs({
"default" => {
"path" => "/data/git-data"
}
})
4.重新加载配置
gitlab-ctl reconfigure
原文链接:https://blog.csdn.net/qq_50247813/article/details/126250101

lsyncd和rsync实现文件实时同步
参考 https://zhuanlan.zhihu.com/p/534916280https://www.freesion.com/article/2686826236/

  1. rsync安装方式:

yum install epel-release -y && yum install rsync -y
lsyncd安装方式:
yum install epel-release -y && yum install lsyncd -y
软件说明:
rsync 用于同步文件
lsyncd 用于监控文件变化
2.配置同步模块
1. 编辑同步配置文件
vi /etc/rsyncd.conf
# any name you like[backup]# destination directory for copy
path = /data/
# hosts you allow to access
hosts allow = 172.16.8.55
hosts deny = *
list = true
uid = root
gid = root
read only = false
log file=/var/log/rsync.log

2.创建同步文件夹
mkdir /data
3.启动同步服务
systemctl start rsyncd
4.设置开机启动
systemctl enable rsyncd

发送端配置:

  1. 主/从服务器之间启用基于的身份验证。登录发送端服务器并用 " ssh- " 命令生成公共或私有的**。

Gitlab 主从搭建搭建_初始化_08


使用 " ssh-copy-id " 复制**文件到接收端服务器。

ssh-copy-id -i /root/.ssh/id_rsa.pub root@172.16.8.55出了问题记得:

chown -R git:git /data/gitlab-data/

二、安装rsync + lsyncd
1. 安装rsync

yum -y install rsync

https://www.freesion.com/article/2686826236/vim /etc/lsyncd.conf
settings {
logfile ="/var/log/lsyncd.log",
statusFile = "/tmp/lsyncd.stat",
statusInterval = 1,
}
sync{
default.rsync,
source="/data",
target="172.16.8.56::backup",
rsync={rsh ="/usr/bin/ssh -l root -i /root/.ssh/id_rsa",}
}

修改sshd端口号
/etc/ssh/sshd_config
Port 22
Port 2223

四、添加证书
https://docs.gitlab.cn/omnibus/settings/ssl/index.html

检查证书的私钥和证书是否匹配
http://www.manongjc.com/detail/16-aojntwqklfdnwlw.html相当于金老师文档里的nginx:xx.crt xxx_com_cn.key
openssl x509 -noout -modulus -in xxx.com.cn.crt |openssl md5
openssl rsa -noout -modulus -in xxx.com.cn.key |openssl md5


三、更新 SSL 证书

如果您的 SSL 证书的内容已更新,但没有对 /etc/gitlab/gitlab.rb 进行配置更改,则重新配置极狐GitLab 不会影响 NGINX。相反,您必须使 NGINX 优雅地重新加载现有配置和新证书
sudo gitlab-ctl hup nginx registry