gitlab的部署

gitlab的部署

1.创建Yum仓库

[root@gitserver ~]# cd /etc/yum.repos.d/
[root@gitserver yum.repos.d]# vim gitlab-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever
gpgcheck=0
enabled=1

2.安装相关依赖和邮箱服务

[root@git-server yum.repos.d]# yum install -y curl policycoreutils-python openssh-server postfix
#启动ssh服务
[root@git-server yum.repos.d]# systemctl start sshd && systemctl enable sshd
#启动邮箱服务
[root@git-server yum.repos.d]# systemctl start postfix && systemctl enable postfix
	注意:邮箱服务正常启动如果报错执行下面的操作:
	修改:/etc/postfix/main.cf  修改参数指定网络接口
	将:inet_interfaces = localhost 改为 all
#启动后去下载gitlib
A:
[root@git-server yum.repos.d]# yum install -y gitlab-ce  #将会安装gitlab最新版本,使用Yum方式安装
B: rpm安装
[root@gitlab /]# yum -y install gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm

3.修改配置文件(/etc/gitlab/gitlab.rc)

#第一处添加对外的域名指向本服务器的公网IP(做好解析,或者直接写IP)
 13 external_url 'http://sihyemama.com'

#第二处修改时区,为亚洲上海 
 49 gitlab_rails['time_zone'] = 'Asia/Shanghai'

#第三处打开数据路径的配置,路径可修改也可保存默认
 421 git_data_dirs({
 422   "default" => {
 423     "path" => "/mnt/nfs-01/git-data"
 424    }
 425 })
#第四处打开端口的注释,打开ssh服务
 439 gitlab_rails['gitlab_shell_ssh_port'] = 22

#第五处打开邮件服务并添加git的邮箱发送部分
 559 gitlab_rails['smtp_enable'] = true
 560 gitlab_rails['smtp_address'] = "smtp.yeah.net"
 561 gitlab_rails['smtp_port'] = 465
 562 gitlab_rails['smtp_user_name'] = "sihyehwang@yeah.net"
 563 gitlab_rails['smtp_password'] = "2541hsh"
 564 gitlab_rails['smtp_domain'] = "yeah.net"
 565 gitlab_rails['smtp_authentication'] = "login"
 566 gitlab_rails['smtp_enable_starttls_auto'] = true
 567 gitlab_rails['smtp_tls'] = true
 ---新添加---
 568 gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
 569 gitlab_rails['gitlab_email_from'] = 'sihyehwang@yeah.net'
 570 gitlab_rails['gitlab_email_display_name'] = 'Admin'
 571 user["git_user_email"] = "sihyehwang@yeah.net"

4.重置并启动GitLab,会自动执行

[root@gitlab /]# gitlab-ctl reconfigure
....
Chef Client finished, 528/1419 resources updated in 03 minutes 26 seconds
gitlab Reconfigured!

5.启动gitlab

[root@gitlab /]# gitlab-ctl restart
ok: run: alertmanager: (pid 6922) 0s
..
ok..

6.测试发邮件

[root@gitlab /]# gitlab-rails console
---------------------------------------------
 GitLab:       12.3.5 (2417d5becc7)
 GitLab Shell: 10.0.0
 PostgreSQL:   10.9
---------------------------------------------
Loading production environment (Rails 5.2.3)
irb(main):001:0> Notify.test_email('sihyehwang@yeah.net', 'hello gitgirl', 'Nice to meet you').deliver_now
##发送成功时的正常输出
Notify#test_email: processed outbound mail in 2.0ms
Sent mail to sihyehwang@yeah.net (1285.9ms)
Date: Mon, 14 Oct 2019 16:13:21 +0800
From: Admin <sihyehwang@yeah.net>
Reply-To: Admin <noreply@sihyemama.com>
To: sihyehwang@yeah.net
Message-ID: <5da42e21b1cf2_1c863fc7fa6cf9b0536a1@gitlab.mail>
Subject: hello gitgirl
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit
Auto-Submitted: auto-generated
X-Auto-Response-Suppress: All

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><p>Nice to meet you</p></body></html>

