首页 > 系统相关 >Jenkins - 在Rocky Linux系统下安装Jenkins和配置Agent节点

Jenkins - 在Rocky Linux系统下安装Jenkins和配置Agent节点

时间:2024-09-02 22:36:57浏览次数:10  
标签:02 remoting Rocky Sep Agent jenkins Jenkins root localhost

安装Jenkins

主节点下载和安装Jenkins LTS版本

本机信息

[root@localhost ~]# cat /etc/system-release
Rocky Linux release 9.4 (Blue Onyx)
[root@localhost ~]# 
[root@localhost ~]# uname -a
Linux localhost.localdomain 5.14.0-427.33.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 28 17:34:59 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# 

官方安装文档
https://www.jenkins.io/doc/book/installing/linux/#red-hat-centos

下载和安装Jenkins LTS版本

wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
yum upgrade
yum install fontconfig java-17-openjdk -y
yum install jenkins
systemctl daemon-reload

确认版本

[root@localhost ~]# java -version
openjdk version "17.0.12" 2024-07-16 LTS
OpenJDK Runtime Environment (Red_Hat-17.0.12.0.7-1) (build 17.0.12+7-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-17.0.12.0.7-1) (build 17.0.12+7-LTS, mixed mode, sharing)
[root@localhost ~]# 
[root@localhost jenkins]# java -jar /usr/share/java/jenkins.war --version
2.462.1
[root@localhost jenkins]#

一些网络配置

关闭防火墙

 systemctl stop firewalld
 systemctl disable firewalld

关闭SELINUX

[root@localhost ~]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Memory protection checking:     actual (secure)
Max kernel policy version:      33
[root@localhost ~]# 
[root@localhost ~]# vim /etc/sysconfig/selinux
[root@localhost ~]# cat /etc/sysconfig/selinux |grep "SELINUX=" |grep -v "#"
SELINUX=disabled
[root@localhost ~]# 
[root@localhost ~]# reboot
[root@localhost ~]# 
[root@localhost ~]# sestatus
SELinux status:                 disabled
[root@localhost ~]# 

启动和初始化Jenkins

启动Jenkins

[root@localhost ~]# systemctl enable jenkins
Created symlink /etc/systemd/system/multi-user.target.wants/jenkins.service → /usr/lib/systemd/system/jenkins.service.
[root@localhost ~]# systemctl start jenkins
[root@localhost ~]# systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
     Loaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled; preset: disabled)
     Active: active (running) since Mon 2024-09-02 10:36:06 CST; 8s ago
   Main PID: 42838 (java)
      Tasks: 51 (limit: 48820)
     Memory: 551.8M
        CPU: 28.391s
     CGroup: /system.slice/jenkins.service
             └─42838 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080

Sep 02 10:35:56 localhost.localdomain jenkins[42838]: 502ee818dd62450f9f0a4156a90f5e95
Sep 02 10:35:56 localhost.localdomain jenkins[42838]: This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword
Sep 02 10:35:56 localhost.localdomain jenkins[42838]: *************************************************************
Sep 02 10:35:56 localhost.localdomain jenkins[42838]: *************************************************************
Sep 02 10:35:56 localhost.localdomain jenkins[42838]: *************************************************************
Sep 02 10:36:06 localhost.localdomain jenkins[42838]: 2024-09-02 02:36:06.367+0000 [id=34]        INFO        jenkins.InitReactorRunner$1#on>
Sep 02 10:36:06 localhost.localdomain jenkins[42838]: 2024-09-02 02:36:06.388+0000 [id=24]        INFO        hudson.lifecycle.Lifecycle#onR>
Sep 02 10:36:06 localhost.localdomain systemd[1]: Started Jenkins Continuous Integration Server.
Sep 02 10:36:07 localhost.localdomain jenkins[42838]: 2024-09-02 02:36:07.459+0000 [id=49]        INFO        h.m.DownloadService$Downloadab>
Sep 02 10:36:07 localhost.localdomain jenkins[42838]: 2024-09-02 02:36:07.460+0000 [id=49]        INFO        hudson.util.Retrier#start: Per>
[root@localhost ~]# 

初始配置Jenkins

  1. 浏览器访问页面 http://192.168.16.200:8080/
  2. 根据提示查看初始登录密码:cat /var/lib/jenkins/secrets/initialAdminPassword
  3. 配置插件:默认不选,需要时再安装
  4. 创建第一个管理员用户
  5. 完成初始化

安装和配置Jenkins Agent节点

在主节点配置Node

登录Jenkins页面:Dashboard --》Manage Jenkins --》Nodes,依次进行选项配置

  • Name: JenkinsAgent-Build01
  • Description: Build agent node - 01
  • Number of executors: 5
  • Remote root directory: /opt/JenkinsAgent
  • Labels: build maven linux
  • Usage: Only build jobs with label expressions matching this node
  • Launch method: Launch agent by connecting it to the controller
  • Availability: Keep this agent online as much as possible
  • Node Properties: null

