Ambari在编译过程中需要下载包括node、npm、yarn等在内的大量依赖,在国内编译时会遇到无法绕过网络问题。由于s3.amazonaws.com基本不可用,因此在在下载诸如HBase等大文件时极为缓慢且成功的概率基本为零;而HBase等大文件主要是通过maven-antrun-plugin插件的get不会使用maven镜像、maven代理:
无奈尝试使用全局代理(转发至国内的HTTP/SOCKS5代理,然后国内的代理通过SS出墙),先尝试了privoxy,但不支持privoxy不支持HTTP和SOCKS5的用户名/密码验证,无果。
之后,查阅polipo文档(官网也被封了),发现其上级代理为HTTP类型时能够使用用户名/密码验证,于是进行尝试。
The variable
parentProxy
specifies the hostname and port number of an HTTP parent proxy; it should have the form ‘host:port’.If the parent proxy requires authorisation, the username and password should be specified in the variable
parentAuthCredentials
in the form ‘username:password’. Only Basic authentication is supported, which is vulnerable to replay attacks.
使用:
1 |
apt-get install polipo |
安装polipo,然后修改配置文件/etc/polipo/config:
1 2 3 4 5 6 7 8 9 10 11 |
# This file only needs to list configuration variables that deviate # from the default values. See /usr/share/doc/polipo/examples/config.sample # and "polipo -v" for variables you can tweak and further information. logSyslog = true logFile = /var/log/polipo/polipo.log proxyAddress = "127.0.0.1" parentProxy = "139.*.*.*:11443" parentAuthCredentials = "user:password" |
使用如下命令启停:
1 2 |
service polipo start service polipo stop |
polipo默认端口为8123,在/etc/environment中增加如下两个环境变量(大小写敏感):
1 2 |
http_proxy="http://127.0.0.1:8123" https_proxy="http://127.0.0.1:8123" |
然后直接使用wget测试即可:
1 2 3 4 5 6 7 8 9 10 |
root@mid003:~# wget https://www.google.com --2019-12-06 22:04:59-- https://www.google.com/ Connecting to 127.0.0.1:8123... connected. Proxy request sent, awaiting response... 200 OK Length: unspecified [text/html] Saving to: ‘index.html.3’ index.html.3 [ <=> ] 11.74K --.-KB/s in 0.08s 2019-12-06 22:04:59 (139 KB/s) - ‘index.html.3’ saved [12019] |
然而,再次尝试编译Ambari,发现maven-antrun-plugin插件还是不走代理,思路失败!
Stack Overflow上有一个问题https://stackoverflow.com/questions/21108925/specifiying-proxy-to-sign-jars-with-maven-with-maven-antrun-plugin也提到了maven-antrun-plugin插件不走/etc/maven/settings.xml中所配置的代理的问题,甚至还有一个2015年的问题(https://issues.apache.org/jira/browse/MANTRUN-195)中也提到了:
When setting a a proxy in my settings.xml file, the proxy configuration is not passed on to the Antrun plugin. Any Ant scripts, trying to access the outside network do not suceed because no proxy is used.
ant官网https://ant.apache.org/manual/proxy.html称可以使用环境变量:
1 |
export ANT_OPTS="-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080" |
但这个用法实测无效,应该将其加到mvn的编译参数中,即将编译时使用的命令行改为:
1 |
mvn -B clean install jdeb:jdeb -DnewVersion=2.7.4.0.0 -DbuildNumber=b730f30585dd67c10d3b841317100f17d4b2c5f1 -DskipTests -Dpython.ver="python >= 2.6" -Drat.skip=true -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8123 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=8123 |
然后就可以看到maven-antrun-plugin插件走代理了:
转载时请保留出处,违法转载追究到底:进城务工人员小梅 » 使用polipo解决maven-antrun-plugin插件不走代理的问题