=> #<Mail::Message:70127717151580, Multipart: false, Headers: <Date: Mon, 14 Oct 2019 16:13:21 +0800>, <From: Admin <sihyehwang@yeah.net>>, <Reply-To: Admin <noreply@sihyemama.com>>, <To: sihyehwang@yeah.net>, <Message-ID: <5da42e21b1cf2_1c863fc7fa6cf9b0536a1@gitlab.mail>>, <Subject: hello gitgirl>, <Mime-Version: 1.0>, <Content-Type: text/html; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>, <Auto-Submitted: auto-generated>, <X-Auto-Response-Suppress: All>>

—邮件报错或提示—

Net::SMTPServerBusy (450 DT:SPM yeah smtp1,ClUQrACnrbHXLqRdDsVdDA-...984)
纠错
代表SMTP错误代码420或450,是一个临时错误。过两分钟就发过去了

7.测试访问: http://sihyemama.com (自己设置服务器的域名或者IP)

​ 用户名: root 密码: 自己创建的
完成好工程的创建后即可交付给开发

gitlab的使用

1.创建新的project

在这里插入图片描述
?添加SSH密钥
在这里插入图片描述
在这里插入图片描述
[流程:] --> 去git客户端

1.生成密钥 
ssh-keygen
2.查看键值
cat /root/.ssh/id_rsa.pub
---
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCjJ8nWaPa0hHpxZ8rfPIxATpAmhBYuimWLbkmIQjDe+AXiFW4kXfJfTv/IKVulNMX2aV24OncWvBSentAigeMvGufYRurk4DEB6c5vx+XwpN89kRb+Zt5LTdCzwBVTAtLArq0TfMC35W5AouYicm0HNpP2gViABRm9YZ+a8qvVLDxQ3vkgZOHjVS6mdXOJp/aDFqV3vr/Q5wNvFZwFg3+QpJkJuLoOauiXEq0bvpqdfXqn/aikQajQIjGmP+LgCZtTpjHI1lB1Yh5ca/ittAxvccO/6J1lg/30PuvRkTe9yM8nxcJLZK/GosMzcAl4Kd29acrQDZP4RAIzg6TeLcvl root@gitlab
---
3.将这整一段复制到浏览器框中提交

如果需要生成更多的密钥,继续添加即可,交付

客户端client

[模拟开发对于项目分支提交等的操作]

1.克隆project到本地

[root@gitlab mnt]# git clone git@sihyemama.com:root/beauty.git
正克隆到 'beauty'...
Th....
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'sihyemama.com,172.16.109.130' (ECDSA) to the list of known hosts.
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
接收对象中: 100% (3/3), done.

[root@gitlab mnt]# ls
beauty 

2.根据需求与角色对project的操作

[root@gitlab beauty]# git commit -m "init commit"
[报错]
*** Please tell me who you are.
Run
  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'root@gitlab.(none)')

******重要***[解决: 添加配置文件中创建的用户]******重要***
[root@gitlab beauty]# git config --global user.email "sihyehwang@yeah.net"
[root@gitlab beauty]# git config --global user.name "sihyehwang@yeah.net"
[root@gitlab beauty]# git add * 
[root@gitlab beauty]# git commit -m "This is second"
[master c9c7b9a] This is second
 1 file changed, 1 insertion(+)
 create mode 100644 contact.html
 
 \#上传到分支
[root@gitlab beauty]# git push origin master
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 327 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@sihyemama.com:root/beauty.git
   9965b71..c9c7b9a  master -> master

在这里插入图片描述
客户端克隆时只需要添加本地解析,能够连通中心服务器的域名,以及上传SSH密钥
[克隆时报错]

[root@gitserver /]# git clone git@sihyemama.com:root/beauty.git
正克隆到 'beauty'...
ssh: Could not resolve hostname sihyemama.com: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决: 1. 确认本地解析是否正确 2.确认服务器端是否有收到密钥

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值