In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to build a Jenkins cluster quickly". In the daily operation, I believe many people have doubts about how to build a Jenkins cluster quickly. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to build a Jenkins cluster quickly". Next, please follow the editor to study!
About Jenkins Cluster
When performing multiple tasks on Jenkins at the same time, the performance of a single machine may reach a bottleneck. Using Jenkins cluster can effectively solve this problem. Allowing multiple machines to deal with these tasks at the same time can disperse the pressure and disperse the hidden danger of a single point of failure of a stand-alone version of Jenkins. Today, we will quickly build a Jenkins cluster in actual combat. The Jenkins version is 2.190.2.
How to build a cluster quickly
With Docker, you can save most of the preparation work. You only need to install docker on the Linux computer, and you can complete the cluster construction with a few commands and operations.
Environmental information
A total of three computers will be used in this actual combat environment, and their settings are all the same, as follows:
Operating system: CentOS Linux release 7.6.1810
Firewall off
Docker:1.13.1
The information of the three computers is as follows: | hostname | IP address | function |-| master | 192.168.133.131 | master node of Jenkins cluster, which provides web service | | agent1 | 192.168.133.132 | No.1 worker node of Jenkins cluster. The label is maven | | agent2 | 192.168.133.133 | No.2 worker node of Jenkins cluster, labeled with gradle |
It is recommended that the memory of the agent2 node is more than 4G, because the next practical operation will be compiled with agent2 to build spring-framework, which requires a little more memory.
Preparatory work
All subsequent operations are root accounts.
Create a folder / usr/local/jenkins on each computer
Create a master for Jenkins
Log in to the master machine and execute the following command:
Docker run\-u root\-idt\-name master\-p 8080 idt 8080\-p 50000 usr/local/jenkins:/var/jenkins_home 50000\-v / var/run/docker.sock:/var/run/docker.sock\ jenkinsci/blueocean:1.19.0
Execute docker logs master, and the login key of jenkins will be displayed in the console, as shown in the red box below:
Enter the browser address: http://192.168.133.131:8080, and display the Jenkins login page, as shown in the following figure. Enter the login key just copied in the red box to log in:
Choose to install the recommended plug-ins:
Wait for the plug-in to be installed online:
The next step is to create an administrator and use the instance url. I won't say much here, and you can make your own decisions according to the actual situation.
At this point, the master of Jenkins has been set up, and then agent1 and agent2 are added to the cluster as working nodes.
Join agent1
Add a node to the Jenkins page. Do the following to enter the node management page:
As shown in the following figure, a new node named agent1 is added:
The next node details are shown in the following figure. Note that the contents in the four red boxes should be consistent with those in the figure:
After successful saving, a list of machines will be displayed, as shown below. The red cross on the icon indicates that the machine is not online (agent1 is not connected yet). Click the red box:
As shown in the following figure, the command in the red box is the startup command of agent1, and the machine executing the command will join the cluster as agent1:
Note that agent.jar in the red box above is a download link to a file called agent.jar. Download this file to the / usr/local/jenkins directory on your agent1 computer.
Ssh logs in to the agent1 computer and executes the following command to add agent1 to the Jenkins cluster:
Docker run\-u root\-idt\-- name agent\-v / usr/local/jenkins:/usr/local/jenkins\ bolingcavalry/openjdk-with-sshpass:8u232\ java-jar / usr/local/jenkins/agent.jar\-jnlpUrl http://192.168.133.131:8080/computer/agent1/slave-agent.jnlp\-secret 44c3e8d1531754b8655b53294bbde6dd99b3aaa91a250092d0d3425534ae1058\-workDir "/ usr/local/jenkins"
The latter part of the above command, namely java-jar. Is the agent1 startup command in the red box of the previous picture, the only thing to change is to change the agent.jar to the absolute path / usr/local/jenkins/agent.jar 8. The image of the above command is bolingcavalry/openjdk-with-sshpass:8u232, and its Dockerfile content is as follows. It is very simple to see that sshpass is installed in the OpenJDK image. Such a container can carry the password of the remote machine when executing the ssh command without waiting for the user to enter the password. This facilitates the shell script to execute the ssh command:
FROM openjdk:8u232ARG DEBIAN_FRONTEND=noninteractiveRUN apt-get update & & apt-get install-- assume-yes sshpass
Go to the Jenkins page to view the list of nodes, as shown in the following figure, you can see that agent1 has been successfully added:
Join agent2
Agent2 joins the cluster in the same way as agent1. Only the following two points should be noted:
Create a node on the Jenkins page with the name agent2
The label of agent2 is gradle, as shown in the red box of the following figure:
At this point, agent2 has also joined successfully:
At this point, the study on "how to build a Jenkins cluster quickly" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.