在centos中安装jenkins master为service

时间:2023-03-08 17:43:30
需要sudo或root权限。
1)确保centos中的java为openjdk。
如果java -version输出为
java -version
java version "1.5.0"
gij (GNU libgcj) version 4.4.6 20110731 (Red Hat 4.4.6-3)
则需要卸载java,安装openjdk版本
yum remove java
然后安装openjdk如下:
yum install java-1.6.0-openjdk运行java -version 如下:java -version
java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.6) (rhel-1.43.1.10.6.el6_2-i386)
OpenJDK Client VM (build 20.0-b11, mixed mode)
OpenJDK Client VM (build 20.0-b11, mixed mode)
2)安装稳定版本的jenkins
•sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
•sudo rpm --import http://pkg.jenkins-ci.org/redhat-stable/jenkins-ci.org.key
•sudo yum install jenkins
3)配置:
[root@Centos_AAA ~]# mkdir -p /home/AAA/jenkins/jenkins_home2
[root@Centos_AAA ~]# chown jenkins:jenkins /home/AAA/jenkins/jenkins_home2
[root@Centos_AAA ~]# ll -d /home/AAA/jenkins/jenkins_home2
drwxrwxr-x. 2 jenkins jenkins 4096 Jan 4 02:38 /home/AAA/jenkins/jenkins_home2
在配置文件/etc/sysconfig/jenkins中修改jenkins_home为/home/AAA/jenkins/jenkins_home2。
3) 启动jenkins
•sudo service jenkins start/stop/restart
•sudo chkconfig jenkins on
以上的安装和配置的解释:
1)jenkins通过daemon启动,查看 /etc/init.d/jenkins;
2)jenkins user被创建,且用来运行jenkins service。如果你需要修改为不同的user,需要修改文件的owner:/var/log/jenkins, /var/lib/jenkins, and /var/cache/jenkins;
3)log在文件/var/log/jenkins/jenkins.log;
4)/etc/sysconfig/jenkins 为jenkins的启动参数;
5) 默认地,jenkins运行于8080端口,确保防火墙允许端口, http://www.cyberciti.biz/faq/disable-linux-firewall-under-centos-rhel-fedora/。
6)jenkins RPM repository 被设置,查看/etc/yum.repos.d/jenkins.repo;
完!