Tag Archives: 下载Oracle文件

用 Wget 直接下载 OTN 上的 Oracle 安装文件

OTN 上下载文件,有的时候是比较烦人的事情。估计是出于负载均衡的原因,直接使用浏览器看到的地址还要经过几次 http 302 跳转才可以看到。而这个跳转是要带着 Session 走的,如果使用多线程下载工具就有可能到一个很小的错误页面文件。新版本的 FlashGet 就有这毛病。
如果准备安装的服务器在远程,参考这里的方法,用 Wget 直接下载其实也并不费事。
现通过浏览器获知该数据文件的 URL 地址。然后来个投石问路看看具体的跳转情况:

$ wget --limit-rate=150k \ http://download.oracle.com/otn/linux/oracle10g/ \ 10201/10201_database_linux_x86_64.cpio.gz http://download.oracle.com/otn/linux/oracle10g/ \ 10201/10201_database_linux_x86_64.cpio.gz => `10201_database_linux_x86_64.cpio.gz' Resolving download.oracle.com... 213.35.100.1 Connecting to download.oracle.com[213.35.100.1]:80... connected. HTTP request sent, awaiting response... 302 Found
Location: http://download-
west.oracle.com/otn/linux/oracle10g/10201/ 10201_database_linux_x86_64.cpio.gz [following] http://download-west.oracle.com/otn/linux/oracle10g/10201/ 10201_database_linux_x86_64.cpio.gz
=> `10201_database_linux_x86_64.cpio.gz' Resolving download-west.oracle.com... 206.204.21.139 Connecting to download-west.oracle.com[206.204.21.139]:80... connected. HTTP request sent, awaiting response... 302 Found
Location: https://profile.oracle.com/jsp/realms/otnLogin.jsp?
remoteIp=218.108.233.1&globalId=&redirectUrl=http%3a%2f%2fdownload-
west.oracle.com%3a80%2fotn%2flinux%2foracle10g%2f10201%
2f10201_database_linux_x86_64.cpio.gz [following] --16:11:01-- https://profile.oracle.com/jsp/realms/otnLogin.jsp? remoteIp=218.108.233.1&globalId=&redirectUrl=http%3a%2f%2fdownload- west.oracle.com%3a80%2fotn%2flinux%2foracle10g%2f10201% 2f10201_database_linux_x86_64.cpio.gz => `otnLogin.jsp? \ remoteIp=218.108.233.1&globalId=&redirectUrl=http:%2F%2Fdownload-
west.oracle.com:80%2Fotn%2Flinux%2Foracle10g%2F10201%
2F10201_database_linux_x86_64.cpio.gz' Resolving profile.oracle.com... 141.146.8.116 Connecting to profile.oracle.com[141.146.8.116]:443... connected.
HTTP request sent, awaiting response... 200 OK Length: 4,106 [text/html]

输出实在是有点恶心,我在适当的地方做了换行处理。要在第二个 Location 处下手:
https://profile.oracle.com/jsp/realms/otnLogin.jsp?remoteIp=218.108.233.1&globalId=&redirectUrl=http%3a%2f%2fdownload-west.oracle.com%3a80%2fotn%2flinux%2foracle10g%2f10201%2f10201_database_linux_x86_64.cpio.gz
在这个地址后添加 &username=YOURPASSWORD&password=YOURPASSWORD&submit=Continue . YOURUSERNAME/YOURPASSWORD 是在 OTN 上的用户名与口令。然后提交如下的命令即可:

wget --limit-rate=128K --post-data="https://profile.oracle.com/jsp/realms/otnLogin.jsp? \ remoteIp=218.108.233.1&globalId=&redirectUrl=http%3a%2f%2fdownload- \ west.oracle.com%3a80%2fotn%2flinux%2foracle10g%2f10201% \ 2f10201_database_linux_x86_64.cpio.gz \ &username=YOURUSERNAME&password=YOURPASSWORD&submit=Continue" \ https://profile.oracle.com/jsp/reg/loginHandler.jsp

如果嫌输出麻烦,可以在最后 -o downloadOracle.log . 新开一个终端窗口 tail -f downloadOracle.log 就可以观察下载进度了。
要养成随时用 Unix 的习惯思考问题,还真是一个需要时间的事情 :)
EOF