1. 程式人生 > >CentOS6.8 部署Tomcat+jenkins+git+maven 持續集成

CentOS6.8 部署Tomcat+jenkins+git+maven 持續集成

jenkins

CentOS6.8 部署Tomcat+jenkins+git+maven 持續集成


一、環境介紹:

1、操作系統:CentOS 6.8 IP:192.168.1.100

2、JDK版本:jdk1.8.0_101

3、Tomcat版本:tomcat-9.0.0.M21

4、jenkins版本: Jenkins ver. 2.46.3

5、git版本:git version 2.9.4

6、maven版本:3.5.0

二、環境部署

1、下載所需軟件包

# mkdir /tmp/soft ; cd /tmp/soft

##### tomcat

# wget http://apache.communilink.net/tomcat/tomcat-9/v9.0.0.M21/bin/apache-tomcat-9.0.0.M21.tar.gz

##### 下載git

# wget https://www.kernel.org/pub/software/scm/git/git-2.9.4.tar.gz

##### 下載jdk

# 下載地址:http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz

##### 下載maven

# wget http://ftp.cuhk.edu.hk/pub/packages/apache.org/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz

##### 下載jenkins

# wget http://mirrors.jenkins.io/war/latest/jenkins.war

2、安裝部署jdk

### 為了以後方便管理,將所有軟件安裝至/export/servers目錄下

a、解壓jdk

# tar -xf jdk-8u131-linux-x64.tar.gz -C /export/servers

b、配置環境變量

### 編輯/etc/profile文件,添加以下信息:

# vim /etc/profile

export JAVA_HOME=/export/servers/jdk1.8.0_131

export JAVA_BIN=$JAVA_HOME/bin

export PATH=$JAVA_HOME/bin:$PATH

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export JAVA_OPTS="-Djava.library.path=/usr/local/lib -server -Xms1024m -Xmx2048m -XX:MaxPermSize=256m -Djava.awt.headless=true -Dsun.net.client.defaultReadTimeout=60000 -Djmagick.systemclassloader=no -Dnetworkaddress.cache.ttl=300 -Dsun.net.inetaddr.ttl=300"

export JAVA_HOME JAVA_BIN PATH CLASSPATH JAVA_OPTS

c、測試安裝是否成功

# java -version

java version "1.8.0_131"

Java(TM) SE Runtime Environment (build 1.8.0_131-b11)

Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

3、安裝Tomcat

a、解壓Tomcat

# tar xf apache-tomcat-9.0.0.M21.tar.gz -C /export/servers

# mv /export/servers/apache-tomcat-9.0.0.M21 /export/servers/tomcat-9.0.0.M21

b、配置tomcat

###修改Tomcat字符集為UTF-8

# vim /export/servers/apache-tomcat-9.0.0.M21/conf/server.xml

# 修改為以下內容,添加URIEncoding:

<Connector port="8080" protocol="HTTP/1.1"

connectionTimeout="20000"

redirectPort="8443" URIEncoding="UTF-8" />

4、安裝jenkins

a、清理tomcat工作目錄

# cd /export/servers/tomcat-9.0.0.M21/webapps/ROOT/

# rm -rf *

b、解壓jenkins

# cp /tmp/soft/jenkins.war ./

# java -jar jenkins.war

5、安裝git

a、安裝依賴包

# cd /tmp/soft

# yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

b、安裝git

# mkdir -p /export/servers/git-2.9.4

# tar -xf git-2.9.4.tar.gz

# make -j 20 prefix=/export/servers/git-2.9.4 all

# make prefix=/export/servers/git-2.9.4 install

c、配置git環境變量

### 在/etc/profile最後添加以下信息:

# vim /etc/profile

export GIT_HOME=/export/servers/git-2.9.4

export PATH=$GIT_HOME/bin:$PATH

6、安裝Maven

a、解壓及安裝

# cd /tmp/soft

# tar -xf apache-maven-3.5.0-bin.tar.gz

# mv apache-maven-3.5.0 maven-3.5.0

# mv maven-3.5.0 /export/servers/

b、配置環境變量

### 在/etc/profile中添加以下信息

# vim /etc/profile

export MAVEN_HOME=/export/servers/maven-3.5.0

export PATH=$PATH:$MAVEN_HOME/bin

三、測試及啟動服務

1、測試JDK

# java -version

java version "1.8.0_131"

Java(TM) SE Runtime Environment (build 1.8.0_131-b11)

Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

2、測試git

# git version

git version 2.9.4

3、測試maven

# mvn -v

Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)

Maven home: /export/servers/maven-3.5.0

Java version: 1.8.0_101, vendor: Oracle Corporation

Java home: /export/servers/jdk1.8.0_131/jre

Default locale: en_US, platform encoding: UTF-8

OS name: "linux", version: "2.6.32-642.el6.x86_64", arch: "amd64", family: "unix"

4、測試Tomcat和Jenkins

# cd /export/servers/tomcat-9.0.0.M21/bin

# /bin/sh startup.sh

# tailf ../logs/catalina.out

### 可以查看下日誌,看是否有Error的錯誤

5、添加開機自啟Tomcat

# echo "/bin/sh /export/servers/tomcat-9.0.0.M21/bin/startup.sh" >> /etc/rc.d/rc.local


四、Web登錄測試

1、先查看下Jenkins初始密碼

# cat /root/.jenkins/secret.key

10d886523c3e33c549c0db32b035f887476097229529f22c4d36327387fc0900

##### 復制此密碼,此密碼會在第一次打開Web頁面時使用

2、登錄Jenkins

打開瀏覽器----->在地址欄輸入:http://192.168.1.100:8080


至此,Jenkins的部署就已經完成,如有任何問題可以發郵件至:[email protected]


本文出自 “Elephant” 博客,請務必保留此出處http://zlyang.blog.51cto.com/1196234/1939847

CentOS6.8 部署Tomcat+jenkins+git+maven 持續集成