搭建jenkins主从集群
1. 检查服务器包配置[可选]
一般不需要apt的额外配置, 如果有删除配置或者移动到别处, 使其不生效:
sudo rm /etc/apt/apt.conf sudo apt-get update
2. 安装JDK
jenkins依赖java, 安装java8+版本,并且配置java_home:
sudo apt search openjdk sudo apt-get install openjdk-8-jdk sudo vim /etc/bash.bashrc export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
3. 安装jenkins
在ubuntu环境下安装:
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 update sudo apt-get install jenkins
一些默认文件位置: |路径|描述| |---|---| |/etc/default/jenkins|jenkins运行配置| |jenkins|默认文件用户| |/var/log/jenkins/jenkins.log|日志路径| |/var/lib/jenkins/|jenkins home|
4. 高级设置
- Crowd 2 Integration
- 配置slave
- 新建node
- 配置node启动方式: 通过Java Web启动代理
- 查看salve页面下载agent.jar 和 slave-agent.jnlp 文件, 并且放到salve服务器的jenkins_home目录下
- 登录salve服务器切换到jenkins用户, 运行上一步salve页面执行命令, 如: java -jar agent.jar -jnlpUrl http://slave.server.ip:8080/computer/slave-01/slave-agent.jnlp -secret 2a99268dbfc5d5f4c517d237d48078b1163f -workDir "/var/lib/jenkins/"
5. 遇到问题
- 空白页面
- 解决方式: sudo /etc/init.d/jenkins restart
- 配置agent的守护进程(否则java -jar agent.jar....命令中断后集群就垮了)
sudo easy_install supervisor echo_supervisord_conf > supervisord.conf sudo mv supervisord.conf /etc/supervisord.conf sudo vim /etc/supervisord.conf # 修改include为files = /etc/supervisor/*.conf sudo mkdir -p /etc/supervisor sudo 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 = true autorestart = true user = jenkins redirect_stderr = true stdout_logfile = /var/lib/jenkins/jenkins-slave-agent.log
- supervisorctl commond:
sudo supervisorctl reread # 读取新配置 sudo supervisorctl update # 启动更新 sudo supervisorctl status # 查看状态 sudo supervisorctl stop jsa # 停止一个子进程 sudo supervisorctl start jsa # 启动一个子进程 sudo supervisorctl restart jsa # 重启一个子进程
相关推荐
yserver 2020-08-15
达观数据 2020-11-11
汪康 2020-10-30
ppppfly 2020-10-24
synshitou 2020-10-21
programmeryu 2020-09-24
Topbeyond 2020-08-21
lrcoop 2020-08-18
young依然 2020-08-17
oden 2020-08-16
lrcoop 2020-08-15
王永迪 2020-08-15
pursuemylife 2020-08-14
pandaphinex 2020-08-09
leonranri 2020-07-26
CloasGao 2020-07-21
zccheu 2020-07-18