Google Storage for Developers工具GSUtil使用教程

王朝学院·作者佚名  2016-04-28
窄屏简体版  字體: 小  |  中  |  大  |  超大  

Google Storage for Developers是Google公司云计算存储产品,为开发者提供了100G的空间,300GB的流量/月,管理Google Storage很容易,最简单的方法就是使用游览器直接登录http://sandbox.google.com/storage 然后就可以使用Web平台进行管理,但是有点简陋。我平时基本都是在Centos5或者Debian5下面工作,命令行管理工具自然方便和熟悉些,下面我来说说Google Storage for Developers的命令行工具GSUtil的用法

一、安装Python2.7

如果你的系统是Debian5或者是最新的Ubuntu的话,就不需要安装了,这里专门针对Python版本较老的Centos5

[root@techroad ~]# wget http://www.python.org/ftp/python/2.7/Python-2.7.tar.bz2

[root@techroad ~]# tar jxvf Python-2.7.tar.bz2

[root@techroad ~]# cd Python-2.7

[root@techroad Python-2.7]# ./configure

[root@techroad Python-2.7]# make && make install

[root@techroad Python-2.7] # cd ../

[root@techroad ~]# /usr/local/bin/python2.7 -V #查看版本

安装完成后要修改下环境变量,和Yum的配置文件,因为Yum工具依赖Python2.4

//修改环境变量

[root@techroad ~]# vim ~/.bashrc

//添加

export PATH=$PATH:usr/local/bin/python2.7

//修改Yum配置文件

[root@techroad ~]# vim /usr/bin/yum

修改#!/usr/bin/python为#!/usr/bin/python2.4

二、安装GSUtil

[root@techroad ~]# wget http://commondatastorage.googleapis.com/pub/gsutil.tar.gz

[root@techroad ~]# tar zxvf gsutil.tar.gz

//修改环境变量

[root@techroad ~]# vim ~/.bashrc

//添加

export PATH=${PATH}:$HOME/gsutil

export PYTHONPATH=${PYTHONPATH}:$HOME/gsutil/boto

[root@techroad ~]# source ./.bashrc

//输入access Key和Secret Access Key

[root@techroad ~]# gsutil ls

注意:运行gsutil ls 命令会提示输入Access Key和Secret Access Key,可以进入这里找到你的Access Key和Secret Access Key

如果运行gsutil工具无法用table补全,或者运行后提示-bash: sdlk: command not found是环境变量没有修改成功,先检查下是否修改正确,再退出一下终端从新进入。

三、使用GSUtil

首先说说Bucket这个是一个存储的容器,相对于你的家目录一样的,第一次进入Google Storage for Developers必须要建立一个Bucket,同时Bucket下可以递归创建目录object,类似于mkdir -p的命令

[root@techroad ~]# gsutil mb gs://terrancesiu gs://terrancesiu/shared gs://terrancesiu/source

//上传数据

[root@techroad ~]# gsutil cp ./conf.tar.gz gs://terrancesiu/source/conf.tar.gz

//列出文件

[root@techroad ~]# gsutil ls gs://terrancesiu

//移动文件

[source][root@techroad ~]# gsutil mv gs://terrancesiu/source/conf.tar.gz gs://terrance/shared/conf.tar.gz

//删除文件文件、bucket

[root@techroad ~]# gsutil rm gs://terrance/shared/conf.tar.gz

[root@techroad ~]# gsutil rb gs://terrance

文章来源:http://techroad.org/archives/577.html

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航