RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
CentOS6.8部署Tomcat+jenkins+git+maven+ant持续集成

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

站在用户的角度思考问题,与客户深入沟通,找到松溪网站设计与松溪网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站建设、成都做网站、企业官网、英文网站、手机端网站、网站推广、主机域名、虚拟空间、企业邮箱。业务覆盖松溪地区。

一、环境介绍:

    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

    7、ant版本:version 1.10.1

二、环境部署

    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

        # wgethttp://mirrors.jenkins.io/war/latest/jenkins.war

        ##### 下载ant

        # wget http://apache.communilink.net//ant/binaries/apache-ant-1.10.1-bin.tar.gz

    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:

        

               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

    7、安装Ant

        a、解压及安装

        # tar xf apache-ant-1.10.1-bin.tar.gz

        # mv apache-ant-1.10.1 ant-1.10.1

        # mv ant-1.10.1 /export/servers/

        b、配置环境变量

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

        # vim /etc/profile

export ANT_HOME=/export/servers/ant-1.10.1

export PATH=$PATH:/export/servers/ant-1.10.1/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的部署就已经完成,如有任何问题可以发邮件至:DBA_Master@163.com


网站标题:CentOS6.8部署Tomcat+jenkins+git+maven+ant持续集成
本文URL:http://lswzjz.com/article/pehhgi.html