1.准备安装环境
192.168.245.180 git
192.168.245.181 jenkins
关闭防火墙 centos 7并且关闭setenforce
[root@localhost ~] systemctl stop firewalld
[root@localhost ~] setenforce 0
2.安装配置文件,上传gitlab数据包并且安装
[root@localhost ~] yum install curl policycoreutils openssh-server openssh-clients -y
[root@localhost ~] yum install postfix -y
[root@localhost ~] systemctl start postfix && systemctl enable postfix
[root@localhost ~]# ls
anaconda-ks.cfg gitlab-ce-13.0.7-ce.0.el7.x86_64.rpm
[root@localhost ~] rpm -ivh gitlab-ce-13.0.7-ce.0.el7.x86_64.rpm
3.修改gitlab配置文件如果是本机可以不用
[root@localhost ~] vim /etc/gitlab/gitlab.rb
g-the-external-url-for-gitlab
external_url 'http://192.168.245.180'
4.启动gitlab查看是否启动
[root@localhost ~] gitlab-ctl reconfigure 启动有点慢不用着急
[root@localhost ~] netstat -nlpt | grep -E '80|8080|80860'
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 65139/nginx: master
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 65139/nginx: master
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 64584/unicorn maste
5.开始测试 输入ip 192.168.245.180
6.创建用户组
7.创建ssh密钥并且查看
[root@localhost ~] ssh-keygen -t rsa -C '2956694705@qq.com'
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:NrSHvCH2UHTc+FZNJF+tNUrlij3eLzsHJRIQ7d3XSWw 2956694705@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| ..+* +==|
| . .o +.oE=|
| o o.++==|
| + o B.=.=|
| + S .o = o.|
| . = = . + |
| o . o |
| o o|
| .=.|
+----[SHA256]-----+
[root@localhost ~]# cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD0TZGLzl8nr0NVWC16UuT/toqYiHT5O+uJjWIaNLK/pyNwJfQaP1yGKGQ47KvVsmRirp9S97iFrQ8oOZ1JnQ7NU0tuAtduSzP7KwfxjQG+uyUBompcy6KdPaZOXPckjH9LMdsFqyfHn4mPYbx8B+k5d/LjQowD8POYPvBuc+TD6qDxH0NLLiJIO7O305jkYcI8EORdBB16Rn/AdilyJXmLVpb94vn9aq5EuzH9cSo6Ce/Vlis0jFR1YShnY9yjwc5g73yDlt0kqvmnoMdeBzz8VYF1zEplwKVDFWd8hOqtKrd+QxNcx+B6lg5biuYDLcT68PHS+4gw0yYdtwnrN2cJ 2956694705@qq.com
[root@localhost ~]#
8.配置gitlab免密登录
测试把服务器仓库clone下来
[root@localhost ~] mkdir demo
[root@localhost ~] cd demo/
[root@localhost demo] ls
[root@localhost demo] git clone git@192.168.245.180:root/xiang.git
正克隆到 'port'...
warning: 您似乎克隆了一个空版本库。
[root@localhost demo]# ls
xiang.git
[root@localhost port] touch READOME.md
[root@localhost port] vi READOME.md
[root@localhost port] git add READOME.md
[root@localhost port] git commit -m "add READDME"
[master(根提交) 3944358] add READDME
1 file changed, 1 insertion(+)
create mode 100644 READOME.md
[root@localhost port]# git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 226 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@192.168.245.180:root/xiang.git
* [new branch] master -> master
分支 master 设置为跟踪来自 origin 的远程分支 master。
[root@localhost port]#
测试
[root@localhost .ssh]# git clone git@192.168.245.180:web/port.git
正克隆到 'port'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
接收对象中: 100% (3/3), done.
[root@localhost .ssh]# ls
id_rsa id_rsa.pub known_hosts port
192.168.245.181 开始安装git jenkins
[root@localhost ~] yum -y install git
已加载插件:fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.neusoft.edu.cn
上传安装jenkins包安装java
作为依赖被升级:
freetype.x86_64 0:2.8-14.el7 glib2.x86_64 0:2.56.1-5.el7
完毕!
[root@localhost ~] yum -y install java
[root@localhost ~] rpm -ivh jenkins-2.222.1-1.1.noarch.rpm
警告:jenkins-2.222.1-1.1.noarch.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID d50582e6: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:jenkins-2.222.1-1.1 ################################# [100%]
安装完成启动jenkins并且查看
[root@localhost ~] systemctl start jenkins
[root@localhost ~] ss -tnl | grep 8080
LISTEN 0 50 :::8080 :::*
进入jenkins
查看jenkins密码
[root@localhost ~] cat /var/lib/jenkins/secrets/initialAdminPassword
776d3a55c6444595a2daa18791bf8e96
这个密码是git的用户密码