标签:远程 rem following lin tor toc pre legacy 节点管理
本套教程均全部使用容器来部署,传统部署请自行搜索。
运行环境:
CentOS Linux release 7.6.1810 (Core)
Docker Version: 18.09.9
可正常访问互联网
关闭防火墙和selinux
我们下载LTS版本
LTS是长期支持版本
docker run --name devops-jenkins --user=root -p 8080:8080 -p 50000:50000 -v /opt/data/jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock -v /usr/local/bin/docker:/usr/bin/docker -d jenkins/jenkins:lts
启动一个名为devops-jenkins
的容器
它的用户名为root
将宿主机8080
端口与容器内部8080
映射
我们将Jenkins相关配置文件挂载出来方便修改
进入Jenkins安装目录
编辑hudson.model.UpdateCenter.xml 文件
将其改成
<?xml version=‘1.1‘ encoding=‘UTF-8‘?>
<sites>
<site>
<id>default</id>
<url>https://updates.jenkins-zh.cn/update-center.json</url>
</site>
</sites>
需要配置对应密钥
进入
cd war/WEB-INF/update-center-rootCAs/
删除文件夹内密钥文件
rm -rf *
在文件内创建一个名为mirror-adapter.crt密钥文件
密钥文件写入以下内容
-----BEGIN CERTIFICATE-----
MIICcTCCAdoCCQD/jZ7AgrzJKTANBgkqhkiG9w0BAQsFADB9MQswCQYDVQQGEwJD
TjELMAkGA1UECAwCR0QxCzAJBgNVBAcMAlNaMQ4wDAYDVQQKDAV2aWhvbzEMMAoG
A1UECwwDZGV2MREwDwYDVQQDDAhkZW1vLmNvbTEjMCEGCSqGSIb3DQEJARYUYWRt
aW5AamVua2lucy16aC5jb20wHhcNMTkxMTA5MTA0MDA5WhcNMjIxMTA4MTA0MDA5
WjB9MQswCQYDVQQGEwJDTjELMAkGA1UECAwCR0QxCzAJBgNVBAcMAlNaMQ4wDAYD
VQQKDAV2aWhvbzEMMAoGA1UECwwDZGV2MREwDwYDVQQDDAhkZW1vLmNvbTEjMCEG
CSqGSIb3DQEJARYUYWRtaW5AamVua2lucy16aC5jb20wgZ8wDQYJKoZIhvcNAQEB
BQADgY0AMIGJAoGBAN+6jN8rCIjVkQ0Q7ZbJLk4IdcHor2WdskOQMhlbR0gOyb4g
RX+CorjDRjDm6mj2OohqlrtRxLGYxBnXFeQGU7wWjQHyfKDghtP51G/672lXFtzB
KXukHByHjtzrDxAutKTdolyBCuIDDGJmRk+LavIBY3/Lxh6f0ZQSeCSJYiyxAgMB
AAEwDQYJKoZIhvcNAQELBQADgYEAD92l26PoJcbl9GojK2L3pyOQjeeDm/vV9e3R
EgwGmoIQzlubM0mjxpCz1J73nesoAcuplTEps/46L7yoMjptCA3TU9FZAHNQ8dbz
a0vm4CF9841/FIk8tsLtwCT6ivkAi0lXGwhX0FK7FaAyU0nNeo/EPvDwzTim4XDK
9j1WGpE=
-----END CERTIFICATE-----
重启Jenkins即可正常安装插件
进入管理页面后
填写节点名称
我获取到的secret-token
-secret c479f0044b37421ab5576580b774d3e3469ba971758956526b86300c7359f141
我们需要以下镜像
https://hub.docker.com/r/jenkins/jnlp-slave
官方给出在linux运行jenkins-agent命令
docker run --init jenkins/inbound-agent -url http://jenkins-server:port <secret> <agent name>
Note: --init
is necessary for correct subprocesses handling (zombie reaping)
初始化镜像要添加--init
为了防止僵尸进程
运行命令:
docker run --init jenkins/jnlp-slave -url http://39.100.134.17:8080 -workDir=/opt/java c479f0044b37421ab5576580b774d3e3469ba971758956526b86300c7359f141 build
运行结果
Jul 15, 2020 2:14:46 AM hudson.remoting.jnlp.Main createEngine
INFO: Setting up agent: build
Jul 15, 2020 2:14:46 AM hudson.remoting.jnlp.Main$CuiListener <init>
INFO: Jenkins agent is running in headless mode.
Jul 15, 2020 2:14:46 AM hudson.remoting.Engine startEngine
INFO: Using Remoting version: 4.3
Jul 15, 2020 2:14:46 AM hudson.remoting.Engine startEngine
WARNING: No Working Directory. Using the legacy JAR Cache location: /home/jenkins/.jenkins/cache/jars
Jul 15, 2020 2:14:47 AM hudson.remoting.jnlp.Main$CuiListener status
INFO: Locating server among [http://39.100.134.17:8080]
Jul 15, 2020 2:14:47 AM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
INFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping]
Jul 15, 2020 2:14:47 AM hudson.remoting.jnlp.Main$CuiListener status
INFO: Agent discovery successful
Agent address: 39.100.134.17
Agent port: 50000
Identity: ca:fe:53:c4:9f:a5:1e:a4:72:68:59:ad:ad:dc:bd:49
Jul 15, 2020 2:14:47 AM hudson.remoting.jnlp.Main$CuiListener status
INFO: Handshaking
Jul 15, 2020 2:14:47 AM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connecting to 39.100.134.17:50000
Jul 15, 2020 2:14:47 AM hudson.remoting.jnlp.Main$CuiListener status
INFO: Trying protocol: JNLP4-connect
Jul 15, 2020 2:14:47 AM hudson.remoting.jnlp.Main$CuiListener status
INFO: Remote identity confirmed: ca:fe:53:c4:9f:a5:1e:a4:72:68:59:ad:ad:dc:bd:49
Jul 15, 2020 2:14:48 AM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connected
最后看到Connected基本上连接成功了
出现问题请查看端口8080与50000端口是否放行
目前是前台输出我们把它放入后台容器中执行
docker run -dit jenkins/jnlp-slave -url http://39.100.134.17:8080 -workDir=/opt/java c479f0044b37421ab5576580b774d3e3469ba971758956526b86300c7359f141 build
查看节点页面是否正常连接
首先需要先安装Docker
插件
https://plugins.jenkins.io/docker-plugin/
或在jenkins插件管理中搜索Docker
插件并安装
docker开启API远程访问
https://blog.csdn.net/longzhanpeng/article/details/82217398
#vim /usr/lib/systemd/system/docker.service
* * * * 省略
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
* * * * 省略
重启加载Docker
systemctl daemon-reload
systemctl restart docker
测试一下
curl http://localhost:2375/version
设置一些腾讯云或阿里云的安全策略和防火墙
标签:远程 rem following lin tor toc pre legacy 节点管理
原文地址:https://www.cnblogs.com/iXiAo9/p/13636965.html