目录
防火墙开通访问端口
centos8查看防火墙开放的端口
firewall-cmd --zone=public --list-ports
开通5432端口
firewall-cmd --zone=public --add-port=5432/tcp --permanent
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=public --add-port=22/tcp --permanent
firewall-cmd --reload 重启生效
查找原始jdk包
rpm -qa "*jdk*"
移除低版本jdk
rpm -e java-1.8.0-openjdk-headless-1.8.0.362.b08-3.el8.x86_64
yum remove
安装支持的版本
yum -y install java-11-openjdk-devel
[root@localhost init.d]# cat /etc/yum.repos.d/jenkins.repo
[jenkins]
name=Jenkins-stable
baseurl=http://pkg.jenkins.io/redhat-stable
gpgcheck=1
yum install -y jenkins
或者直接下载rpm包
wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat-stable/jenkins-2.375.1-1.1.noarch.rpm
rpm -ivh jenkins-2.375.1-1.1.noarch.rpm
[root@jenkins download]# /etc/init.d/jenkins start
Starting jenkins (via systemctl): [ OK ]
[root@jenkins download]#
[root@jenkins download]#
[root@jenkins download]#
[root@jenkins download]#
[root@jenkins download]# ps -ef | grep jenkins
jenkins 5627 1 0 20:18 ? 00:00:00 /etc/alternatives/java -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
root 5647 5501 0 20:20 pts/0 00:00:00 grep --color=auto jenkins
[root@jenkins download]#
[root@jenkins ~]# netstat -untalp | grep 8080
tcp6 0 0 :::8080 :::* LISTEN 6106/java
[root@jenkins ~]#
Jenkins的目录介绍
[root@jenkins ~]# rpm -ql jenkins
/etc/init.d/jenkins #启动文件存放位置
/etc/logrotate.d/jenkins #日志分割配置文件
/etc/sysconfig/jenkins #Jenkins主配置文件
/usr/lib/jenkins
/usr/lib/jenkins/jenkins.war #war包存放目录,war包就是把网站站点打个包
/usr/sbin/rcjenkins #Jenkins的命令
/var/cache/jenkins #war包解压目录,Jenkins网页代码目录
/var/lib/jenkins #Jenkins的工作目录,Jenkins的配置就在这个目录
/var/log/jenkins #Jenkins的日志存放目录
[root@jenkins ~]#
修改Jenkins密码(我们在安装Jenkins的时候就发现Jenkins存放初始密码存放位置是:/var/lib/jenkins/secrets/initialAdminPassword)
(我们在安装Jenkins的时候就发现Jenkins存放初始密码存放位置是:/var/lib/jenkins/secrets/initialAdminPassword)
设置
修改密码
点击注销
使用新密码登录Jenkins
[root@jenkins download]# ll
total 160580
-rw-r--r-- 1 root root 164431230 Sep 3 06:02 jenkins-plugins.tar.gz
[root@jenkins download]#
[root@jenkins download]# ll /var/lib/jenkins/plugins/ #查看存放Jenkins插件包的目录
total 0
[root@jenkins download]#
[root@jenkins download]# tar xfP jenkins-plugins.tar.gz #解压Jenkins插件包
[root@jenkins download]#
[root@jenkins download]# ll
total 160592
-rw-r--r-- 1 root root 164431230 Sep 3 06:02 jenkins-plugins.tar.gz
drwxr-xr-x 97 jenkins jenkins 8192 Dec 8 2017 plugins
[root@jenkins download]#
[root@jenkins download]# ll plugins/ | wc -l #插件包共计文件数是191个
191
[root@jenkins download]#
[root@jenkins download]# cp -a plugins/* /var/lib/jenkins/plugins/ #将解压后的文件拷贝到Jenkins存放插件包的目录
[root@jenkins download]#
[root@jenkins download]# ll /var/lib/jenkins/plugins/ | wc -l
191
[root@jenkins download]#
[root@jenkins download]# /etc/init.d/jenkins restart #重启Jenkins服务
Restarting jenkins (via systemctl): [ OK ]
[root@jenkins download]#
配置GitLab Push 自动触发Jenkins构建
参考链接:https://www.cnblogs.com/yinzhengjie/p/9613270.html
在Jenkins后端生成秘钥对
[root@jenkins ~]# ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
[root@jenkins ~]# ssh-keygen -t rsa -b 2048 -C "email@example.com"
Generating public/private rsa key pair.
Created directory '/root/.ssh'.
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:
e1:75:1f:cf:18:02:5e:b7:16:99:14:75:56:73:ac:ad root@jenkins.yinzhengjie.org.cn
The key's randomart image is:
+--[ RSA 2048]----+
| . ..=BB|
| . o .o+=|
| . o o =o |
| . o . +.*.|
| S o.o|
| E |
| |
| |
| |
+-----------------+
[root@jenkins ~]#
查看服务端的公钥和私钥
[root@jenkins ~]# cat /root/.ssh/id_rsa.pub #查看公钥
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCwr6GMG0OYSWyLcraC4FGquTm9C+26a2/SdTysXOTiC6GpqYE9L57NgCSJSYWFalj+s/O6+LqHLY/ORi+LMmh4DtYSD4rUYo5NRd68B3lVs2JU8FqfCK/bJR+Sy/SxDAtKfrP/8gPM+4saB9JXUaljavhwIsyqMJxLkbwmDsdYmf4MHjMoHA4k8qECYKfvL7mep3Cglh0U4dQTubVvjmN/f6oKX7l7yVe+DoSImPyYae16+8AOe0v8+hiL5zB8eBBuCJZfXT/ZQbp5pAWxNCiiHsLI9VQhjsmsLS+bpgEvnCDqbVuXhrYXaLrQDm2EG2YwU1YSES6gJrvs5OkMbwXr root@jenkins.yinzhengjie.org.cn
[root@jenkins ~]#
[root@jenkins ~]#
[root@jenkins ~]# cat /root/.ssh/id_rsa #查看私钥
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAsK+hjBtDmElsi3K2guBRqrk5vQvtumtv0nU8rFzk4guhqamB
PS+ezYAkiUmFhWpY/rPzuvi6hy2PzkYvizJoeA7WEg+K1GKOTUXevAd5VbNiVPBa
nwiv2yUfksv0sQwLSn6z//IDzPuLGgfSV1GpY2r4cCLMqjCcS5G8Jg7HWJn+DB4z
KBwOJPKhAmCn7y+5nqdwoJYdFOHUE7m1b45jf3+qCl+5e8lXvg6EiJj8mGntevvA
DntL/PoYi+cwfHgQbgiWX10/2UG6eaQFsTQooh7CyPVUIY7JrC0vm6YBL5wg6m1b
l4a2F2i60A5thBtmMFNWEhEuoCa77OTpDG8F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+cWVilZaLl/
JMQq5wKBgQC41olS3GTRuPdNoZCI9rWaR30XafVv3EV7XmAnytNJGJv/VY00a1fk
fXWIUTG/AYQ932qBZQ/PL9eobtuvrZxRj7Xt8p6O6ERRk4mqRERHF+E6yEFdzKef
rXfkvpqaZ63aTLjeolEiVO/Vud6ZEcc6UkpBnajgN1e5vapXARL9pA==
-----END RSA PRIVATE KEY-----
[root@jenkins ~]#
将Jenkins服务器端的公钥上传到GitLab中
Private token 自动构建
配置GitLab Push 自动触发Jenkins构建
参考链接
https://www.cnblogs.com/yinzhengjie/p/9613270.html
二.配置GitLab认证
2>.点击认证
3>.在GitLab中复制“Private token”的值
4>将GitLab的“Private token”的值复制到Jenkins的API token中。
5>.认证添加成功的界面
6>.进入系统设置界面
7>.测试连接(由于我们通过API认证的,所以必须得用http协议,测试成功后别忘记保存哟!)
8>.如果上述配置成功,我们再次编辑我们之前的项目
9>.点击之前的项目
10>.点击构建触发器
11>.拷贝Jenkins生成的随机字符串(在完成第十三步后回来保存它!)
12>.进入到GitLab中的“Integrations Settings”
13>.添加GitLab的“System hook”(注意图中的URL和Token信息均来第11步骤)
14>测试添加的webhook
三.修改GitLab的数据,简称服务器端是否有文件生成
1>.在GitLab的webUI界面中我们添加新的文件
2>.编辑文件内容并提交
3>.提交成功界面如下
4>.观察Jenkins是否持续有任务运行
5>.服务器端指定目录是否有文件生成
一.安装GitLab插件
在GitLab中复制“Private token”的值
https://www.cnblogs.com/yinzhengjie/p/9602029.html
(如果是虚拟机建议将Jenkins的服务器内存设置较大,这个执行者数量调的越大它就会越消耗系统资源),别忘记点击保存按钮哟!
1.做hostname 修改为域名,ipaserver 服务器都做好解析
2.安装freeipa
yum install -y ipa-client
3.可能有相关依赖包错误
下载指定安装包地址https://rpmfind.net/linux/rpm2html/search.php?query=iftop&submit=Search+...&system=&arch=
wget 包名
4.在下载下来的包目录本地安装
yum localinstall 包名
5.安装
ipa-client-install --unattended --mkhomedir --enable-dns-updates --principal admin@TEST.COM
6.如果报错,按照提示安装操作
ipa-client-install
准备环境
master节点:192.168.247.130 (已安装Jenkins)
agent节点:192.168.247.131
1.在master节点创建ssh key
ssh-keygen -t rsa
一路回车
2.发送公钥到agent服务器,并输入agent服务器 密码
ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.247.131
3.测试master节点免密登陆agent
ssh 192.168.247.131
Jenkins选择:系统管理→manage credentials
cat ~/.ssh/id_rsa
保存凭据
mkdir -p /data/workspaces
stderr: No ECDSA host key is known for gitlabtest.test.com and you have requested strict checking.
Warning: Permanently added the ECDSA host key for IP address '154.213.2.253' to the list of known hosts.
显示密钥不生效
1. 生成证书
添加完以后依然会报错
jenkins stderr: No ECDSA host key is known for gitee.com and you have requested strict checking.
这是因为ssh连接陌生机器需要确认,将clone代码的机器上的known_hosts复制到运行jenkins服务账号的~/.ssh目录下即可
2.判断Jenkins是那个用户运行的
# ps aux | grep jenkins
root@april:~# ps aux | grep jenkins
jenkins 10106 0.1 25.4 2753696 498056 ? Ssl Aug14 7:31 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080
root 22337 0.0 0.0 14436 1100 pts/1 S+ 10:08 0:00 grep --color=auto jenkins
root@april:~# cat /etc/passwd | grep jenkins
jenkins:x:112:121:Jenkins,,,:/var/lib/jenkins:/bin/bash
root@april:~#
以上命令可以看到运行jenkins服务的账号为jenkins,其home为/var/lib/jenkins
#处理步骤
切换到Jenkins用户下,生成密钥
su -s /bin/bash jenkins
ssh-keygen -t rsa
cd
cat .ssh/id_rsa.pub
cat .ssh/id_rsa
按照提示生成这个文件即可
known_hosts
手机扫一扫
移动阅读更方便
你可能感兴趣的文章