主节点开启TCP端口
Dashboard --> Manage Jenkins --> Security --> Agents --> TCP port for inbound agents --> 选择 Fixed --> 添加端口 12345

在Node主机上配置Agent节点

在主节点上可以查看到需要在Node主机执行的命令
Dashboard --》Manage Jenkins --》Nodes --》JenkinsAgent-Build01

# Run from agent command line: (Unix) 
mkdir /opt/JenkinsAgent
cd /opt
curl -sO http://192.168.16.200:8080/jnlpJars/agent.jar
java -jar agent.jar -url http://192.168.16.200:8080/ -secret 4e1e31e059bbb8248e90e07acace1d084b04756a62c253c1a0680c0b3513b75a -name "JenkinsAgent-Build01" -workDir "/opt/JenkinsAgent"

关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

关闭SELINUX

[root@localhost ~]# vim /etc/sysconfig/selinux
[root@localhost ~]# cat /etc/sysconfig/selinux |grep "SELINUX=" |grep -v "#"
SELINUX=disabled
[root@localhost ~]# reboot
[root@localhost ~]# sestatus
SELinux status:                 disabled
[root@localhost ~]# 

推荐以nohup方式启动Jenkins Agent

nohup java -jar agent.jar -url http://192.168.16.200:8080/ -secret 4e1e31e059bbb8248e90e07acace1d084b04756a62c253c1a0680c0b3513b75a -name "JenkinsAgent-Build01" -workDir "/opt/JenkinsAgent" &

Agent启动日志

[root@localhost opt]# java -jar agent.jar -url http://192.168.16.200:8080/ -secret 4e1e31e059bbb8248e90e07acace1d084b04756a62c253c1a0680c0b3513b75a -name "JenkinsAgent-Build01" -workDir "/opt/JenkinsAgent"
Sep 02, 2024 12:57:31 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using /opt/JenkinsAgent/remoting as a remoting work directory
Sep 02, 2024 12:57:31 PM org.jenkinsci.remoting.engine.WorkDirManager setupLogging
INFO: Both error and output logs will be printed to /opt/JenkinsAgent/remoting
Sep 02, 2024 12:57:31 PM hudson.remoting.Launcher createEngine
INFO: Setting up agent: JenkinsAgent-Build01
Sep 02, 2024 12:57:31 PM hudson.remoting.Engine startEngine
INFO: Using Remoting version: 3248.3250.v3277a_8e88c9b_
Sep 02, 2024 12:57:31 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using /opt/JenkinsAgent/remoting as a remoting work directory
Sep 02, 2024 12:57:31 PM hudson.remoting.Launcher$CuiListener status
INFO: Locating server among [http://192.168.16.200:8080/]
Sep 02, 2024 12:57:32 PM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
INFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping]
Sep 02, 2024 12:57:32 PM hudson.remoting.Launcher$CuiListener status
INFO: Agent discovery successful
  Agent address: 192.168.16.200
  Agent port:    12345
  Identity:      b9:05:31:af:9d:c1:bd:81:f6:97:f1:76:4e:9d:60:5f
Sep 02, 2024 12:57:32 PM hudson.remoting.Launcher$CuiListener status
INFO: Handshaking
Sep 02, 2024 12:57:32 PM hudson.remoting.Launcher$CuiListener status
INFO: Connecting to 192.168.16.200:12345
Sep 02, 2024 12:57:32 PM hudson.remoting.Launcher$CuiListener status
INFO: Server reports protocol JNLP4-connect-proxy not supported, skipping
Sep 02, 2024 12:57:32 PM hudson.remoting.Launcher$CuiListener status
INFO: Trying protocol: JNLP4-connect
Sep 02, 2024 12:57:34 PM org.jenkinsci.remoting.protocol.impl.BIONetworkLayer$Reader run
INFO: Waiting for ProtocolStack to start.
Sep 02, 2024 12:57:36 PM hudson.remoting.Launcher$CuiListener status
INFO: Remote identity confirmed: b9:05:31:af:9d:c1:bd:81:f6:97:f1:76:4e:9d:60:5f
Sep 02, 2024 12:57:36 PM hudson.remoting.Launcher$CuiListener status
INFO: Connected

确认状态

查看节点管理界面,现实状态正常
Dashboard --》Manage Jenkins --》Nodes


错误排查

问题现象:agent节点启动报错

Sep 02, 2024 12:50:16 PM hudson.remoting.Launcher$CuiListener status
INFO: Could not locate server among [http://192.168.16.200:8080/]; waiting 10 seconds before retry
java.io.IOException: http://192.168.16.200:8080/tcpSlaveAgentListener/ is invalid: 404 Not Found
        at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:229)
        at hudson.remoting.Engine.innerRun(Engine.java:829)
        at hudson.remoting.Engine.run(Engine.java:574)

