实战交付一套dubbo微服务到k8s集群(3)之二进制安装Maven

maven官网:https://maven.apache.org/

maven二进制下载连接:https://archive.apache.org/dist/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz

1.下载maven二进制包

在运维主机(mfyxw50.mfyxw.com)上操作

[root@mfyxw50 ~]# cd /opt/src/
[root@mfyxw50 src]# wget https://archive.apache.org/dist/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz

2.解压二进制maven文件到指定目录

在运维主机(mfyxw50.mfyxw.com)上操作

[root@mfyxw50 ~]# mkdir -p /data/nfs-volume/jenkins_home/maven-3.6.1-8u232
[root@mfyxw50 ~]# tar xf /opt/src/apache-maven-3.6.1-bin.tar.gz -C /data/nfs-volume/jenkins_home/
[root@mfyxw50 ~]# mv /data/nfs-volume/jenkins_home/apache-maven-3.6.1/* /data/nfs-volume/jenkins_home/maven-3.6.1-8u232/
[root@mfyxw50 ~]# rm -fr /data/nfs-volume/jenkins_home/apache-maven-3.6.1

在mfyxw30.mfyxw.com主机上执行

在jenkins容器中是否能查看到有二进制的maven目录

[root@mfyxw30 ~]# kubectl get pod -n infra
NAME                      READY   STATUS    RESTARTS   AGE
jenkins-b99776c69-p6skp   1/1     Running   0          4h2m
[root@mfyxw30 ~]# kubectl exec -it jenkins-b99776c69-p6skp -n infra -- /bin/bash
root@jenkins-b99776c69-p6skp:/# cd /var/jenkins_home/
root@jenkins-b99776c69-p6skp:/var/jenkins_home# ls
com.cloudbees.hudson.plugins.folder.config.AbstractFolderConfiguration.xml  logs
config.xml								                          maven-3.6.1-8u232
copy_reference_file.log							                  nodeMonitors.xml
hudson.model.UpdateCenter.xml						              nodes
hudson.plugins.git.GitTool.xml						              plugins
identity.key.enc							                     queue.xml.bak
jenkins.install.InstallUtil.lastExecVersion				           secret.key
jenkins.install.UpgradeWizard.state					               secret.key.not-so-secret
jenkins.model.DownloadSettings.xml					               secrets
jenkins.security.QueueItemAuthenticatorConfiguration.xml		    updates
jenkins.security.UpdateSiteWarningsConfiguration.xml			    userContent
jenkins.security.apitoken.ApiTokenPropertyConfiguration.xml		    users
jenkins.telemetry.Correlator.xml					               war
jobs									                          workflow-libs
root@jenkins-b99776c69-p6skp:/var/jenkins_home# 

image-20200528153438871

3.设置maven镜像源

在运维主机(mfyxw50.mfyxw.com)上操作

[root@mfyxw50 ~]# vi /data/nfs-volume/jenkins_home/maven-3.6.1-8u232/conf/settings.xml
#添加如下内容
<mirror>
  <id>alimaven</id>
  <name>aliyun maven</name>
  <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  <mirrorOf>central</mirrorOf>        
</mirror>

image-20200528180809133

原文地址:https://www.cnblogs.com/Heroge/p/12985564.html