今天尝试了一个工具(类似azcopy)导入Linux集群中的数据到Azure(微软云)的HDInsight集群中
关于Linux 版本的类似于Azcopy 的上传工具,还是可以通过参数修改来支持中国区Azure 的文件传输的。
所以这个方式应该是可行的。你可以从下面的GitHub 下载这个工具。
https://github.com/matthchr/azure-batch-samples/tree/master/Python/Storage
支持中国区Azure 的参数如下:
--blobep BLOBEP 默认是Global blob storage endpoint [core.windows.net]
ForChina, use: core.chinacloudapi.cn
一、安装blobxfer
https://github.com/matthchr/azure-batch-samples/tree/master/Python/Storage
pip命令系统没有,因为之前安装的python2.7没有带这个命令,需要先安装pip
二、pip安装,参考
https://www.ttlsa.com/python/how-to-install-and-use-pip-ttlsa/
步骤如下:
wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate
tar -zxvf pip-1.5.4.tar.gz
cd pip-1.5.4
chmod +x setup.py
# python setup.py install
报错如下:
Traceback (most recent call last):
File "setup.py", line 6, in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools
提示没有setuptools模块,需要先安装setuptools模块,
最终显示如下才算安装成功:
Installed /usr/local/python2.7/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg
Processing dependencies for pip==1.5.4
Finished processing dependencies for pip==1.5.4
三、发现没有setuptols
参考如下文档:http://www.letuknowit.com/post/147.html
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-5.7.zip --no-check-certificate
wget http://peak.telecommunity.com/dist/ez_setup.py
wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
unzip setuptools-5.7.zip
cd setuptools-5.7
需要添加x执行权限
chmod +x setup.py
# python ez_setup.py 或者 python2.7 ez_setup.py install
最终显示如下说明安装成功:
Installed /usr/local/python2.7/lib/python2.7/site-packages/setuptools-5.7-py2.7.egg
Processing dependencies for setuptools==5.7
Finished processing dependencies for setuptools==5.7
需要添加执行权限,否则报错如下:
Traceback (most recent call last):
File "ez_setup.py", line 278, in <module>
main(sys.argv[1:])
File "ez_setup.py", line 212, in main
from setuptools.command.easy_install import main
zipimport.ZipImportError: can‘t decompress data; zlib not available
或者报错如下:
# python ez_setup.py
Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
Traceback (most recent call last):
File "ez_setup.py", line 278, in <module>
main(sys.argv[1:])
File "ez_setup.py", line 210, in main
egg = download_setuptools(version, delay=0)
File "ez_setup.py", line 158, in download_setuptools
src = urllib2.urlopen(url)
File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 437, in open
response = meth(req, response)
File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 550, in http_response
‘http‘, request, response, code, msg, hdrs)
File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 469, in error
result = self._call_chain(*args)
File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 656, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 454, in _open
‘unknown_open‘, req)
File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 1265, in unknown_open
raise URLError(‘unknown url type: %s‘ % type)
urllib2.URLError: <urlopen error unknown url type: https>
注意:有时候会提示no moudule zlib
cd Python-2.7.11/
chmod +x update.sh
cd Modules/
vim Setup.dist 将#删除,然后重新编译安装Python,注意添加update.sh(安装脚本)的执行权限
zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
[root@localhost ~]# blobxfer azureaccount azurecontiner nginx+php1.9.tar.gz
Traceback (most recent call last):
File "/usr/local/python2.7/bin/blobxfer", line 7, in <module>
from blobxfer import main
File "/usr/local/python2.7/lib/python2.7/site-packages/blobxfer.py", line 72, in <module>
import azure.common
ImportError: No module named azure.common
[root@localhost ~]# pip install azure-storage
Requirement already satisfied (use --upgrade to upgrade): azure-storage in /usr/local/python2.7/lib/python2.7/site-packages
Cleaning up...
[root@localhost ~]# pip install azure-common
Requirement already satisfied (use --upgrade to upgrade): azure-common in /usr/local/python2.7/lib/python2.7/site-packages
Cleaning up...
[root@localhost ~]# pip install requests
Downloading/unpacking requests
Downloading requests-2.9.1-py2.py3-none-any.whl (501kB): 501kB downloaded
Installing collected packages: requests
Successfully installed requests
本文出自 “梅花香自苦寒来!” 博客,请务必保留此出处http://daixuan.blog.51cto.com/5426657/1767325
原文地址:http://daixuan.blog.51cto.com/5426657/1767325