Then continue to learn Jenkins, this time mainly to see some of the incurable diseases:
First, yum install installation method
In addition to the direct Java-jar Jenkins.war approach, it can also be installed with Yum, which provides more configurable options and is more suitable for production environments to control Jenkins behavior.
sudo yum update-y (optional) sudo wget-o/etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.reposudo rpm --import Http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.keyyum install deltarpm (optional) sudo yum install Jenkins
After installation is complete, available
sudo service Jenkins Start/stop/restart
However, I tested the CentOS 7 environment,/etc/rc.d/init.d/jenkins This script is a little bit of a problem, if Java is not in the default directory, will cause startup failure
sudo vi/etc/rc.d/init.d/jenkins
Navigate to 67 rows and you will find that the script will find the Java executable file from the following location
candidates= " /etc/alternatives/java /usr/lib/jvm/java-1.6.0/bin/java /usr/lib/jvm/jre-1.6.0/bin/ Java /usr/lib/jvm/java-1.7.0/bin/java /usr/lib/jvm/jre-1.7.0/bin/java /usr/lib/jvm/java-1.8.0/bin/ Java /usr/lib/jvm/jre-1.8.0/bin/java /usr/bin/java "
If Java is not installed in these directories, startup will fail, workaround: Add the correct location of Java, such as:
Candidates= "/opt/app/jdk1.8.0_65/bin/java"
Note: After this processing, also to execute sudo systemctl daemon-reload, then you can service Jenkins start, if there is an error, try to CD/ETC/RC.D/INIT.D, and then sudo./jenkins Start further troubleshooting. Students are advised to read this startup script carefully, you can find a lot of useful information, such as:
Jenkins_war= "/usr/lib/jenkins/jenkins.war" jenkins_config=/etc/sysconfig/jenkinsjenkins_pid_file= "/var/run/ Jenkins.pid "
The above parameters define the configuration file, the war package, the PID file, the location of the log, we can go directly to these locations to view the details when something goes wrong.
For example: Port 8080 is occupied, need to change the boot port, directly view/etc/sysconfig/jenkins this file, find
jenkins_port= "8080"
You can modify it.
/etc/sysconfig/jenkins This file is also recommended to read throughout, there are some key information, such as:
Jenkins_home= "/var/lib/jenkins" jenkins_user= "Jenkins" jenkins_ajp_port= "8009" jenkins_debug_level= "5" JENKINS_ Enable_access_log= "No"
Ii. the issue of the start-up status of Jenkins
When started in Java-jar Jenkins.war this way, the default is under the current user root directory, Create the. Jenkins directory, all Jenkins-related content, including configuration files, user-created data in this directory, if you switch another account to log on to Linux, and then restart, you will find all the previously created items including the user completely lost, because at this time the working directory of Jenkins Switch to the new user's ~/.jenkins, so under normal circumstances, do not arbitrarily switch the boot identity.
With Yum installed Jenkins, because the working directory is written dead in/etc/sysconfig/jenkins, so there is no problem, but in this way, a lot of directories are placed in/var position, less permissions, If you are having errors such as a file that cannot be written, be careful to adjust the permissions of the Jenkins user or directory.
Third, security policy configuration error, resulting in the inability to use Jenkins problem
Sometimes their own blind toss, the management of the anonymous user is forbidden, and then the user can log in and forget to check the management rights, then the ignorant, do not worry, into the ~/.jenkins or/var/lib/jenkins, edit config.
<useSecurity>true</useSecurity>
This is roughly the 7th line, and then change the following two nodes to:
<authorizationstrategy class= "hudson.security.authorizationstrategy$unsecured"/><securityRealm class= " Hudson.security.securityrealm$none "/>
Save, then restart Jenkins, and it's OK.
If there is no important data, it can also be more violent, the ~/.jenkins or/var/lib/jenkins under the plugins except the directory to kill all, equivalent to all except the plug-in, all content initialization.
Jenkins Getting Started tutorial (bottom)