安装jdk在usr下创建java目录,使用命令下载jdk压缩包。这里是安装在/usr/java,或者可以使用yum安装到/usr/lib/jvm。 $ wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u102-b14/jdk-8u102-linux-x64.tar.gz 或者在本地先下载好再使用scp命令上传 $ scp /本地路径/jdk-8u102-linux-x64.tar.gz 登录用户名@服务器ip:/usr/java 解压完删除压缩包 $ tar xvf jdk-8u102-linux-x64.tar.gz 配置环境变量,将以下脚本添加到/etc/profile文件的末尾 JAVA_HOME=/usr/java/jdk1.8.0_102 JRE_HOME=/usr/java/jdk1.8.0_102/jre PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib export JAVA_HOME JRE_HOME PATH CLASSPATH 最后reboot重启,执行java -version,结果显示已安装成功 $ java -version java version "1.8.0_102" Java(TM) SE Runtime Environment (build 1.8.0_102-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode) 安装jenkins添加jenkins库 $ wget -O /etc/yum.repos.d/jenkins.repo http://jenkins-ci.org/redhat/jenkins.repo $ rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key 接下来使用yum命令来安装 $ yum install jenkins 下载rpm包过程中报错 Downloading Packages: http://pkg.jenkins.io/redhat/jenkins-2.16-1.1.noarch.rpm: [Errno 14] PYCURL ERROR 18 - "transfer closed with 66371436 bytes remaining to read" Trying other mirror. Error Downloading Packages: jenkins-2.16-1.1.noarch: failure: jenkins-2.16-1.1.noarch.rpm from jenkins: [Errno 256] No more mirrors to try. 大概就是下载速度太慢关闭了,这里的解决办法是多次执行install直到下完或者还是到自已机器下载再上传到rpm所在目录,下载链接 http://pkg.jenkins-ci.org/red... ,我的rpm目录是/var/cache/yum/x86_64/6/jenkins/packages。 执行以下命令,可以看到jenkins已经是开机自启动的系统服务,它在/etc/init.d目录下生成了jenkins文件 $ chkconfig --list | grep jenkins jenkins 0:关闭 1:关闭 2:关闭 3:启用 4:关闭 5:启用 6:关闭 jenkins的war包存放在/usr/lib/jenkins目录下,配置文件jenkins在/etc/sysconfig,我这里修改端口为8888 ## Type: integer(0:65535) ## Default: 8080 ## ServiceRestart: jenkins # # Port Jenkins is listening on. # Set to -1 to disable # JENKINS_PORT="8888" 可以看到jenkins的主目录 ## Path: Development/Jenkins ## Description: Jenkins Continuous Integration Server ## Type: string ## Default: "/var/lib/jenkins" ## ServiceRestart: jenkins # # Directory where Jenkins store its configuration and working # files (checkouts, build reports, artifacts, ...). # JENKINS_HOME="/var/lib/jenkins" jenkins创建job和slave都会在这个目录下生成数据,现在是空的,数据迁移时可以将该目录下的数据拷贝到新机器的同个目录下。第一次访问控制台后会生成初始数据。 启动jenkins,直接使用系统服务的启动命令,结果报错,找不到java $ service jenkins start Starting Jenkins bash: /usr/bin/java: No such file or directory [FAILED] 找到/etc/init.d/jenkins文件,在变量candidates后面添加一个路径/usr/java/jdk1.8.0_102/bin/java。 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/java/jdk1.8.0_102/bin/java " 再启动就成功了 $ service jenkins start Starting Jenkins [ OK ] 最后在浏览器访问jenkins,输入:jenkins服务器地址:8888 后续写如何用jenkins实现一键自动部署 (责任编辑:最模板) |