需要在管理节点开启TCP端口
Dashboard --> Manage Jenkins --> Security --> Agents --> TCP port for inbound agents --> 选择 Fixed --> 添加端口 12345
正常情况下,浏览器页面访问 http://192.168.16.200:8080/tcpSlaveAgentListener/ 会显示“Jenkins”结果


标签:02,remoting,Rocky,Sep,Agent,jenkins,Jenkins,root,localhost
From: https://www.cnblogs.com/anliven/p/18393681

相关文章

  • 自定义TOOLs(完全体Agent)
    1.Agents包括几个关键组件:-*Agent*:用于生成指令和执行动作的代理。-*Tool*:用于执行动作的函数。-*Memory*:用于存储历史对话和生成的指令。-*LLM*:用于生成指令和执行动作的LLM。2.例如:计算\搜索\知识库检索(多轮对话)fromlangchain.agentsimportload_to......
  • CentOS 8 安装 jenkins、gitlab-ce、SonarQube教程
    一、在CentOS8上安装jenkins在一台CentOS8(IP:10.0.0.81RAM:2GB)上安装jenkins-2.452.41、配置Java环境从Jenkins-2.357版本开始JDK最低要求java11,而jenkins-2.346.1是最后一个支持java1.8的版本。点击查看代码1.先查看系统是否自带了jdk,若有输出信息,批量卸载......
  • LongWriter-6k 数据集开发利用 AgentWrite:一种在LLM中将输出长度扩展到超过10,000字,同
    大语言模型(LLMs)的领域已经取得了巨大的进展,特别是在扩展其记忆容量以处理越来越多的上下文方面。现在这些模型可以处理超过100,000个标记的输入,使得它们能够执行高度复杂的任务,例如生成长篇文本、翻译大型文档和总结大量数据。然而,尽管在处理能力方面取得了这些进展,在生成等长......
  • 解析 Agent 在国外智慧金融领域的一个落地场景:智能顾投
    作者:老余捞鱼原创不易,转载请标明出处及原作者。写在前面的话:    随着这两年蓬勃发展的人工智能技术在金融投资领域和股票证券市场的逐步推广运用,基于金融大模型的智能体(Agent)在智慧顾问投资领域就越来越多引发人们的关注了,本文将简介目前国外将其主要服务于哪些场......
  • 从实在智能最新发布的实在Agent 7.0,看RPA Agent的迭代升级
     智能体进化发展了一年,现在的RPAAgent迭代到什么程度了?从实在智能最新发布的实在Agent7.0,看RPAAgent的迭代升级抓取豆瓣信息、自己制作PPT,这款AIAgent真的实现了流程全自动化AIAgent构建到执行全自动化,持续进化RPAAgent再次降低智能体应用门槛实在智能重磅发布实在......
  • 智能体进化发展了一年,现在的RPA Agent迭代到什么程度了?
    智能体进化发展了一年,现在的RPAAgent迭代到什么程度了?抓取豆瓣信息、自己制作PPT,这款AIAgent真的实现了流程全自动化AIAgent构建到执行全自动化,持续进化RPAAgent再次降低智能体应用门槛C端AIAgent构建与应用实现端到端,这个智能体构建平台真的不一般文/王吉伟智能体的爆发,意味......
  • OpenAI-Agents: 人工智能代理的力量与科技搜索的新方向
    OpenAI-Agents:人工智能代理的力量与科技搜索的新方向在人工智能快速发展的今天,OpenAI-Agents项目为我们展示了AI在生成高质量文本和理解复杂主题方面的惊人能力。这个由AI完全撰写的应用程序和论文集合,不仅体现了人工智能的潜力,更为科研和技术探索开辟了新的方向。让我们深......
  • 100个AI Agent应用场景合集丨来看看Agent能在你的行业做什么
    AIAgent在11个行业中常见的100个应用场景人工智能代理(AIAgent)的发展正在以前所未有的速度改变我们的生活和工作方式。从日常生活的小事到企业级的复杂决策,AIAgent的应用场景广泛且多样。以下是100个AIAgent的创新应用场景,它们展示了AI技术如何渗透到我们......
  • 大模型爆卷,引发硅谷大厂打擂台赛的AI Agent到底是何方神圣?
    AIAgent是何方神圣?让比尔·盖茨在2023年预言:未来五年内有望正式迎来它,彻底改变人类的生产力与生活方式。让吴恩达教授在AIAscent2024演讲中高赞:今年得益于它的工作流的帮助,人工智能的能力范围将持续拓展,所有从事人工智能的人都应该关注这个令人兴奋的新兴趋势。它就......
  • Langchain框架中的Agents全解析:类型、工具与自定义实践
    文章目录前言一、什么是Agents?举个栗子......