系统配置
节点jenkins配置
[root@localhost ~]# hostnamectl set-hostname jenkins
[root@localhost ~]# ip a|grep inet|grep -v inet6
inet 127.0.0.1/8 scope host lo
inet 192.168.73.115/24 brd 192.168.73.255 scope global dynamic noprefixroute ens160
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 9.1 (Plow)
节点jenkins-node1配置
[root@localhost ~]# hostnamectl set-hostname jenkins-node1
[root@localhost ~]# ip a|grep inet|grep -v inet6
inet 127.0.0.1/8 scope host lo
inet 192.168.73.116/24 brd 192.168.73.255 scope global dynamic noprefixroute ens160
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 9.1 (Plow)
节点jenkins-node2配置
[root@localhost ~]# hostnamectl set-hostname jenkins-node2
[root@localhost ~]# ip a|grep inet|grep -v inet6
inet 127.0.0.1/8 scope host lo
inet 192.168.73.117/24 brd 192.168.73.255 scope global dynamic noprefixroute ens160
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 9.1 (Plow)
jenkins安装
包位置
https://github.com/jenkinsci/jenkins/releases/download/jenkins-2.440/jenkins.war
数据存储及启动脚本
#!/bin/bash
# 设置数存储目录
# set JENKINS_HOME=/data/jenkins/jenkinsdata
# 启动
nohup java -jar /data/jenkins/jenkins.war >> /data/jenkins/jenkins.log &
设置数存储目录
[root@jenkins jenkins]# pwd
/data/jenkins
[root@jenkins jenkins]# mkdir -p /data/jenkins/jenkinsdata
[root@jenkins jenkins]# useradd -s /sbin/nologin jenkins
[root@jenkins jenkins]# chown -R jenkins:jenkins /data/jenkins/jenkinsdata
[root@jenkins jenkins]# echo "export JENKINS_HOME=/data/jenkins/jenkinsdata" >> ~/.bashrc
[root@jenkins jenkins]# source ~/.bashrc
启动jenkins
[root@jenkins jenkins]# yum -y install java-11-openjdk.x86_64
[root@jenkins jenkins]# chmod 755 start.sh
[root@jenkins jenkins]# sh -x start.sh
[root@jenkins jenkins]# tail -f jenkins.log
初始密码
[root@jenkins jenkins]# cat /data/jenkins/jenkinsdata/secrets/initialAdminPassword
14293137df58473484a585224ced15ce
访问地址
http://192.168.73.115:8080
添加jenkins节点
从节点安装jdk
[root@jenkins-node1 data]# yum -y install java-11-openjdk.x86_64
[root@jenkins-node2 data]# yum -y install java-11-openjdk.x86_64
主要节点配置ssh连接的环境
# 创建 known_hosts 文件
[root@jenkins jenkins]# mkdir -p /root/.ssh
[root@jenkins jenkins]# touch /root/.ssh/known_hosts
# 添加远程服务器的公钥
[root@jenkins jenkins]# ssh-keyscan -H 192.168.73.116 >> /root/.ssh/known_hosts
[root@jenkins jenkins]# ssh-keyscan -H 192.168.73.117 >> /root/.ssh/known_hosts
# known_hosts 文件授权
[root@jenkins jenkins]# chmod 644 /root/.ssh/known_hosts
创建从节点ssh连接的凭证
添加从节点
以同样的步骤添加节点jenkins-node2
节点添加成功