Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build jenkins Master-Slave Cluster

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to build jenkins master-slave cluster". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to build jenkins master-slave cluster".

1. Check server package configuration [optional]

Generally speaking, no additional configuration of apt is required. If the configuration is deleted or moved to another location, it will not take effect:

Sudo rm / etc/apt/apt.confsudo apt-get update2. Install JDK

Jenkins relies on java, installs the java8+ version, and configures java_home:

Sudo apt search openjdksudo apt-get install openjdk-8-jdksudo vim / etc/bash.bashrcexport JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/3. Install jenkins

Install in a ubuntu environment:

Wget-Q-O-https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add-sudo sh-c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > / etc/apt/sources.list.d/jenkins.list'sudo apt-get updatesudo apt-get install jenkins

Some default file locations:

Path description / etc/default/jenkinsjenkins running configuration jenkins default file user / var/log/jenkins/jenkins.log log path / var/lib/jenkins/jenkins home4. Advanced Settin

Crowd 2 Integration

Configure slave

Create a new node

Configure node startup mode: start the agent through Java Web. Note that this option is optional only if the TCP port of the JNLP proxy protocol is set in the global security configuration.

View the salve page to download the agent.jar and slave-agent.jnlp files and put them in the jenkins_home directory of the salve server

Log in to the salve server to switch to the jenkins user, and run the previous salve page to execute the command, such as: java-jar agent.jar-jnlpUrl http://slave.server.ip:8080/computer/slave-01/slave-agent.jnlp-secret 2a99268dbfc5d5f4c517d237d48078b1163f-workDir "/ var/lib/jenkins/"

Integration of GitLab and Jenkins

URL: task location of Jenkins: http://jenkins-in.devops.com/project/halo-kong

Securet Token: the token generated by the Jenkins obtained in the previous step. You can click Test to test it after wearing it.

Jenkins selects a pipeline task, Build Triggers- > Advanced-> Secret token, and generates a token

Gitlab select a project, Setting- > Integrations, and create a new webhook, where

5. Encounter problems

Blank page

Solution: sudo / etc/init.d/jenkins restart

Configure the daemon for agent (otherwise java-jar agent.jar.... The cluster collapsed after the command was interrupted)

Sudo easy_install supervisorecho_supervisord_conf > supervisord.confsudo mv supervisord.conf / etc/supervisord.confsudo vim / etc/supervisord.conf # modify include to files = / etc/supervisor/*.confsudo mkdir-p / etc/supervisorsudo vim / etc/supervisor/jenkins-slave-agent.conf

Jenkins-slave-agent.conf:

[program:jsa] directory = / var/lib/jenkins/command = java-jar agent.jar-jnlpUrl http://slave.server.ip:8080/computer/slave-01/slave-agent.jnlp-secret 2a99268dbfc5d5f4c517d237d48078b1163f-workDir "/ var/lib/jenkins/" autostart = trueautorestart = trueuser = jenkinsredirect_stderr = truestdout_logfile = / var/lib/jenkins/jenkins-slave-agent.log

Supervisorctl commond:

Sudo supervisorctl reread # read new configuration sudo supervisorctl update # start update sudo supervisorctl status # check status sudo supervisorctl stop jsa # stop a child process sudo supervisorctl start jsa # start a child process sudo supervisorctl restart jsa # restart a child process

Running a docker-compose build report on agent node failed to connect to http+docker://localhost docker

Reason: permissions

Solution: sudo chown jenkins:docker / var/run/docker.sock

Run the docker push report no basic auth credentials on agent node

Reason: incorrect location of load credential file

Solution: specify the location of the load permissions file, such as: docker-- config / var/lib/jenins/ push xxxxx

Configure the branch that dynamically switches to the push

Reason: fixed branches are configured by default, but not if you need to configure branches dynamically

Solution: use some of the variables built into the gitlab plug-in, such as switching with gitlabSourceBranch variables combined with checkout, such as

Checkout ([$class: 'GitSCM', branches: [[name:' ${gitlabSourceBranch}']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [credentialsId: 'gitlab-user', url:' http://git.devops.com/devops/devops.git']]]) thank you for your reading. This is the content of "how to build a jenkins Master-Slave Cluster". After the study of this article, I believe you have a deeper understanding of how to build a jenkins master-slave cluster, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report