centos 安裝jenkins
centos 安裝jenkins
1.安裝JDK7
1.1 下載JDK7
可能不能直接使用wget下載,可使用迅雷下載
http://download.oracle.com/otn-pub/Java/jdk/7/jdk-7-linux-i586.tar.gz
拷貝到目錄/usr/local
1.2 解壓安裝包
[java]view plaincopy
- [root@localhostlocal]#tar-zxvfjdk-7-linux-i586.tar.gz
1.3修改環境變量
[java]view plaincopy
- [root@localhostlocal]#vi/etc/profile
添加下面幾行
[java]view plaincopy
- exportJAVA_HOME=/usr/local/jdk1.7.0
- exportJRE_HOME=/usr/local/jdk1.7.0/jre
- exportCLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
- exportPATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
1.4 執行命令
[java]view plaincopy
- [root@bogonopt]#source/etc/profile
這樣環境變量的修改就生效了
1.5 驗證JDK安裝結果
[java]view plaincopy
- [[email protected]]#java-version
- javaversion"1.7.0"
- Java(TM)SERuntimeEnvironment(build1.7.0-b147)
- JavaHotSpot(TM)ClientVM(build21.0-b17,mixedmode)
- ng:1.0pt;}
2.安裝maven
2.1 下載maven
[java]view plaincopy
- [root@localhostlocal]#wgethttp://mirrors.cnnic.cn/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
2.2 解壓maven
[java]view plaincopy
- [root@localhostlocal]#tar-zxvfapache-maven-3.3.9-bin.tar.gz
2.3 配置maven安裝路徑
修改文件/etc/profile,添加下面三行
[java]view plaincopy
- MAVEN_HOME=/usr/local/apache-maven-3.3.9
- exportMAVEN_HOME
- exportPATH=${PATH}:${MAVEN_HOME}/bin
讓修改生效
[java]view plaincopy
- [root@localhostlocal]#source/etc/profile
2.4 驗證安裝結果
[java]view plaincopy
- [root@localhostlocal]#mvn-v
- ApacheMaven3.3.9(bb52d8502b132ec0a5a3f4c09453c07478323dc5;2015-11-10T08:41:47-08:00)
- Mavenhome:/usr/local/apache-maven-3.3.9
- Javaversion:1.7.0,vendor:OracleCorporation
- Javahome:/usr/local/jdk1.7.0/jre
- Defaultlocale:en_US,platformencoding:UTF-8
- OSname:"linux",version:"2.6.32-431.el6.i686",arch:"i386",family:"unix"
3.安裝Jenkins
3.1 下載jenkins
http://211.162.52.227/files/4054000003480AF6/ftp.yz.yamagata-u.ac.jp/pub/misc/jenkins/redhat-stable/jenkins-2.7.3-1.1.noarch.rpm
將安裝包拷貝到目錄/usr/local
3.2.安裝jenkins
[java]view plaincopy
- [root@localhostlocal]#rpm-ivhjenkins-2.7.3-1.1.noarch.rpm
jenkins的安裝目錄是/usr/lib/jenkins,裡面有個WAR包jenkins.war
3.3.修改jenkins配置文件
添加下面一行
[java]view plaincopy
- /usr/local/jdk1.7.0/bin/java
[java]view plaincopy
- [root@localhostjenkins]#vi/etc/sysconfig/jenkins
- 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
- /usr/local/jdk1.7.0/bin/java"
3.4 啟動jenkins
[java]view plaincopy
- [root@localhostjenkins]#servicejenkinsstart
- StartingJenkins[OK]
3.5 開放端口8080
jenkins的默認端口號是8080,防火牆要開放這個端口,外部才能訪問。
添加下面一行
[java]view plaincopy
- -<spanstyle="font-family:Arial,Helvetica,sans-serif;">AINPUT-mstate--stateNEW-mtcp-ptcp--dport8080-jACCEPT</span>
[java]view plaincopy
- [root@localhostjenkins]#vi/etc/sysconfig/iptables
- #Firewallconfigurationwrittenbysystem-config-firewall
- #Manualcustomizationofthisfileisnotrecommended.
- *filter
- :INPUTACCEPT[0:0]
- :FORWARDACCEPT[0:0]
- :OUTPUTACCEPT[0:0]
- -AINPUT-mstate--stateESTABLISHED,RELATED-jACCEPT
- -AINPUT-picmp-jACCEPT
- -AINPUT-ilo-jACCEPT
- -AINPUT-mstate--stateNEW-mtcp-ptcp--dport22-jACCEPT
- -AINPUT-mstate--stateNEW-mtcp-ptcp--dport80-jACCEPT
- <precode_snippet_id="1876506"snippet_file_name="blog_20160911_9_9918486"name="code"class="java">-<spanstyle="font-family:Arial,Helvetica,sans-serif;">AINPUT-mstate--stateNEW-mtcp-ptcp--dport8080-jACCEPT</span>
-A INPUT -jREJECT --reject-with icmp-host-prohibited-A FORWARD -jREJECT --reject-with icmp-host-prohibited
3.6 重啟防火牆
[java]view plaincopy
- [root@localhostjenkins]#serviceiptablesrestart
- iptables:SettingchainstopolicyACCEPT:filter[OK]
- iptables:Flushingfirewallrules:[OK]
- iptables:Unloadingmodules:[OK]
- iptables:Applyingfirewallrules:[OK]
3.7 浏覽器訪問jenkins
http://192.168.1.105:8080
進入目錄/var/lib/jenkins/secrets
查看密碼
[java]view plaincopy
- [root@localhostsecrets]#viinitialAdminPassword
- 2aa80bb4a1ce4a269996b1b2ba6cefc1
3.8 查看運行日志
[java]view plaincopy
- [root@localhostjenkins]#more/var/log/jenkins/jenkins.log
http://xxxxxx/Linuxjc/1184815.html TechArticle